|
1 <html> |
|
2 <head> |
|
3 <title>Test for Bug 625187</title> |
|
4 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
7 <script type="text/javascript" src="prompt_common.js"></script> |
|
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> |
|
9 <!-- |
|
10 - Any copyright is dedicated to the Public Domain. |
|
11 - http://creativecommons.org/publicdomain/zero/1.0/ |
|
12 - |
|
13 - Contributor(s): |
|
14 - Mihai Sucan <mihai.sucan@gmail.com> |
|
15 --> |
|
16 </head> |
|
17 <body onload="runtest()"> |
|
18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=625187">Mozilla Bug 625187</a> |
|
19 |
|
20 <p><button onclick="alert('hello world')">Button</button></p> |
|
21 |
|
22 <iframe id="iframe_diff_origin" src="http://example.com/tests/toolkit/components/prompts/test/bug625187_iframe.html"></iframe> |
|
23 |
|
24 <iframe id="iframe_same_origin" src="bug625187_iframe.html"></iframe> |
|
25 |
|
26 <pre id="test"></pre> |
|
27 |
|
28 <script class="testbody" type="text/javascript"> |
|
29 SimpleTest.waitForExplicitFinish(); |
|
30 |
|
31 var testNum = 0; |
|
32 var dialogNum = 0; |
|
33 |
|
34 function hasTabModalPrompts() { |
|
35 var prefName = "prompts.tab_modal.enabled"; |
|
36 var Services = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").Services; |
|
37 return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL && |
|
38 Services.prefs.getBoolPref(prefName); |
|
39 } |
|
40 |
|
41 function runtest() |
|
42 { |
|
43 isTabModal = hasTabModalPrompts(); |
|
44 |
|
45 // This test depends on tab modal prompts being enabled. |
|
46 if (!isTabModal) { |
|
47 todo(false, "Test disabled when tab modal prompts are not enabled."); |
|
48 SimpleTest.finish(); |
|
49 return; |
|
50 } |
|
51 |
|
52 startCallbackTimer(); |
|
53 |
|
54 var button = document.querySelector("button"); |
|
55 dispatchMouseEvent(button, "click"); |
|
56 |
|
57 startCallbackTimer(); |
|
58 |
|
59 var iframe = document.getElementById("iframe_diff_origin"); |
|
60 button = SpecialPowers.wrap(iframe.contentWindow).document.getElementById("btn1"); |
|
61 dispatchMouseEvent(button, "click"); |
|
62 |
|
63 startCallbackTimer(); |
|
64 |
|
65 iframe = document.getElementById("iframe_same_origin"); |
|
66 button = iframe.contentWindow.document.getElementById("btn1"); |
|
67 dispatchMouseEvent(button, "click"); |
|
68 |
|
69 startCallbackTimer(); |
|
70 |
|
71 button = iframe.contentWindow.document.getElementById("btn2"); |
|
72 dispatchMouseEvent(button, "click"); |
|
73 |
|
74 SimpleTest.finish(); |
|
75 } |
|
76 |
|
77 function handleDialog(ui) |
|
78 { |
|
79 dialogNum++; |
|
80 if (dialogNum == 1 || dialogNum == 3 || dialogNum == 4) |
|
81 is(ui.infoTitle.getAttribute("hidden"), "true", |
|
82 "dialog #" + dialogNum + ": the tabprompt infoTitle element is hidden"); |
|
83 else if (dialogNum == 2) |
|
84 ok(!ui.infoTitle.hasAttribute("hidden"), |
|
85 "dialog #" + dialogNum + ": the tabprompt infoTitle element is not hidden"); |
|
86 |
|
87 synthesizeMouse(ui.button0, 2, 2, {}, SpecialPowers.unwrap(ui.button0.ownerDocument.defaultView)); |
|
88 } |
|
89 |
|
90 function dispatchMouseEvent(target, type) |
|
91 { |
|
92 var win = SpecialPowers.unwrap(target.ownerDocument.defaultView); |
|
93 var e = document.createEvent("MouseEvent"); |
|
94 e.initEvent(type, false, false, win, 0, 1, 1, 1, 1, |
|
95 false, false, false, false, 0, null); |
|
96 var utils = SpecialPowers.getDOMWindowUtils(win); |
|
97 utils.dispatchDOMEventViaPresShell(SpecialPowers.unwrap(target), e, true); |
|
98 } |
|
99 </script> |
|
100 </body> |
|
101 </html> |