From e262621a275d49b5f647d5820e36aa884d8517d7 Mon Sep 17 00:00:00 2001 From: Mark Capella Date: Thu, 16 Aug 2012 16:45:00 +1200 Subject: [PATCH 1/7] Bug 783404 - Remove superfluous check that nsIDirectoryEnumerator returns a nsIFile, r=unfocused --- toolkit/mozapps/extensions/XPIProvider.jsm | 3 --- 1 file changed, 3 deletions(-) diff --git a/toolkit/mozapps/extensions/XPIProvider.jsm b/toolkit/mozapps/extensions/XPIProvider.jsm index 6eae3161620..91b37e58312 100644 --- a/toolkit/mozapps/extensions/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/XPIProvider.jsm @@ -2144,9 +2144,6 @@ var XPIProvider = { .QueryInterface(Ci.nsIDirectoryEnumerator); let entry; while (entry = entries.nextFile) { - // Should never happen really - if (!(entry instanceof Ci.nsIFile)) - continue; let id = entry.leafName; From 3880f3d0ac0e493ec545e884381c70e7905f852d Mon Sep 17 00:00:00 2001 From: Thaddee Tyl Date: Fri, 17 Aug 2012 18:38:59 +0300 Subject: [PATCH 2/7] Bug 780791 - WebConsole autocompletion doesn't autocomplete on string literals; r=msucan --- .../devtools/webconsole/WebConsoleUtils.jsm | 87 +++++++++++-------- .../test/browser_webconsole_completion.js | 7 ++ 2 files changed, 58 insertions(+), 36 deletions(-) diff --git a/browser/devtools/webconsole/WebConsoleUtils.jsm b/browser/devtools/webconsole/WebConsoleUtils.jsm index fba6bb5ce54..182e0cc015e 100644 --- a/browser/devtools/webconsole/WebConsoleUtils.jsm +++ b/browser/devtools/webconsole/WebConsoleUtils.jsm @@ -909,48 +909,63 @@ function JSPropertyProvider(aScope, aInputValue) return null; } - let properties = completionPart.split("."); - let matchProp; - if (properties.length > 1) { - matchProp = properties.pop().trimLeft(); - for (let i = 0; i < properties.length; i++) { - let prop = properties[i].trim(); - if (!prop) { - return null; - } + let matches = null; + let matchProp = ""; - // If obj is undefined or null (which is what "== null" does), - // then there is no chance to run completion on it. Exit here. - if (obj == null) { - return null; - } + let lastDot = completionPart.lastIndexOf("."); + if (lastDot > 0 && + (completionPart[0] == "'" || completionPart[0] == '"') && + completionPart[lastDot - 1] == completionPart[0]) { + // We are completing a string literal. + obj = obj.String.prototype; + matchProp = completionPart.slice(lastDot + 1); - // Check if prop is a getter function on obj. Functions can change other - // stuff so we can't execute them to get the next object. Stop here. - if (WCU.isNonNativeGetter(obj, prop)) { - return null; - } - try { - obj = obj[prop]; - } - catch (ex) { - return null; - } - } } else { - matchProp = properties[0].trimLeft(); - } + // We are completing a variable / a property lookup. - // If obj is undefined or null (which is what "== null" does), - // then there is no chance to run completion on it. Exit here. - if (obj == null) { - return null; - } + let properties = completionPart.split("."); + if (properties.length > 1) { + matchProp = properties.pop().trimLeft(); + for (let i = 0; i < properties.length; i++) { + let prop = properties[i].trim(); + if (!prop) { + return null; + } - // Skip Iterators and Generators. - if (WCU.isIteratorOrGenerator(obj)) { - return null; + // If obj is undefined or null (which is what "== null" does), + // then there is no chance to run completion on it. Exit here. + if (obj == null) { + return null; + } + + // Check if prop is a getter function on obj. Functions can change other + // stuff so we can't execute them to get the next object. Stop here. + if (WCU.isNonNativeGetter(obj, prop)) { + return null; + } + try { + obj = obj[prop]; + } + catch (ex) { + return null; + } + } + } + else { + matchProp = properties[0].trimLeft(); + } + + // If obj is undefined or null (which is what "== null" does), + // then there is no chance to run completion on it. Exit here. + if (obj == null) { + return null; + } + + // Skip Iterators and Generators. + if (WCU.isIteratorOrGenerator(obj)) { + return null; + } } let matches = Object.keys(getMatchedProps(obj, {matchProp:matchProp})); diff --git a/browser/devtools/webconsole/test/browser_webconsole_completion.js b/browser/devtools/webconsole/test/browser_webconsole_completion.js index e839c91e18b..0dc1981fe0b 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_completion.js +++ b/browser/devtools/webconsole/test/browser_webconsole_completion.js @@ -105,6 +105,13 @@ function testCompletion(hud) { is(jsterm.completeNode.value, " ice", "non-object completion"); + // Test string literal autocompletion. + input.value = "'Asimov'.sl"; + jsterm.complete(jsterm.COMPLETE_HINT_ONLY, testNext); + yield; + + is(jsterm.completeNode.value, " ice", "string literal completion"); + testDriver = jsterm = input = null; executeSoon(finishTest); yield; From 5b6338889c72bab657a16d85617fb36d4c24e83e Mon Sep 17 00:00:00 2001 From: "Bellindira Castillo [:bellindira]" Date: Thu, 16 Aug 2012 23:01:03 -0600 Subject: [PATCH 3/7] Bug 752841 - [New Tab Page] Make the number of tabs adjustable; r=ttaubert --- browser/app/profile/firefox.js | 6 ++ browser/base/content/newtab/grid.js | 69 ++++++++++++++----- browser/base/content/newtab/newTab.js | 3 +- browser/base/content/newtab/newTab.xul | 15 ---- browser/base/content/test/newtab/Makefile.in | 1 + .../test/newtab/browser_newtab_bug752841.js | 53 ++++++++++++++ browser/modules/NewTabUtils.jsm | 63 ++++++++++++++++- 7 files changed, 176 insertions(+), 34 deletions(-) create mode 100644 browser/base/content/test/newtab/browser_newtab_bug752841.js diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index b90890953f3..7b75287af8a 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1128,6 +1128,12 @@ pref("browser.newtab.preload", false); // Toggles the content of 'about:newtab'. Shows the grid when enabled. pref("browser.newtabpage.enabled", true); +// number of rows of newtab grid +pref("browser.newtabpage.rows", 3); + +// number of columns of newtab grid +pref("browser.newtabpage.columns", 3); + // Enable the DOM fullscreen API. pref("full-screen-api.enabled", true); diff --git a/browser/base/content/newtab/grid.js b/browser/base/content/newtab/grid.js index 22b40d7c425..b1c42c051d0 100644 --- a/browser/base/content/newtab/grid.js +++ b/browser/base/content/newtab/grid.js @@ -22,17 +22,8 @@ let gGrid = { /** * All cells contained in the grid. */ - get cells() { - let cells = []; - let children = this.node.querySelectorAll(".newtab-cell"); - for (let i = 0; i < children.length; i++) - cells.push(new Cell(this, children[i])); - - // Replace the getter with our cached value. - Object.defineProperty(this, "cells", {value: cells, enumerable: true}); - - return cells; - }, + _cells: null, + get cells() this._cells, /** * All sites contained in the grid's cells. Sites may be empty. @@ -46,7 +37,7 @@ let gGrid = { init: function Grid_init() { this._node = document.getElementById("newtab-grid"); this._createSiteFragment(); - this._draw(); + this._render(); }, /** @@ -74,8 +65,8 @@ let gGrid = { node.removeChild(child); }, this); - // Draw the grid again. - this._draw(); + // Render the grid again. + this._render(); }, /** @@ -92,6 +83,32 @@ let gGrid = { this.node.removeAttribute("locked"); }, + /** + * Creates the newtab grid. + */ + _renderGrid: function Grid_renderGrid() { + let row = document.createElementNS(HTML_NAMESPACE, "div"); + let cell = document.createElementNS(HTML_NAMESPACE, "div"); + row.classList.add("newtab-row"); + cell.classList.add("newtab-cell"); + + // Clear the grid + this._node.innerHTML = ""; + + // Creates the structure of one row + for (let i = 0; i < gGridPrefs.gridColumns; i++) { + row.appendChild(cell.cloneNode(true)); + } + // Creates the grid + for (let j = 0; j < gGridPrefs.gridRows; j++) { + this._node.appendChild(row.cloneNode(true)); + } + + // (Re-)initialize all cells. + let cellElements = this.node.querySelectorAll(".newtab-cell"); + this._cells = [new Cell(this, cell) for (cell of cellElements)]; + }, + /** * Creates the DOM fragment that is re-used when creating sites. */ @@ -116,11 +133,10 @@ let gGrid = { }, /** - * Draws the grid, creates all sites and puts them into their cells. + * Renders the sites, creates all sites and puts them into their cells. */ - _draw: function Grid_draw() { + _renderSites: function Grid_renderSites() { let cells = this.cells; - // Put sites into the cells. let links = gLinks.getLinks(); let length = Math.min(links.length, cells.length); @@ -129,5 +145,24 @@ let gGrid = { if (links[i]) this.createSite(links[i], cells[i]); } + }, + + /** + * Renders the grid. + */ + _render: function Grid_render() { + if (this._shouldRenderGrid()) { + this._renderGrid(); + } + + this._renderSites(); + }, + + _shouldRenderGrid : function Grid_shouldRenderGrid() { + let rowsLength = this._node.querySelectorAll(".newtab-row").length; + let cellsLength = this._node.querySelectorAll(".newtab-cell").length; + + return (rowsLength != gGridPrefs.gridRows || + cellsLength != (gGridPrefs.gridRows * gGridPrefs.gridColumns)); } }; diff --git a/browser/base/content/newtab/newTab.js b/browser/base/content/newtab/newTab.js index 0b40ec8adcd..fa77342e852 100644 --- a/browser/base/content/newtab/newTab.js +++ b/browser/base/content/newtab/newTab.js @@ -20,7 +20,8 @@ let { allPages: gAllPages, linkChecker: gLinkChecker, pinnedLinks: gPinnedLinks, - blockedLinks: gBlockedLinks + blockedLinks: gBlockedLinks, + gridPrefs: gGridPrefs } = NewTabUtils; XPCOMUtils.defineLazyGetter(this, "gStringBundle", function() { diff --git a/browser/base/content/newtab/newTab.xul b/browser/base/content/newtab/newTab.xul index 58acb3b01c1..be783829c4b 100644 --- a/browser/base/content/newtab/newTab.xul +++ b/browser/base/content/newtab/newTab.xul @@ -26,21 +26,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/browser/base/content/test/newtab/Makefile.in b/browser/base/content/test/newtab/Makefile.in index e395003106d..7649d76c5f9 100644 --- a/browser/base/content/test/newtab/Makefile.in +++ b/browser/base/content/test/newtab/Makefile.in @@ -28,6 +28,7 @@ _BROWSER_FILES = \ browser_newtab_bug725996.js \ browser_newtab_bug734043.js \ browser_newtab_bug735987.js \ + browser_newtab_bug752841.js \ browser_newtab_bug765628.js \ head.js \ $(NULL) diff --git a/browser/base/content/test/newtab/browser_newtab_bug752841.js b/browser/base/content/test/newtab/browser_newtab_bug752841.js new file mode 100644 index 00000000000..91c347b0c8d --- /dev/null +++ b/browser/base/content/test/newtab/browser_newtab_bug752841.js @@ -0,0 +1,53 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const PREF_NEWTAB_ROWS = "browser.newtabpage.rows"; +const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns"; + +function runTests() { + let testValues = [ + {row: 0, column: 0}, + {row: -1, column: -1}, + {row: -1, column: 0}, + {row: 0, column: -1}, + {row: 2, column: 4}, + {row: 2, column: 5}, + ]; + + // Expected length of grid + let expectedValues = [1, 1, 1, 1, 8, 10]; + + // Values before setting new pref values (9 is the default value -> 3 x 3) + let previousValues = [9, 1, 1, 1, 1, 8]; + + let existingTab, existingTabGridLength, newTab, newTabGridLength; + yield addNewTabPageTab(); + existingTab = gBrowser.selectedTab; + + for (let i = 0; i < expectedValues.length; i++) { + gBrowser.selectedTab = existingTab; + existingTabGridLength = getGrid().cells.length; + is(existingTabGridLength, previousValues[i], + "Grid length of existing page before update is correctly."); + + Services.prefs.setIntPref(PREF_NEWTAB_ROWS, testValues[i].row); + Services.prefs.setIntPref(PREF_NEWTAB_COLUMNS, testValues[i].column); + + existingTabGridLength = getGrid().cells.length; + is(existingTabGridLength, expectedValues[i], + "Existing page grid is updated correctly."); + + yield addNewTabPageTab(); + newTab = gBrowser.selectedTab; + newTabGridLength = getGrid().cells.length; + is(newTabGridLength, expectedValues[i], + "New page grid is updated correctly."); + + gBrowser.removeTab(newTab); + } + + gBrowser.removeTab(existingTab); + + Services.prefs.clearUserPref(PREF_NEWTAB_ROWS); + Services.prefs.clearUserPref(PREF_NEWTAB_COLUMNS); +} diff --git a/browser/modules/NewTabUtils.jsm b/browser/modules/NewTabUtils.jsm index 11087a54f90..826099229ed 100644 --- a/browser/modules/NewTabUtils.jsm +++ b/browser/modules/NewTabUtils.jsm @@ -24,6 +24,12 @@ XPCOMUtils.defineLazyGetter(this, "gPrincipal", function () { // The preference that tells whether this feature is enabled. const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled"; +// The preference that tells the number of rows of the newtab grid. +const PREF_NEWTAB_ROWS = "browser.newtabpage.rows"; + +// The preference that tells the number of columns of the newtab grid. +const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns"; + // The maximum number of results we want to retrieve from history. const HISTORY_RESULTS_LIMIT = 100; @@ -183,6 +189,60 @@ let AllPages = { Ci.nsISupportsWeakReference]) }; +/** + * Singleton that keeps Grid preferences + */ +let GridPrefs = { + /** + * Cached value that tells the number of rows of newtab grid. + */ + _gridRows: null, + get gridRows() { + if (!this._gridRows) { + this._gridRows = Math.max(1, Services.prefs.getIntPref(PREF_NEWTAB_ROWS)); + } + + return this._gridRows; + }, + + /** + * Cached value that tells the number of columns of newtab grid. + */ + _gridColumns: null, + get gridColumns() { + if (!this._gridColumns) { + this._gridColumns = Math.max(1, Services.prefs.getIntPref(PREF_NEWTAB_COLUMNS)); + } + + return this._gridColumns; + }, + + + /** + * Initializes object. Adds a preference observer + */ + init: function GridPrefs_init() { + Services.prefs.addObserver(PREF_NEWTAB_ROWS, this, false); + Services.prefs.addObserver(PREF_NEWTAB_COLUMNS, this, false); + }, + + /** + * Implements the nsIObserver interface to get notified when the preference + * value changes. + */ + observe: function GridPrefs_observe(aSubject, aTopic, aData) { + if (aData == PREF_NEWTAB_ROWS) { + this._gridRows = null; + } else { + this._gridColumns = null; + } + + AllPages.update(); + } +}; + +GridPrefs.init(); + /** * Singleton that keeps track of all pinned links and their positions in the * grid. @@ -606,5 +666,6 @@ let NewTabUtils = { allPages: AllPages, linkChecker: LinkChecker, pinnedLinks: PinnedLinks, - blockedLinks: BlockedLinks + blockedLinks: BlockedLinks, + gridPrefs: GridPrefs }; From 84a0ccd6eba68a8165c3fb80aa41f78adf72055e Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Mon, 20 Aug 2012 15:30:29 +1200 Subject: [PATCH 4/7] Bug 758950 - Test fix, test_bug292789.html should load xpinstallConfirm.js with a newer JS version. r=dveditz --- caps/tests/mochitest/test_bug292789.html.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/caps/tests/mochitest/test_bug292789.html.in b/caps/tests/mochitest/test_bug292789.html.in index 800fb881028..b58c70252e0 100644 --- a/caps/tests/mochitest/test_bug292789.html.in +++ b/caps/tests/mochitest/test_bug292789.html.in @@ -13,7 +13,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=292789