Bug 1001854 - Search field length does not consistent after toggle "Hide the new tab page" and restart. r=adw, a=sledru
authorEd Lee <edilee@mozilla.com>
Mon, 28 Apr 2014 11:00:41 -0700
changeset 199086 bdef20bf49fb59191bb3e7f1532e181d4e71dfb3
parent 199085 025e2cc8643095b704f10f49ea9332675261b997
child 199087 2f253c8cf8d271f92931b745c4a3ab8489444a35
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, sledru
bugs1001854
milestone31.0a2
Bug 1001854 - Search field length does not consistent after toggle "Hide the new tab page" and restart. r=adw, a=sledru Trigger load event if the document was loaded before init such as the user toggling the page.
browser/base/content/newtab/grid.js
browser/base/content/test/newtab/browser.ini
browser/base/content/test/newtab/browser_newtab_bug1001854.js
--- a/browser/base/content/newtab/grid.js
+++ b/browser/base/content/newtab/grid.js
@@ -48,16 +48,21 @@ let gGrid = {
     this._createSiteFragment();
     this._renderGrid();
     gLinks.populateCache(() => {
       this._renderSites();
       this._ready = true;
     });
     addEventListener("load", this);
     addEventListener("resize", this);
+
+    // The document may already be loaded if the user is toggling the page
+    if (document.readyState == "complete") {
+      this.handleEvent({type: "load"});
+    }
   },
 
   /**
    * Creates a new site in the grid.
    * @param aLink The new site's link.
    * @param aCell The cell that will contain the new site.
    * @return The newly created site.
    */
--- a/browser/base/content/test/newtab/browser.ini
+++ b/browser/base/content/test/newtab/browser.ini
@@ -16,16 +16,17 @@ support-files =
 [browser_newtab_bug735987.js]
 skip-if = os == "mac" # Intermittent failures, bug 898317
 [browser_newtab_bug752841.js]
 [browser_newtab_bug765628.js]
 [browser_newtab_bug876313.js]
 [browser_newtab_bug991111.js]
 [browser_newtab_bug991210.js]
 [browser_newtab_bug998387.js]
+[browser_newtab_bug1001854.js]
 [browser_newtab_disable.js]
 [browser_newtab_drag_drop.js]
 [browser_newtab_drag_drop_ext.js]
 [browser_newtab_drop_preview.js]
 [browser_newtab_focus.js]
 [browser_newtab_perwindow_private_browsing.js]
 [browser_newtab_reset.js]
 [browser_newtab_search.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/newtab/browser_newtab_bug1001854.js
@@ -0,0 +1,20 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const PRELOAD_PREF = "browser.newtab.preload";
+
+function runTests() {
+  // turn off preload to ensure that a newtab page loads as disabled
+  Services.prefs.setBoolPref(PRELOAD_PREF, false);
+  Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, false);
+  yield addNewTabPageTab();
+
+  let search = getContentDocument().getElementById("newtab-search-form");
+  is(search.style.width, "", "search form has no width yet");
+
+  NewTabUtils.allPages.enabled = true;
+  isnot(search.style.width, "", "search form has width set");
+
+  // restore original state
+  Services.prefs.clearUserPref(PRELOAD_PREF);
+}