Skip to content

Commit f0d3e4c

Browse files
committed
ancestorOrigins: add tests and update Location IDL
See whatwg/html#1918 for the HTML Standard discussion and whatwg/html#2480 for the HTML Standard change.
1 parent e84ca6a commit f0d3e4c

File tree

4 files changed

+255
-16
lines changed

4 files changed

+255
-16
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
// META: script=/common/get-host-info.sub.js
2+
3+
const embedPath = new URL("resources/ancestororigins-embed.py", location.href).pathname,
4+
info = get_host_info(),
5+
localOrigin = info.HTTP_ORIGIN,
6+
localEmbed = localOrigin + embedPath,
7+
remoteOrigin = info.HTTP_REMOTE_ORIGIN,
8+
remoteEmbed = remoteOrigin + embedPath,
9+
remoteOrigin2 = info.HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT
10+
remoteEmbed2 = remoteOrigin2 + embedPath
11+
let id = 0
12+
13+
async_test(t => {
14+
const iframe = document.createElement("iframe"),
15+
localId = ++id
16+
iframe.sandbox = "allow-scripts"
17+
iframe.src = localEmbed + "?iframe=|" + remoteEmbed + "?id=" + localId
18+
document.body.appendChild(iframe)
19+
t.add_cleanup(() => iframe.remove())
20+
21+
22+
self.addEventListener("message", t.step_func(e => {
23+
if(e.data.id === localId) {
24+
assert_array_equals(e.data.output, ["null", localOrigin])
25+
t.done()
26+
}
27+
}))
28+
}, "Ensure sandboxed iframes show up as null")
29+
30+
// The following code ends up generating multiple tests each with multiple nested " % (frameURL, frameReferrer)) + "\n"
12+
13+
if "id" in request.GET:
14+
body = body + """
18+
""" % request.GET.first("id")
19+
20+
if body == "":
21+
return "Please specify either or both the 'iframe' and 'id' GET parameters."
22+
return body

interfaces/html.idl

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,22 +1433,29 @@ interface History {
14331433
void replaceState(any data, DOMString title, optional DOMString? url = null);
14341434
};
14351435

1436-
[Unforgeable] interface Location {
1437-
stringifier attribute USVString href;
1438-
readonly attribute USVString origin;
1439-
attribute USVString protocol;
1440-
attribute USVString host;
1441-
attribute USVString hostname;
1442-
attribute USVString port;
1443-
attribute USVString pathname;
1444-
attribute USVString search;
1445-
attribute USVString hash;
1446-
1447-
void assign(USVString url);
1448-
void replace(USVString url);
1449-
void reload();
1450-
1451-
[SameObject] readonly attribute USVString[] ancestorOrigins;
1436+
[Exposed=(Window,Worker)]
1437+
interface DOMStringList {
1438+
readonly attribute unsigned long length;
1439+
getter DOMString? item(unsigned long index);
1440+
boolean contains(DOMString string);
1441+
};
1442+
1443+
interface Location {
1444+
[Unforgeable] stringifier attribute USVString href;
1445+
[Unforgeable] readonly attribute USVString origin;
1446+
[Unforgeable] attribute USVString protocol;
1447+
[Unforgeable] attribute USVString host;
1448+
[Unforgeable] attribute USVString hostname;
1449+
[Unforgeable] attribute USVString port;
1450+
[Unforgeable] attribute USVString pathname;
1451+
[Unforgeable] attribute USVString search;
1452+
[Unforgeable] attribute USVString hash;
1453+
1454+
[Unforgeable] void assign(USVString url);
1455+
[Unforgeable] void replace(USVString url);
1456+
[Unforgeable] void reload();
1457+
1458+
[Unforgeable, SameObject] readonly attribute DOMStringList ancestorOrigins;
14521459
};
14531460

14541461
[Constructor(DOMString type, optional PopStateEventInit eventInitDict)]

0 commit comments

Comments
 (0)