dom/tests/mochitest/bugs/test_window_bar.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=642338
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 642338</title>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=642338">Mozilla Bug 642338</a>
michael@0 13 <p id="display"></p>
michael@0 14 <div id="content" style="display: none">
michael@0 15
michael@0 16 </div>
michael@0 17 <pre id="test">
michael@0 18 <script class="testbody" type="text/javascript">
michael@0 19
michael@0 20 /* Test that the following window properties work:
michael@0 21
michael@0 22 menubar
michael@0 23 toolbar
michael@0 24 locationbar
michael@0 25 personalbar
michael@0 26 statusbar
michael@0 27 scrollbars
michael@0 28
michael@0 29 */
michael@0 30
michael@0 31 var numWindows = 0;
michael@0 32
michael@0 33 /* Called when our popup loads. */
michael@0 34 function testWindow(w)
michael@0 35 {
michael@0 36
michael@0 37 // If dom.disable_window_open_feature.X is true, then we can't disable
michael@0 38 // feature X when we call window.open from content. So to check that our popup
michael@0 39 // has the right bars shown, we need to check that it obeys first the pref
michael@0 40 // and then the arguments to window.open, if applicable.
michael@0 41
michael@0 42 function checkFeature(feature, prefname) {
michael@0 43 if (prefname === undefined)
michael@0 44 prefname = feature;
michael@0 45
michael@0 46 if (SpecialPowers.getBoolPref('dom.disable_window_open_feature.' + prefname)) {
michael@0 47 is(w[feature].visible, true, feature + ' should always be true.');
michael@0 48 }
michael@0 49 else {
michael@0 50 // w.location.search == '?true' if we expect the bars to be on, and
michael@0 51 // '?false' otherwise.
michael@0 52 var enabled = w.location.search == '?true';
michael@0 53 is(w[feature].visible, enabled, feature + ' should follow window.open settings.');
michael@0 54 }
michael@0 55 }
michael@0 56
michael@0 57 checkFeature('menubar');
michael@0 58 checkFeature('toolbar');
michael@0 59 checkFeature('personalbar');
michael@0 60 checkFeature('scrollbars');
michael@0 61 checkFeature('statusbar', 'status');
michael@0 62 checkFeature('locationbar', 'location');
michael@0 63
michael@0 64 w.close();
michael@0 65
michael@0 66 numWindows++;
michael@0 67 if (numWindows == 2) {
michael@0 68 // We're done!
michael@0 69 SimpleTest.finish();
michael@0 70 }
michael@0 71
michael@0 72 }
michael@0 73
michael@0 74 SimpleTest.waitForExplicitFinish();
michael@0 75
michael@0 76 // These will call back into testWindow when they open.
michael@0 77
michael@0 78 var allBarsWindow =
michael@0 79 window.open('file_window_bar.html?true', 'all-bars',
michael@0 80 'menubar=yes,toolbar=yes,location=yes,' +
michael@0 81 'personalbar=yes,status=yes,scrollbars=yes',
michael@0 82 true);
michael@0 83
michael@0 84 var noBarsWindow =
michael@0 85 window.open('file_window_bar.html?false', 'no-bars',
michael@0 86 'menubar=no,toolbar=no,location=no,' +
michael@0 87 'personalbar=no,status=no,scrollbars=no',
michael@0 88 false);
michael@0 89
michael@0 90 </script>
michael@0 91 </pre>
michael@0 92 </body>
michael@0 93 </html>

mercurial