|
1 <!-- |
|
2 Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 --> |
|
5 <html> |
|
6 <head> |
|
7 <title>Indexed Database Test</title> |
|
8 |
|
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 |
|
12 <script type="text/javascript;version=1.7"> |
|
13 const testData = [ |
|
14 { host: "http://" + window.location.host, expectedResult: true }, |
|
15 { host: "http://example.com", expectedResult: false }, |
|
16 { host: "http://sub1.test2.example.org:8000", expectedResult: false }, |
|
17 { host: "http://" + window.location.host, expectedResult: true } |
|
18 ]; |
|
19 |
|
20 const iframe1Path = |
|
21 window.location.pathname.replace("test_third_party.html", |
|
22 "third_party_iframe1.html"); |
|
23 const iframe2URL = |
|
24 "http://" + window.location.host + |
|
25 window.location.pathname.replace("test_third_party.html", |
|
26 "third_party_iframe2.html"); |
|
27 |
|
28 let testIndex = 0; |
|
29 let testRunning = false; |
|
30 |
|
31 function iframeLoaded() { |
|
32 let message = { source: "parent", href: iframe2URL }; |
|
33 let iframe = document.getElementById("iframe1"); |
|
34 iframe.contentWindow.postMessage(message.toSource(), "*"); |
|
35 } |
|
36 |
|
37 function setiframe() { |
|
38 let iframe = document.getElementById("iframe1"); |
|
39 |
|
40 if (!testRunning) { |
|
41 testRunning = true; |
|
42 iframe.addEventListener("load", iframeLoaded, false); |
|
43 } |
|
44 |
|
45 iframe.src = testData[testIndex].host + iframe1Path; |
|
46 } |
|
47 |
|
48 function messageListener(event) { |
|
49 let message = eval(event.data); |
|
50 |
|
51 is(message.source, "iframe", "Good source"); |
|
52 is(message.result, testData[testIndex].expectedResult, "Good result"); |
|
53 |
|
54 if (testIndex < testData.length - 1) { |
|
55 testIndex++; |
|
56 setiframe(); |
|
57 return; |
|
58 } |
|
59 |
|
60 SimpleTest.finish(); |
|
61 } |
|
62 |
|
63 function runTest() { |
|
64 SimpleTest.waitForExplicitFinish(); |
|
65 window.addEventListener("message", messageListener, false); |
|
66 setiframe(); |
|
67 } |
|
68 </script> |
|
69 |
|
70 </head> |
|
71 |
|
72 <body onload="runTest();"> |
|
73 <iframe id="iframe1"></iframe> |
|
74 </body> |
|
75 |
|
76 </html> |