dom/tests/mochitest/bugs/test_bug260264_nested.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial