Bug 1257887 - Make windows opened through window.open() be scrollable by default. r=smaug
authorBen Tian <btian@mozilla.com>
Tue, 17 May 2016 11:25:47 +0800
changeset 298610 4adb52152ba4e1008d15634532ed985c10e8f3e4
parent 298609 9fa7e2a17ee96abc884352ec5482642b5da30a57
child 298611 2fd48137efe57976965de8a417aa38681fc08d01
push id77249
push usercbook@mozilla.com
push dateTue, 24 May 2016 08:47:36 +0000
treeherdermozilla-inbound@7d7c5acc9b1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1257887
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1257887 - Make windows opened through window.open() be scrollable by default. r=smaug
dom/html/test/test_bug369370.html
dom/tests/mochitest/bugs/test_window_bar.html
embedding/components/windowwatcher/nsWindowWatcher.cpp
layout/base/tests/test_transformed_scrolling_repaints_3.html
modules/libpref/init/all.js
--- a/dom/html/test/test_bug369370.html
+++ b/dom/html/test/test_bug369370.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=369370
 -->
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>Test for Bug 369370</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
   <script type="text/javascript">
     /*
      * Test strategy:
      */
     function makeClickFor(x, y) {
@@ -136,16 +136,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 
         test6();
     }
     var kidWin;
     var kidDoc;
 
     SimpleTest.waitForExplicitFinish();
     SpecialPowers.pushPrefEnv({"set":[["browser.enable_automatic_image_resizing", true]]}, function() {
-       kidWin = window.open("bug369370-popup.png", "bug369370", "width=400,height=300");
+       kidWin = window.open("bug369370-popup.png", "bug369370", "width=400,height=300,scrollbars=no");
        // will init onload
        ok(kidWin, "opened child window");
        kidWin.onload = childLoaded;
     });
   </script>
 </body>
 </html>
--- a/dom/tests/mochitest/bugs/test_window_bar.html
+++ b/dom/tests/mochitest/bugs/test_window_bar.html
@@ -53,17 +53,16 @@ function testWindow(w)
       var enabled = w.location.search == '?true';
       is(w[feature].visible, enabled, feature + ' should follow window.open settings.');
     }
   }
 
   checkFeature('menubar');
   checkFeature('toolbar');
   checkFeature('personalbar');
-  checkFeature('scrollbars');
   checkFeature('statusbar', 'status');
   checkFeature('locationbar', 'location');
 
   w.close();
 
   numWindows++;
   if (numWindows == 3) {
     // We're done!
--- a/embedding/components/windowwatcher/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp
@@ -1538,17 +1538,17 @@ nsWindowWatcher::URIfromURL(const char* 
 
   // build and return the absolute URI
   return NS_NewURI(aURI, aURL, baseURI);
 }
 
 #define NS_CALCULATE_CHROME_FLAG_FOR(feature, flag)                            \
   prefBranch->GetBoolPref(feature, &forceEnable);                              \
   if (forceEnable && !(aDialog && !openedFromContentScript) &&                 \
-      !(!openedFromContentScript && aHasChromeParent) && !aChromeURL) {                  \
+      !(!openedFromContentScript && aHasChromeParent) && !aChromeURL) {        \
     chromeFlags |= flag;                                                       \
   } else {                                                                     \
     chromeFlags |=                                                             \
       WinHasOption(aFeatures, feature, 0, &presenceFlag) ? flag : 0;           \
   }
 
 /**
  * Calculate the chrome bitmask from a string list of features.
@@ -1653,23 +1653,26 @@ nsWindowWatcher::CalculateChromeFlags(mo
   NS_CALCULATE_CHROME_FLAG_FOR("location",
                                nsIWebBrowserChrome::CHROME_LOCATIONBAR);
   NS_CALCULATE_CHROME_FLAG_FOR("personalbar",
                                nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR);
   NS_CALCULATE_CHROME_FLAG_FOR("status",
                                nsIWebBrowserChrome::CHROME_STATUSBAR);
   NS_CALCULATE_CHROME_FLAG_FOR("menubar",
                                nsIWebBrowserChrome::CHROME_MENUBAR);
-  NS_CALCULATE_CHROME_FLAG_FOR("scrollbars",
-                               nsIWebBrowserChrome::CHROME_SCROLLBARS);
   NS_CALCULATE_CHROME_FLAG_FOR("resizable",
                                nsIWebBrowserChrome::CHROME_WINDOW_RESIZE);
   NS_CALCULATE_CHROME_FLAG_FOR("minimizable",
                                nsIWebBrowserChrome::CHROME_WINDOW_MIN);
 
+  // default scrollbar to "on," unless explicitly turned off
+  if (WinHasOption(aFeatures, "scrollbars", 1, &presenceFlag) || !presenceFlag) {
+    chromeFlags |= nsIWebBrowserChrome::CHROME_SCROLLBARS;
+  }
+
   chromeFlags |= WinHasOption(aFeatures, "popup", 0, &presenceFlag) ?
     nsIWebBrowserChrome::CHROME_WINDOW_POPUP : 0;
 
   /* OK.
      Normal browser windows, in spite of a stated pattern of turning off
      all chrome not mentioned explicitly, will want the new OS chrome (window
      borders, titlebars, closebox) on, unless explicitly turned off.
      Dialogs, on the other hand, take the absence of any explicit settings
--- a/layout/base/tests/test_transformed_scrolling_repaints_3.html
+++ b/layout/base/tests/test_transformed_scrolling_repaints_3.html
@@ -10,15 +10,15 @@
 <pre id="test">
 <script type="application/javascript">
 SimpleTest.waitForExplicitFinish();
 
 SpecialPowers.pushPrefEnv(
   {"set": [["layers.single-tile.enabled", false]]},
   function() {
     window.open("transformed_scrolling_repaints_3_window.html", "transformed_scrolling_repaints_3",
-                "chrome,width=300,height=400");
+                "chrome,width=300,height=400,scrollbars=no");
   }
 );
 </script>
 </pre>
 </body>
 </html>
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1067,17 +1067,16 @@ pref("dom.disable_window_move_resize",  
 pref("dom.disable_window_status_change",    false);
 
 pref("dom.disable_window_open_feature.titlebar",    false);
 pref("dom.disable_window_open_feature.close",       false);
 pref("dom.disable_window_open_feature.toolbar",     false);
 pref("dom.disable_window_open_feature.location",    false);
 pref("dom.disable_window_open_feature.personalbar", false);
 pref("dom.disable_window_open_feature.menubar",     false);
-pref("dom.disable_window_open_feature.scrollbars",  false);
 pref("dom.disable_window_open_feature.resizable",   true);
 pref("dom.disable_window_open_feature.minimizable", false);
 pref("dom.disable_window_open_feature.status",      true);
 
 pref("dom.allow_scripts_to_close_windows",          false);
 
 pref("dom.require_user_interaction_for_beforeunload", true);