|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=260264 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 260264</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" src="utils_bug260264.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=260264">Mozilla Bug 260264</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript"> |
|
20 |
|
21 /** Test for Bug 260264 **/ |
|
22 |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 |
|
25 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
|
26 var popupEvents = makePrefAccessor("dom.popup_allowed_events"), |
|
27 blockPopups = makePrefAccessor("dom.disable_open_during_load"), |
|
28 ownPopupPriv = makePopupPrivAccessor(location.href), |
|
29 ecPopupPriv = makePopupPrivAccessor("http://example.com"); |
|
30 |
|
31 function test_nested_frames() { |
|
32 |
|
33 var savedBlockPopups = blockPopups(true); |
|
34 |
|
35 // Grandchild will use this name to refer to the current window: |
|
36 window.name = "parent260264"; |
|
37 |
|
38 function performer(event) { |
|
39 $("display").appendChild(document.createElement("iframe")).src = |
|
40 alter_file(alter_host(location.href, "example.com"), |
|
41 "child_bug260264.html#" + event); |
|
42 } |
|
43 |
|
44 function finisher(old) { |
|
45 popupEvents(old.events); |
|
46 ownPopupPriv(old.ownPriv); |
|
47 ecPopupPriv(old.ecPriv); |
|
48 } |
|
49 |
|
50 function should_have_blocked(popup) { |
|
51 ok(!popup, "popup should have been blocked"); |
|
52 } |
|
53 |
|
54 function should_not_have_blocked(popup) { |
|
55 ok(popup, "popup should not have been blocked"); |
|
56 } |
|
57 |
|
58 /** |
|
59 * The example_priv parameter controls whether or not the child frame has |
|
60 * popup clearance. Neither the top window nor the grandchild frame have |
|
61 * this clearance. The point of these tests is to make sure the child's |
|
62 * clearance (or lack thereof) is properly considered when opening a popup |
|
63 * from the grandchild. |
|
64 */ |
|
65 function makeTest(event, example_priv, reporter, allowed_events) { |
|
66 return { |
|
67 event: event, |
|
68 setup: function(old) { |
|
69 old.events = popupEvents(allowed_events || "click mouseup"); |
|
70 old.ownPriv = ownPopupPriv(DENY_ACTION); |
|
71 old.ecPriv = ecPopupPriv(example_priv); |
|
72 }, |
|
73 report: reporter, |
|
74 perform: performer, |
|
75 finish: finisher |
|
76 }; |
|
77 }; |
|
78 |
|
79 var tests = [ |
|
80 makeTest("mouseup", DENY_ACTION, should_not_have_blocked), |
|
81 makeTest("mouseup", ALLOW_ACTION, should_not_have_blocked), |
|
82 makeTest("mouseup", ALLOW_ACTION, should_not_have_blocked, "click"), |
|
83 makeTest("mouseup", DENY_ACTION, should_have_blocked, "click"), |
|
84 makeTest("mouseover", DENY_ACTION, should_have_blocked), |
|
85 makeTest("mouseover", ALLOW_ACTION, should_not_have_blocked), |
|
86 makeTest("click", DENY_ACTION, should_not_have_blocked), |
|
87 makeTest("click", ALLOW_ACTION, should_not_have_blocked) |
|
88 ]; |
|
89 |
|
90 function resume() { |
|
91 var options = tests[0]; |
|
92 if (options) { |
|
93 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
|
94 options.setup(tests[0].old = {}); |
|
95 options.perform(options.event); |
|
96 } else { |
|
97 blockPopups(savedBlockPopups); |
|
98 SimpleTest.finish(); |
|
99 } |
|
100 } |
|
101 |
|
102 // Visible to child windows: |
|
103 window.report = function(popup) { |
|
104 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
|
105 try { tests[0].report(popup) } |
|
106 finally { |
|
107 tests[0].finish(tests[0].old); |
|
108 tests.shift(); |
|
109 resume(); |
|
110 } |
|
111 } |
|
112 |
|
113 resume(); |
|
114 |
|
115 } |
|
116 |
|
117 test_nested_frames(); |
|
118 |
|
119 </script> |
|
120 </pre> |
|
121 </body> |
|
122 </html> |