Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / security / isolatedWorld / userGestureEvents.html
1 <!DOCTYPE html>
2 <html>
3 <title>Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page</title>
4 <script>
5
6 // This test is meaningless without a testRunner.
7 if (window.testRunner && window.eventSender) {
8
9     testRunner.setCanOpenWindows(true);
10     testRunner.waitUntilDone();
11     testRunner.dumpAsText();
12
13     function newTest(title)
14     {
15         document.getElementById("log").innerHTML += "<br>" + title + ": ";
16     }
17
18     function pass()
19     {
20         document.getElementById("log").innerHTML += "PASS\n";
21         testRunner.notifyDone();
22     }
23
24     // (This function is run within an isolated world)
25     function userGestureEventListener()
26     {
27         // Register an event handler that will try to perform an action that can only be initiated by a user gesture (opening a window).
28         document.getElementById("button1").onclick = function()
29         {
30             window.open("resources/userGestureEvents-second-window.html", "resources/userGestureEvents-second-window.html");
31         }
32     }
33
34     function runTestInWorld(worldId, funcName)
35     {
36         testRunner.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");
37     }
38
39     function runTest() 
40     {
41         newTest("Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page.");
42         runTestInWorld(1, "userGestureEventListener");
43
44         // Click somewhere on the button!
45         var testDiv = document.getElementById("test");
46         eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);
47         eventSender.mouseDown();
48         eventSender.mouseUp();
49     }
50
51 } else
52     document.getElementById("log").innerHTML += "FAIL\n";
53 </script>
54 <body onload="runTest()">
55     <div id="test"><button id='button1'>Click Me</button></div>
56     <div id="log"></div>
57 </body>
58 </html>