1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/bugs/test_window_bar.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=642338 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 642338</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=642338">Mozilla Bug 642338</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script class="testbody" type="text/javascript"> 1.22 + 1.23 +/* Test that the following window properties work: 1.24 + 1.25 + menubar 1.26 + toolbar 1.27 + locationbar 1.28 + personalbar 1.29 + statusbar 1.30 + scrollbars 1.31 + 1.32 +*/ 1.33 + 1.34 +var numWindows = 0; 1.35 + 1.36 +/* Called when our popup loads. */ 1.37 +function testWindow(w) 1.38 +{ 1.39 + 1.40 + // If dom.disable_window_open_feature.X is true, then we can't disable 1.41 + // feature X when we call window.open from content. So to check that our popup 1.42 + // has the right bars shown, we need to check that it obeys first the pref 1.43 + // and then the arguments to window.open, if applicable. 1.44 + 1.45 + function checkFeature(feature, prefname) { 1.46 + if (prefname === undefined) 1.47 + prefname = feature; 1.48 + 1.49 + if (SpecialPowers.getBoolPref('dom.disable_window_open_feature.' + prefname)) { 1.50 + is(w[feature].visible, true, feature + ' should always be true.'); 1.51 + } 1.52 + else { 1.53 + // w.location.search == '?true' if we expect the bars to be on, and 1.54 + // '?false' otherwise. 1.55 + var enabled = w.location.search == '?true'; 1.56 + is(w[feature].visible, enabled, feature + ' should follow window.open settings.'); 1.57 + } 1.58 + } 1.59 + 1.60 + checkFeature('menubar'); 1.61 + checkFeature('toolbar'); 1.62 + checkFeature('personalbar'); 1.63 + checkFeature('scrollbars'); 1.64 + checkFeature('statusbar', 'status'); 1.65 + checkFeature('locationbar', 'location'); 1.66 + 1.67 + w.close(); 1.68 + 1.69 + numWindows++; 1.70 + if (numWindows == 2) { 1.71 + // We're done! 1.72 + SimpleTest.finish(); 1.73 + } 1.74 + 1.75 +} 1.76 + 1.77 +SimpleTest.waitForExplicitFinish(); 1.78 + 1.79 +// These will call back into testWindow when they open. 1.80 + 1.81 +var allBarsWindow = 1.82 + window.open('file_window_bar.html?true', 'all-bars', 1.83 + 'menubar=yes,toolbar=yes,location=yes,' + 1.84 + 'personalbar=yes,status=yes,scrollbars=yes', 1.85 + true); 1.86 + 1.87 +var noBarsWindow = 1.88 + window.open('file_window_bar.html?false', 'no-bars', 1.89 + 'menubar=no,toolbar=no,location=no,' + 1.90 + 'personalbar=no,status=no,scrollbars=no', 1.91 + false); 1.92 + 1.93 +</script> 1.94 +</pre> 1.95 +</body> 1.96 +</html>