Bug 1942639 - Propagate --filter argument from desktop_unittest.py to runreftest...
[gecko.git] / dom / xslt / tests / mochitest / test_bug1769155.html
blobe11b374ae07aa6f1e7ad8826f862d80a08c41ce4
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>XSLT error results shouldn't replace documents loaded during the transform</title>
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
8 <script>
9 SimpleTest.waitForExplicitFinish();
11 async function runTest() {
12 const crossOriginLocation = "https://example.org/tests/dom/xslt/tests/mochitest/file_bug1769155.html";
13 const sjs = new URL("bug1769155.sjs", location.href);
14 // During the XSLT processing we redirect by setting location and then
15 // spin the event loop using synchronous XHR, so that the location change
16 // happens while we're still processing the XSLT.
17 let xml = `
18 <?xml-stylesheet type="application/xml" href="#sheet"?>
19 <stylesheet id="sheet" version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
20 <template match="/">
21 <script xmlns="http://www.w3.org/1999/xhtml">
22 location = "${crossOriginLocation}";
23 let xhr = new XMLHttpRequest();
24 xhr.open("GET", "${sjs.href}", false);
25 xhr.send();
26 <\/script>
27 </template>
28 </stylesheet>`;
30 let win = window.open();
32 let redirected = new Promise((resolve) => {
33 addEventListener("message", resolve, { once: true });
34 });
36 SpecialPowers.spawn(win, [xml], value => {
37 content.location = URL.createObjectURL(new Blob([ value ], { type: "application/xml" }));
38 });
39 await redirected;
41 // At this point the setting of window.location should have redirected us to
42 // a cross-origin site.
43 let threw = false;
44 try {
45 win.document;
46 } catch {
47 threw = true;
49 ok(threw, "Accessing a property on a cross-origin window should fail.");
51 win.close();
53 SimpleTest.finish();
55 </script>
56 </head>
57 <body onload="runTest();">
58 <p id="display"></p>
59 <div id="content" style="display: none"></div>
60 <pre id="test"></pre>
61 </body>
62 </html>