Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / security / isolatedWorld / events.html
index 7da973b..746a2a4 100644 (file)
-<!DOCTYPE html>\r
-<html>\r
-<title>Test how event handlers work with isolated Worlds</title>\r
-<script>\r
-\r
-// This test is meaningless without testRunner.\r
-if (window.testRunner && window.eventSender) {\r
-\r
-    testRunner.dumpAsText();\r
-    testRunner.waitUntilDone();\r
-\r
-    window.textAttributeEventsCount = 0;\r
-    window.xhrEventsCount = 0;\r
-    window.functionAttributeEventsCount = 0;\r
-    window.addEventListener("message", function(message)\r
-    {\r
-        testRunner.notifyDone();\r
-    }, false);\r
-\r
-    window.textAttributeEventsCallback = function()\r
-    {\r
-        if (textAttributeEventsCount++)\r
-            document.getElementById("log").innerHTML += "PASS";\r
-    }\r
-\r
-    function newTest(title)\r
-    {\r
-        document.getElementById("log").innerHTML += "<br>" + title + ": ";\r
-    }\r
-\r
-    function textAttributeEventListener()\r
-    {\r
-        window.textAttributeEventsCallback = function()\r
-        {\r
-            if (window.alreadyFailed)\r
-                return;\r
-             document.getElementById("log").innerHTML += "FAIL";\r
-             window.alreadyFailed = true;\r
-        }\r
-\r
-        var test = document.getElementById("test");\r
-        test.innerHTML = "<button id='button1' onclick='textAttributeEventsCallback()'></button>";\r
-        document.getElementById("button1").click();\r
-    }\r
-\r
-    function functionAttributeEventListener()\r
-    {\r
-        var test = document.getElementById("test");\r
-        var button = test.appendChild(document.createElement("button"));\r
-        window.functionAttributeEventsCount = 0;\r
-        button.onclick = function()\r
-        {\r
-            if (window.functionAttributeEventsCount++)\r
-                document.getElementById("log").innerHTML += "PASS";\r
-        }\r
-        button.style.cssText = "width: 30px;height:30px";\r
-        button.click();\r
-    }\r
-\r
-    function xhrEventListener()\r
-    {\r
-        window.xhrWorld = 1;\r
-        var done;\r
-        var xhr = new XMLHttpRequest();\r
-        xhr.open("GET", "anyfile", true);\r
-        xhr.onreadystatechange = function() {\r
-            if (done)\r
-                return;\r
-            done = true;\r
-            document.getElementById("log").innerHTML += window.xhrWorld  ? "PASS" : "FAIL";\r
-            window.postMessage("done", "*");\r
-        };\r
-        xhr.send(null);\r
-    }\r
-\r
-    function runTestInWorld(worldId, funcName)\r
-    {\r
-        testRunner.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");\r
-    }\r
-\r
-    function runTest() \r
-    {\r
-        newTest("Text attribute event listeners should always fire in main world");\r
-        runTestInWorld(1, "textAttributeEventListener");\r
-        var button1 = document.getElementById("button1");\r
-        button1.click();\r
-        button1.parentElement.removeChild(button1);\r
-        \r
-        newTest("Function attribute event listeners should fire in the world where they were created");\r
-        runTestInWorld(1, "functionAttributeEventListener");\r
-        var testDiv = document.getElementById("test");\r
-        // Land somewhere on the button.\r
-        eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);\r
-        eventSender.mouseDown();\r
-        eventSender.mouseUp();\r
-\r
-        newTest("XHR attribute event listeners should fire in the world where they were created");\r
-        runTestInWorld(1, "xhrEventListener");\r
-    }\r
-}\r
-</script>\r
-<body onload="runTest()">\r
-    <div id="test"></div>\r
-    <div id="log"></div>\r
-</body>\r
-</html>\r
+<!DOCTYPE html>
+<html>
+<title>Test how event handlers work with isolated Worlds</title>
+<script>
+
+// This test is meaningless without testRunner.
+if (window.testRunner && window.eventSender) {
+
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+
+    window.textAttributeEventsCount = 0;
+    window.xhrEventsCount = 0;
+    window.functionAttributeEventsCount = 0;
+    window.addEventListener("message", function(message)
+    {
+        testRunner.notifyDone();
+    }, false);
+
+    window.textAttributeEventsCallback = function()
+    {
+        if (textAttributeEventsCount++)
+            document.getElementById("log").innerHTML += "PASS";
+    }
+
+    function newTest(title)
+    {
+        document.getElementById("log").innerHTML += "<br>" + title + ": ";
+    }
+
+    function textAttributeEventListener()
+    {
+        window.textAttributeEventsCallback = function()
+        {
+            if (window.alreadyFailed)
+                return;
+             document.getElementById("log").innerHTML += "FAIL";
+             window.alreadyFailed = true;
+        }
+
+        var test = document.getElementById("test");
+        test.innerHTML = "<button id='button1' onclick='textAttributeEventsCallback()'></button>";
+        document.getElementById("button1").click();
+    }
+
+    function functionAttributeEventListener()
+    {
+        var test = document.getElementById("test");
+        var button = test.appendChild(document.createElement("button"));
+        window.functionAttributeEventsCount = 0;
+        button.onclick = function()
+        {
+            if (window.functionAttributeEventsCount++)
+                document.getElementById("log").innerHTML += "PASS";
+        }
+        button.style.cssText = "width: 30px;height:30px";
+        button.click();
+    }
+
+    function xhrEventListener()
+    {
+        window.xhrWorld = 1;
+        var done;
+        var xhr = new XMLHttpRequest();
+        xhr.open("GET", "anyfile", true);
+        xhr.onreadystatechange = function() {
+            if (done)
+                return;
+            done = true;
+            document.getElementById("log").innerHTML += window.xhrWorld  ? "PASS" : "FAIL";
+            window.postMessage("done", "*");
+        };
+        xhr.send(null);
+    }
+
+    function runTestInWorld(worldId, funcName)
+    {
+        testRunner.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");
+    }
+
+    function runTest() 
+    {
+        newTest("Text attribute event listeners should always fire in main world");
+        runTestInWorld(1, "textAttributeEventListener");
+        var button1 = document.getElementById("button1");
+        button1.click();
+        button1.parentElement.removeChild(button1);
+        
+        newTest("Function attribute event listeners should fire in the world where they were created");
+        runTestInWorld(1, "functionAttributeEventListener");
+        var testDiv = document.getElementById("test");
+        // Land somewhere on the button.
+        eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+
+        newTest("XHR attribute event listeners should fire in the world where they were created");
+        runTestInWorld(1, "xhrEventListener");
+    }
+}
+</script>
+<body onload="runTest()">
+    <div id="test"></div>
+    <div id="log"></div>
+</body>
+</html>