test_bug260264_nested.html (3730B)
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 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 function makeIframe(aEvent) { 26 var tempURL = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')+1); 27 tempURL = 'http://example.com' + tempURL + "child_bug260264.html#" + aEvent; 28 $("display").appendChild(document.createElement("iframe")).src = tempURL; 29 } 30 31 function test_nested_frames() { 32 SpecialPowers.pushPrefEnv({"set": [["dom.disable_open_during_load", true]]}, test_nested_frames2); 33 } 34 35 function test_nested_frames2() { 36 // Grandchild will use this name to refer to the current window: 37 window.name = "parent260264"; 38 39 if (tests[0]) { 40 tests[0].setup(function() {makeIframe(tests[0].event);}); 41 } else { 42 ok(false, "There should have run 8 tests here"); 43 SimpleTest.finish(); 44 } 45 } 46 47 function should_have_blocked(popup) { 48 ok(!popup, "popup should have been blocked"); 49 } 50 51 function should_not_have_blocked(popup) { 52 ok(popup, "popup should not have been blocked"); 53 } 54 55 function setupPP(aAllowedEvents, aPopup1, aPopup2, aNext) { 56 SpecialPowers.pushPrefEnv({"set": [["dom.popup_allowed_events", aAllowedEvents]]}, function() { 57 SpecialPowers.pushPermissions([{'type': 'popup', 'allow': aPopup1, 'context': document}, 58 {'type': 'popup', 'allow': aPopup2, 'context': 'http://example.com'}], aNext); 59 }); 60 } 61 62 /** 63 * The example_priv (DENY_ACTION) parameter controls whether or not the child frame has 64 * popup clearance. Neither the top window nor the grandchild frame have 65 * this clearance. The point of these tests is to make sure the child's 66 * clearance (or lack thereof) is properly considered when opening a popup 67 * from the grandchild. 68 */ 69 70 var tests = [ 71 { event: "mouseup", 72 setup(aNext) { 73 setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext); 74 }, 75 report: should_have_blocked 76 }, 77 { event: "mouseup", 78 setup(aNext) { 79 setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext); 80 }, 81 report: should_not_have_blocked 82 }, 83 { event: "mouseup", 84 setup(aNext) { 85 setupPP("click", ALLOW_ACTION, ALLOW_ACTION, aNext); 86 }, 87 report: should_not_have_blocked 88 }, 89 { event: "mouseup", 90 setup(aNext) { 91 setupPP("click", DENY_ACTION, DENY_ACTION, aNext); 92 }, 93 report: should_have_blocked 94 }, 95 { event: "mouseover", 96 setup(aNext) { 97 setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext); 98 }, 99 report: should_have_blocked 100 }, 101 { event: "mouseover", 102 setup(aNext) { 103 setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext); 104 }, 105 report: should_not_have_blocked 106 }, 107 { event: "click", 108 setup(aNext) { 109 setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext); 110 }, 111 report: should_have_blocked 112 }, 113 { event: "click", 114 setup(aNext) { 115 setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext); 116 }, 117 report: should_not_have_blocked 118 } 119 ]; 120 121 // Visible to child windows: 122 function report(popup) { 123 tests[0].report(popup); 124 tests.shift(); 125 126 if (tests[0]) { 127 tests[0].setup(function() {makeIframe(tests[0].event);}); 128 } else { 129 SimpleTest.finish(); 130 } 131 } 132 133 test_nested_frames(); 134 135 </script> 136 </pre> 137 </body> 138 </html>