Skip to content

Commit a4373b8

Browse files
mikewestchromium-wpt-export-bot
authored andcommitted
[Origin API] Drop Location and WorkerLocation conversions.
After discussion with Anne in [1], it makes sense to drop conversions from `Location` and `WorkerLocation` objects via `Origin.from()`. Those can meaningfully differ from the origin of the context to which they belong due to sandboxing, and we should encourage developers to use the right `Origin` representation going forward. [1]: whatwg/html#11846 (comment) Bug: 434131026 Change-Id: Ie8101ac9743767a32c109b83bdc82c9bb715d3b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7186344 Reviewed-by: Antonio Sartori <[email protected]> Commit-Queue: Mike West <[email protected]> Cr-Commit-Position: refs/heads/main@{#1549657}
1 parent 1b59c6e commit a4373b8

File tree

1 file changed

+2
-40
lines changed

1 file changed

+2
-40
lines changed

html/browsers/origin/tentative/api/origin-from-location.window.js

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,8 @@
22
// META: script=/common/get-host-info.sub.js
33

44
test(t => {
5-
const origin = Origin.from(window.location);
6-
assert_true(!!origin);
7-
assert_false(origin.opaque);
8-
assert_true(origin.isSameOrigin(Origin.from(get_host_info().ORIGIN)));
9-
}, `Origin.from(window.location) returns a tuple origin.`);
10-
11-
async_test(t => {
12-
const el = document.createElement('iframe');
13-
el.src = "/common/blank.html";
14-
el.onload = t.step_func_done(_ => {
15-
const origin = Origin.from(el.contentWindow.location);
16-
assert_true(!!origin);
17-
assert_false(origin.opaque);
18-
assert_true(origin.isSameOrigin(Origin.from(get_host_info().ORIGIN)));
19-
});
20-
document.body.appendChild(el);
21-
}, `Origin.from(Location) returns a tuple origin for same-origin frames.`);
5+
assert_throws_js(TypeError, _ => Origin.from(window.location));
6+
}, `Origin.from(window.location) throws.`);
227

238
async_test(t => {
249
const el = document.createElement('iframe');
@@ -28,26 +13,3 @@ async_test(t => {
2813
});
2914
document.body.appendChild(el);
3015
}, `Origin.from(Location) throws for cross-origin frames.`);
31-
32-
async_test(t => {
33-
const w = window.open("/html/browsers/windows/resources/post-to-opener.html");
34-
window.addEventListener("message", t.step_func(e => {
35-
if (e.source === w) {
36-
const origin = Origin.from(w.location);
37-
assert_true(!!origin);
38-
assert_false(origin.opaque);
39-
assert_true(origin.isSameOrigin(Origin.from(get_host_info().ORIGIN)));
40-
t.done();
41-
}
42-
}));
43-
}, `Origin.from(Location) returns a tuple origin for same-origin windows.`);
44-
45-
async_test(t => {
46-
const w = window.open(get_host_info().REMOTE_ORIGIN + "/html/browsers/windows/resources/post-to-opener.html");
47-
window.addEventListener("message", t.step_func(e => {
48-
if (e.source === w) {
49-
assert_throws_js(TypeError, _ => Origin.from(w.location));
50-
t.done();
51-
}
52-
}));
53-
}, `Origin.from(Location) throws for cross-origin windows.`);

0 commit comments

Comments
 (0)