diff --git a/html/browsers/history/the-location-interface/location-ancestororigins-involved.window.js b/html/browsers/history/the-location-interface/location-ancestororigins-involved.window.js new file mode 100644 index 00000000000000..1a100edac3f968 --- /dev/null +++ b/html/browsers/history/the-location-interface/location-ancestororigins-involved.window.js @@ -0,0 +1,180 @@ +// META: script=/common/get-host-info.sub.js + +function checkSupported() { + assert_implements('ancestorOrigins' in location, 'location.ancestorOrigins should be supported'); +} + +const embedPath = new URL("resources/ancestororigins-embed.py", location.href).pathname, + info = get_host_info(), + localOrigin = info.HTTP_ORIGIN, + localEmbed = localOrigin + embedPath, + remoteOrigin = info.HTTP_REMOTE_ORIGIN, + remoteEmbed = remoteOrigin + embedPath, + remoteOrigin2 = info.HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT, + remoteEmbed2 = remoteOrigin2 + embedPath; +let id = 0; + +async_test(t => { + checkSupported(); + const iframe = document.createElement("iframe"), + localId = ++id; + iframe.sandbox = "allow-scripts"; + iframe.src = localEmbed + "?iframe=|" + encodeURIComponent(remoteEmbed) + "?id=" + localId; + document.body.appendChild(iframe); + t.add_cleanup(() => iframe.remove()); + + self.addEventListener("message", t.step_func(e => { + if(e.data.id === localId) { + assert_array_equals(e.data.output, ["null", localOrigin]); + t.done(); + } + })); +}, "Ensure sandboxed iframes show up as null"); + +// The following code ends up generating multiple tests each with multiple nested " % (frameURL, frameReferrer)) + "\n" + + if b"id" in request.GET: + body = body + """ +""" % request.GET.first(b"id").decode("utf-8") + + if body == "": + return "Please specify either or both the 'iframe' and 'id' GET parameters." + return (headers, body)