Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / security / dataURL / xss-DENIED-from-data-url-sub-frame-to-data-url-sub-frame.html
index 5fcec5b..55504f0 100644 (file)
@@ -2,47 +2,35 @@
 <head>
     <script src="../resources/cross-frame-access.js"></script>
     <script>
+        var subFramesLoaded = 0;
         if (window.testRunner) {
             testRunner.dumpAsText();
             testRunner.dumpChildFramesAsText();
             testRunner.waitUntilDone();
         }
 
+        function startTestWhenReady() {
+            if (++subFramesLoaded == 2)
+                document.getElementById('secondSubFrame').contentWindow.postMessage('perform test', '*');
+        }
+
         function loaded() {
             var firstURL = "data:text/html,<html>"
-                + "<head>"
-                +     "<scr" + "ipt>"
-                +         "function fireSentinel() {"
-                +             "if (window.testRunner)"
-                +                 "testRunner.globalFlag = true;"
-                +         "}"
-                +     "</scr" + "ipt>"
-                + "</head>"
-                + "<body onload=\"fireSentinel();\">"
+                + "<body>"
                 +     "<p>Inner iframe.</p>"
                 +     "<p id='accessMe'>Pass: Cross frame access from a sibling data: URL was denied.</p>"
                 + "</body>"
                 + "</html>";
 
             var iframe = document.getElementById("firstSubFrame");
+            iframe.onload = startTestWhenReady;
             iframe.src = firstURL;
 
             var secondURL = "data:text/html,<html>"
                 + "<head>"
                 +     "<scr" + "ipt>"
                 +         "function loaded() {"
-                +             "if (window.testRunner) {"
-                +                 "setTimeout(waitForFlag, 1);"
-                +                 "function waitForFlag() {"
-                +                     "if (!testRunner.globalFlag) {"
-                +                         "setTimeout(waitForFlag, 1);"
-                +                         "return;"
-                +                     "}"
-                +                     "performTest();"
-                +                 "}"
-                +             "} else {"
-                +                 "document.getElementById('console').innerHTML = 'Click the button when all the subframes have finished loading.';"
-                +             "}"
+                +             "window.addEventListener('message', performTest);"
                 +         "}"
                 +         "function performTest() {"
                 +             "try {"
                 + "</head>"
                 + "<body onload=\"loaded();\">"
                 +     "<p>Inner iframe.</p>"
-                +     "<button onclick='performTest();'>Test</button>"
                 +     "<pre id='console'></pre>"
                 + "</body>"
                 + "</html>";
 
             iframe = document.getElementById("secondSubFrame");
+            iframe.onload = startTestWhenReady;
             iframe.src = secondURL;
         }
     </script>