Bug 1685822 [wpt PR 27117] - [Import Maps] Add tests for rejecting multiple import...
[gecko.git] / dom / security / test / csp / test_null_baseuri.html
blob324b644f83e85eee38b9cd7eb9b514355ed1a73f
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Bug 1121857 - document.baseURI should not get blocked if baseURI is null</title>
5 <!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 </head>
9 <body>
10 <p id="display"></p>
11 <div id="content" style="visibility: hidden">
12 <iframe style="width:100%;" id="testframe"></iframe>
13 </div>
15 <script class="testbody" type="text/javascript">
17 /* Description of the test:
18 * Creating a 'base' element and appending that element
19 * to document.head. After setting baseTag.href and finally
20 * removing the created element from the head, the baseURI
21 * should be the inital baseURI of the page.
24 const TOTAL_TESTS = 3;
25 var test_counter = 0;
27 // a postMessage handler to communicate the results back to the parent.
28 window.addEventListener("message", receiveMessage);
30 function receiveMessage(event)
32 // make sure the base-uri before and after the test is the initial base uri of the page
33 if (event.data.test === "initial_base_uri") {
34 ok(event.data.baseURI.startsWith("http://mochi.test"), "baseURI should be 'http://mochi.test'!");
36 // check that appending the child and setting the base tag actually affects the base-uri
37 else if (event.data.test === "changed_base_uri") {
38 ok(event.data.baseURI === "http://www.base-tag.com/", "baseURI should be 'http://www.base-tag.com'!");
40 // we shouldn't get here, but just in case, throw an error.
41 else {
42 ok(false, "unrecognized test!");
45 if (++test_counter === TOTAL_TESTS) {
46 SimpleTest.finish();
50 function startTest() {
51 var src = "file_testserver.sjs";
52 // append the file that should be served
53 src += "?file=" + escape("tests/dom/security/test/csp/file_null_baseuri.html");
54 // using 'unsafe-inline' since we load the testcase using an inline script
55 // within file_null_baseuri.html
56 src += "&csp=" + escape("default-src * 'unsafe-inline';");
58 document.getElementById("testframe").src = src;
62 SimpleTest.waitForExplicitFinish();
63 startTest();
65 </script>
66 </body>
67 </html>