summaryrefslogtreecommitdiff
path: root/browser/base/content/test/newtab
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/newtab')
-rw-r--r--browser/base/content/test/newtab/Makefile.in38
-rw-r--r--browser/base/content/test/newtab/browser_newtab_block.js61
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug721442.js23
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug722273.js68
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug723102.js19
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug723121.js30
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug725996.js23
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug734043.js27
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug735987.js26
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug752841.js53
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug765628.js27
-rw-r--r--browser/base/content/test/newtab/browser_newtab_bug876313.js24
-rw-r--r--browser/base/content/test/newtab/browser_newtab_disable.js34
-rw-r--r--browser/base/content/test/newtab/browser_newtab_drag_drop.js74
-rw-r--r--browser/base/content/test/newtab/browser_newtab_drag_drop_ext.js55
-rw-r--r--browser/base/content/test/newtab/browser_newtab_drop_preview.js22
-rw-r--r--browser/base/content/test/newtab/browser_newtab_focus.js57
-rw-r--r--browser/base/content/test/newtab/browser_newtab_perwindow_private_browsing.js68
-rw-r--r--browser/base/content/test/newtab/browser_newtab_reset.js28
-rw-r--r--browser/base/content/test/newtab/browser_newtab_tabsync.js61
-rw-r--r--browser/base/content/test/newtab/browser_newtab_undo.js49
-rw-r--r--browser/base/content/test/newtab/browser_newtab_unpin.js56
-rw-r--r--browser/base/content/test/newtab/head.js390
-rw-r--r--browser/base/content/test/newtab/moz.build6
24 files changed, 0 insertions, 1319 deletions
diff --git a/browser/base/content/test/newtab/Makefile.in b/browser/base/content/test/newtab/Makefile.in
deleted file mode 100644
index 6ac460d14..000000000
--- a/browser/base/content/test/newtab/Makefile.in
+++ /dev/null
@@ -1,38 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this file,
-# You can obtain one at http://mozilla.org/MPL/2.0/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = @relativesrcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_BROWSER_FILES = \
- browser_newtab_block.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_reset.js \
- browser_newtab_tabsync.js \
- browser_newtab_undo.js \
- browser_newtab_unpin.js \
- browser_newtab_bug721442.js \
- browser_newtab_bug722273.js \
- browser_newtab_bug723102.js \
- browser_newtab_bug723121.js \
- browser_newtab_bug725996.js \
- browser_newtab_bug734043.js \
- browser_newtab_bug735987.js \
- browser_newtab_bug752841.js \
- browser_newtab_bug765628.js \
- browser_newtab_bug876313.js \
- browser_newtab_perwindow_private_browsing.js \
- head.js \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
diff --git a/browser/base/content/test/newtab/browser_newtab_block.js b/browser/base/content/test/newtab/browser_newtab_block.js
deleted file mode 100644
index bcb3d7baf..000000000
--- a/browser/base/content/test/newtab/browser_newtab_block.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that blocking/removing sites from the grid works
- * as expected. Pinned tabs should not be moved. Gaps will be re-filled
- * if more sites are available.
- */
-function runTests() {
- // we remove sites and expect the gaps to be filled as long as there still
- // are some sites available
- yield setLinks("0,1,2,3,4,5,6,7,8,9");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- yield blockCell(4);
- checkGrid("0,1,2,3,5,6,7,8,9");
-
- yield blockCell(4);
- checkGrid("0,1,2,3,6,7,8,9,");
-
- yield blockCell(4);
- checkGrid("0,1,2,3,7,8,9,,");
-
- // we removed a pinned site
- yield restore();
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",1");
-
- yield addNewTabPageTab();
- checkGrid("0,1p,2,3,4,5,6,7,8");
-
- yield blockCell(1);
- checkGrid("0,2,3,4,5,6,7,8,");
-
- // we remove the last site on the grid (which is pinned) and expect the gap
- // to be re-filled and the new site to be unpinned
- yield restore();
- yield setLinks("0,1,2,3,4,5,6,7,8,9");
- setPinnedLinks(",,,,,,,,8");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8p");
-
- yield blockCell(8);
- checkGrid("0,1,2,3,4,5,6,7,9");
-
- // we remove the first site on the grid with the last one pinned. all cells
- // but the last one should shift to the left and a new site fades in
- yield restore();
- yield setLinks("0,1,2,3,4,5,6,7,8,9");
- setPinnedLinks(",,,,,,,,8");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8p");
-
- yield blockCell(0);
- checkGrid("1,2,3,4,5,6,7,9,8p");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug721442.js b/browser/base/content/test/newtab/browser_newtab_bug721442.js
deleted file mode 100644
index 597aed251..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug721442.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function runTests() {
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks([
- {url: "http://example.com/#7", title: ""},
- {url: "http://example.com/#8", title: "title"},
- {url: "http://example.com/#9", title: "http://example.com/#9"}
- ]);
-
- yield addNewTabPageTab();
- checkGrid("7p,8p,9p,0,1,2,3,4,5");
-
- checkTooltip(0, "http://example.com/#7", "1st tooltip is correct");
- checkTooltip(1, "title\nhttp://example.com/#8", "2nd tooltip is correct");
- checkTooltip(2, "http://example.com/#9", "3rd tooltip is correct");
-}
-
-function checkTooltip(aIndex, aExpected, aMessage) {
- let link = getCell(aIndex).node.querySelector(".newtab-link");
- is(link.getAttribute("title"), aExpected, aMessage);
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug722273.js b/browser/base/content/test/newtab/browser_newtab_bug722273.js
deleted file mode 100644
index bc561b321..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug722273.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-const NOW = Date.now() * 1000;
-const URL = "http://fake-site.com/";
-
-let tmp = {};
-Cc["@mozilla.org/moz/jssubscript-loader;1"]
- .getService(Ci.mozIJSSubScriptLoader)
- .loadSubScript("chrome://browser/content/sanitize.js", tmp);
-
-let {Sanitizer} = tmp;
-
-function runTests() {
- sanitizeHistory();
- yield addFakeVisits();
- yield addNewTabPageTab();
-
- is(getCell(0).site.url, URL, "first site is our fake site");
-
- whenPagesUpdated();
- yield sanitizeHistory();
-
- ok(!getCell(0).site, "the fake site is gone");
-}
-
-function addFakeVisits() {
- let visits = [];
- for (let i = 59; i > 0; i--) {
- visits.push({
- visitDate: NOW - i * 60 * 1000000,
- transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
- });
- }
- let place = {
- uri: makeURI(URL),
- title: "fake site",
- visits: visits
- };
- PlacesUtils.asyncHistory.updatePlaces(place, {
- handleError: function () ok(false, "couldn't add visit"),
- handleResult: function () {},
- handleCompletion: function () {
- NewTabUtils.links.populateCache(function () {
- NewTabUtils.allPages.update();
- TestRunner.next();
- }, true);
- }
- });
-}
-
-function sanitizeHistory() {
- let s = new Sanitizer();
- s.prefDomain = "privacy.cpd.";
-
- let prefs = gPrefService.getBranch(s.prefDomain);
- prefs.setBoolPref("history", true);
- prefs.setBoolPref("downloads", false);
- prefs.setBoolPref("cache", false);
- prefs.setBoolPref("cookies", false);
- prefs.setBoolPref("formdata", false);
- prefs.setBoolPref("offlineApps", false);
- prefs.setBoolPref("passwords", false);
- prefs.setBoolPref("sessions", false);
- prefs.setBoolPref("siteSettings", false);
-
- s.sanitize();
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug723102.js b/browser/base/content/test/newtab/browser_newtab_bug723102.js
deleted file mode 100644
index aa04b1150..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug723102.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function runTests() {
- // create a new tab page and hide it.
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- let firstTab = gBrowser.selectedTab;
-
- yield addNewTabPageTab();
- gBrowser.removeTab(firstTab);
-
- ok(NewTabUtils.allPages.enabled, "page is enabled");
- NewTabUtils.allPages.enabled = false;
- ok(getGrid().node.hasAttribute("page-disabled"), "page is disabled");
- NewTabUtils.allPages.enabled = true;
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug723121.js b/browser/base/content/test/newtab/browser_newtab_bug723121.js
deleted file mode 100644
index 5ad8e7ca0..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug723121.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function runTests() {
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGridLocked(false, "grid is unlocked");
-
- let cell = getCell(0).node;
- let site = getCell(0).site.node;
- let link = site.querySelector(".newtab-link");
-
- sendDragEvent("dragstart", link);
- checkGridLocked(true, "grid is now locked");
-
- sendDragEvent("dragend", link);
- checkGridLocked(false, "grid isn't locked anymore");
-
- sendDragEvent("dragstart", cell);
- checkGridLocked(false, "grid isn't locked - dragstart was ignored");
-
- sendDragEvent("dragstart", site);
- checkGridLocked(false, "grid isn't locked - dragstart was ignored");
-}
-
-function checkGridLocked(aLocked, aMessage) {
- is(getGrid().node.hasAttribute("locked"), aLocked, aMessage);
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug725996.js b/browser/base/content/test/newtab/browser_newtab_bug725996.js
deleted file mode 100644
index 4d3ef7d5e..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug725996.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function runTests() {
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- let cell = getCell(0).node;
-
- sendDragEvent("drop", cell, "http://example.com/#99\nblank");
- is(NewTabUtils.pinnedLinks.links[0].url, "http://example.com/#99",
- "first cell is pinned and contains the dropped site");
-
- yield whenPagesUpdated();
- checkGrid("99p,0,1,2,3,4,5,6,7");
-
- sendDragEvent("drop", cell, "");
- is(NewTabUtils.pinnedLinks.links[0].url, "http://example.com/#99",
- "first cell is still pinned with the site we dropped before");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug734043.js b/browser/base/content/test/newtab/browser_newtab_bug734043.js
deleted file mode 100644
index dff7a14b4..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug734043.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function runTests() {
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- let receivedError = false;
- let block = getContentDocument().querySelector(".newtab-control-block");
-
- function onError() {
- receivedError = true;
- }
-
- let cw = getContentWindow();
- cw.addEventListener("error", onError);
-
- for (let i = 0; i < 3; i++)
- EventUtils.synthesizeMouseAtCenter(block, {}, cw);
-
- yield whenPagesUpdated();
- ok(!receivedError, "we got here without any errors");
- cw.removeEventListener("error", onError);
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug735987.js b/browser/base/content/test/newtab/browser_newtab_bug735987.js
deleted file mode 100644
index 8dda601b9..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug735987.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-function runTests() {
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- yield simulateDrop(1);
- checkGrid("0,99p,1,2,3,4,5,6,7");
-
- yield blockCell(1);
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- yield simulateDrop(1);
- checkGrid("0,99p,1,2,3,4,5,6,7");
-
- NewTabUtils.blockedLinks.resetCache();
- yield addNewTabPageTab();
- checkGrid("0,99p,1,2,3,4,5,6,7");
-
- yield blockCell(1);
- checkGrid("0,1,2,3,4,5,6,7,8");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug752841.js b/browser/base/content/test/newtab/browser_newtab_bug752841.js
deleted file mode 100644
index 91c347b0c..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug752841.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/* 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/base/content/test/newtab/browser_newtab_bug765628.js b/browser/base/content/test/newtab/browser_newtab_bug765628.js
deleted file mode 100644
index 6b93c8e6d..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug765628.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-const BAD_DRAG_DATA = "javascript:alert('h4ck0rz');\nbad stuff";
-const GOOD_DRAG_DATA = "http://example.com/#99\nsite 99";
-
-function runTests() {
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- sendDropEvent(0, BAD_DRAG_DATA);
- sendDropEvent(1, GOOD_DRAG_DATA);
-
- yield whenPagesUpdated();
- checkGrid("0,99p,1,2,3,4,5,6,7");
-}
-
-function sendDropEvent(aCellIndex, aDragData) {
- let ifaceReq = getContentWindow().QueryInterface(Ci.nsIInterfaceRequestor);
- let windowUtils = ifaceReq.getInterface(Ci.nsIDOMWindowUtils);
-
- let event = createDragEvent("drop", aDragData);
- windowUtils.dispatchDOMEventViaPresShell(getCell(aCellIndex).node, event, true);
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_bug876313.js b/browser/base/content/test/newtab/browser_newtab_bug876313.js
deleted file mode 100644
index ed9e8fbb3..000000000
--- a/browser/base/content/test/newtab/browser_newtab_bug876313.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * This test makes sure that the changes made by unpinning
- * a site are actually written to NewTabUtils' storage.
- */
-function runTests() {
- // Second cell is pinned with page #99.
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",99");
-
- yield addNewTabPageTab();
- checkGrid("0,99p,1,2,3,4,5,6,7");
-
- // Unpin the second cell's site.
- yield unpinCell(1);
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- // Clear the pinned cache to force NewTabUtils to read the pref again.
- NewTabUtils.pinnedLinks.resetCache();
- NewTabUtils.allPages.update();
- checkGrid("0,1,2,3,4,5,6,7,8");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_disable.js b/browser/base/content/test/newtab/browser_newtab_disable.js
deleted file mode 100644
index 57aa59761..000000000
--- a/browser/base/content/test/newtab/browser_newtab_disable.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that the 'New Tab Page' feature can be disabled if the
- * decides not to use it.
- */
-function runTests() {
- // create a new tab page and hide it.
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- let gridNode = getGrid().node;
-
- ok(!gridNode.hasAttribute("page-disabled"), "page is not disabled");
-
- NewTabUtils.allPages.enabled = false;
- ok(gridNode.hasAttribute("page-disabled"), "page is disabled");
-
- let oldGridNode = gridNode;
-
- // create a second new tage page and make sure it's disabled. enable it
- // again and check if the former page gets enabled as well.
- yield addNewTabPageTab();
- ok(gridNode.hasAttribute("page-disabled"), "page is disabled");
-
- // check that no sites have been rendered
- is(0, getContentDocument().querySelectorAll(".site").length, "no sites have been rendered");
-
- NewTabUtils.allPages.enabled = true;
- ok(!gridNode.hasAttribute("page-disabled"), "page is not disabled");
- ok(!oldGridNode.hasAttribute("page-disabled"), "old page is not disabled");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_drag_drop.js b/browser/base/content/test/newtab/browser_newtab_drag_drop.js
deleted file mode 100644
index 1c64ddf72..000000000
--- a/browser/base/content/test/newtab/browser_newtab_drag_drop.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that dragging and dropping sites works as expected.
- * Sites contained in the grid need to shift around to indicate the result
- * of the drag-and-drop operation. If the grid is full and we're dragging
- * a new site into it another one gets pushed out.
- */
-function runTests() {
- requestLongerTimeout(2);
-
- // test a simple drag-and-drop scenario
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- yield simulateDrop(1, 0);
- checkGrid("1,0p,2,3,4,5,6,7,8");
-
- // drag a cell to its current cell and make sure it's not pinned afterwards
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- yield simulateDrop(0, 0);
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- // ensure that pinned pages aren't moved if that's not necessary
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",1,2");
-
- yield addNewTabPageTab();
- checkGrid("0,1p,2p,3,4,5,6,7,8");
-
- yield simulateDrop(3, 0);
- checkGrid("3,1p,2p,0p,4,5,6,7,8");
-
- // pinned sites should always be moved around as blocks. if a pinned site is
- // moved around, neighboring pinned are affected as well
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("0,1");
-
- yield addNewTabPageTab();
- checkGrid("0p,1p,2,3,4,5,6,7,8");
-
- yield simulateDrop(0, 2);
- checkGrid("2p,0p,1p,3,4,5,6,7,8");
-
- // pinned sites should not be pushed out of the grid (unless there are only
- // pinned ones left on the grid)
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",,,,,,,7,8");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7p,8p");
-
- yield simulateDrop(8, 2);
- checkGrid("0,1,3,4,5,6,7p,8p,2p");
-
- // make sure that pinned sites are re-positioned correctly
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("0,1,2,,,5");
-
- yield addNewTabPageTab();
- checkGrid("0p,1p,2p,3,4,5p,6,7,8");
-
- yield simulateDrop(4, 0);
- checkGrid("3,1p,2p,4,0p,5p,6,7,8");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_drag_drop_ext.js b/browser/base/content/test/newtab/browser_newtab_drag_drop_ext.js
deleted file mode 100644
index 527ea2cc7..000000000
--- a/browser/base/content/test/newtab/browser_newtab_drag_drop_ext.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that dragging and dropping sites works as expected.
- * Sites contained in the grid need to shift around to indicate the result
- * of the drag-and-drop operation. If the grid is full and we're dragging
- * a new site into it another one gets pushed out.
- * This is a continuation of browser_newtab_drag_drop.js
- * to decrease test run time, focusing on external sites.
- */
-function runTests() {
- // drag a new site onto the very first cell
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",,,,,,,7,8");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7p,8p");
-
- yield simulateDrop(0);
- checkGrid("99p,0,1,2,3,4,5,7p,8p");
-
- // drag a new site onto the grid and make sure that pinned cells don't get
- // pushed out
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",,,,,,,7,8");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7p,8p");
-
- yield simulateDrop(7);
- checkGrid("0,1,2,3,4,5,7p,99p,8p");
-
- // drag a new site beneath a pinned cell and make sure the pinned cell is
- // not moved
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",,,,,,,,8");
-
- yield addNewTabPageTab();
- checkGrid("0,1,2,3,4,5,6,7,8p");
-
- yield simulateDrop(7);
- checkGrid("0,1,2,3,4,5,6,99p,8p");
-
- // drag a new site onto a block of pinned sites and make sure they're shifted
- // around accordingly
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("0,1,2,,,,,,");
-
- yield addNewTabPageTab();
- checkGrid("0p,1p,2p");
-
- yield simulateDrop(1);
- checkGrid("0p,99p,1p,2p,3,4,5,6,7");
-} \ No newline at end of file
diff --git a/browser/base/content/test/newtab/browser_newtab_drop_preview.js b/browser/base/content/test/newtab/browser_newtab_drop_preview.js
deleted file mode 100644
index 61c163d9d..000000000
--- a/browser/base/content/test/newtab/browser_newtab_drop_preview.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests ensure that the drop preview correctly arranges sites when
- * dragging them around.
- */
-function runTests() {
- // the first three sites are pinned - make sure they're re-arranged correctly
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("0,1,2,,,5");
-
- yield addNewTabPageTab();
- checkGrid("0p,1p,2p,3,4,5p,6,7,8");
-
- let cw = getContentWindow();
- cw.gDrag._draggedSite = getCell(0).site;
- let sites = cw.gDropPreview.rearrange(getCell(4));
- cw.gDrag._draggedSite = null;
-
- checkGrid("3,1p,2p,4,0p,5p,6,7,8", sites);
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_focus.js b/browser/base/content/test/newtab/browser_newtab_focus.js
deleted file mode 100644
index e841d3537..000000000
--- a/browser/base/content/test/newtab/browser_newtab_focus.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that focusing the 'New Tage Page' works as expected.
- */
-function runTests() {
- // Handle the OSX full keyboard access setting
- Services.prefs.setIntPref("accessibility.tabfocus", 7);
-
- // Focus count in new tab page.
- // 28 = 9 * 3 + 1 = 9 sites and 1 toggle button, each site has a link, a pin
- // and a remove button.
- let FOCUS_COUNT = 28;
-
- // Create a new tab page.
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- gURLBar.focus();
-
- // Count the focus with the enabled page.
- yield countFocus(FOCUS_COUNT);
-
- // Disable page and count the focus with the disabled page.
- NewTabUtils.allPages.enabled = false;
- yield countFocus(1);
-
- Services.prefs.clearUserPref("accessibility.tabfocus");
- NewTabUtils.allPages.enabled = true;
-}
-
-/**
- * Focus the urlbar and count how many focus stops to return again to the urlbar.
- */
-function countFocus(aExpectedCount) {
- let focusCount = 0;
- let contentDoc = getContentDocument();
-
- window.addEventListener("focus", function onFocus() {
- let focusedElement = document.commandDispatcher.focusedElement;
- if (focusedElement && focusedElement.classList.contains("urlbar-input")) {
- window.removeEventListener("focus", onFocus, true);
- is(focusCount, aExpectedCount, "Validate focus count in the new tab page.");
- executeSoon(TestRunner.next);
- } else {
- if (focusedElement && focusedElement.ownerDocument == contentDoc &&
- focusedElement instanceof HTMLElement) {
- focusCount++;
- }
- document.commandDispatcher.advanceFocus();
- }
- }, true);
-
- document.commandDispatcher.advanceFocus();
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_perwindow_private_browsing.js b/browser/base/content/test/newtab/browser_newtab_perwindow_private_browsing.js
deleted file mode 100644
index 68717a304..000000000
--- a/browser/base/content/test/newtab/browser_newtab_perwindow_private_browsing.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests ensure that all changes made to the new tab page in private
- * browsing mode are discarded after switching back to normal mode again.
- * The private browsing mode should start with the current grid shown in normal
- * mode.
- */
-
-function runTests() {
- // prepare the grid
- yield testOnWindow(undefined);
- yield setLinks("0,1,2,3,4,5,6,7,8,9");
-
- yield addNewTabPageTab();
- pinCell(0);
- checkGrid("0p,1,2,3,4,5,6,7,8");
-
- // open private window
- yield testOnWindow({private: true});
-
- yield addNewTabPageTab();
- checkGrid("0p,1,2,3,4,5,6,7,8");
-
- // modify the grid while we're in pb mode
- yield blockCell(1);
- checkGrid("0p,2,3,4,5,6,7,8");
-
- yield unpinCell(0);
- checkGrid("0,2,3,4,5,6,7,8");
-
- // open normal window
- yield testOnWindow(undefined);
-
- // check that the grid is the same as before entering pb mode
- yield addNewTabPageTab();
- checkGrid("0,2,3,4,5,6,7,8")
-}
-
-var windowsToClose = [];
-function testOnWindow(options) {
- var win = OpenBrowserWindow(options);
- win.addEventListener("load", function onLoad() {
- win.removeEventListener("load", onLoad, false);
- windowsToClose.push(win);
- gWindow = win;
- whenDelayedStartupFinished(win, TestRunner.next);
- }, false);
-}
-
-function whenDelayedStartupFinished(win, callback) {
- const topic = "browser-delayed-startup-finished";
- Services.obs.addObserver(function onStartup(subject) {
- if (win == subject) {
- Services.obs.removeObserver(onStartup, topic);
- executeSoon(callback);
- }
- }, topic, false);
-}
-
-registerCleanupFunction(function () {
- gWindow = window;
- windowsToClose.forEach(function(win) {
- win.close();
- });
-});
-
diff --git a/browser/base/content/test/newtab/browser_newtab_reset.js b/browser/base/content/test/newtab/browser_newtab_reset.js
deleted file mode 100644
index 3503fbb8d..000000000
--- a/browser/base/content/test/newtab/browser_newtab_reset.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that resetting the 'New Tage Page' works as expected.
- */
-function runTests() {
- // Disabled until bug 716543 is fixed.
- return;
-
- // create a new tab page and check its modified state after blocking a site
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("");
-
- yield addNewTabPageTab();
- let resetButton = getContentDocument().getElementById("toolbar-button-reset");
-
- checkGrid("0,1,2,3,4,5,6,7,8");
- ok(!resetButton.hasAttribute("modified"), "page is not modified");
-
- yield blockCell(4);
- checkGrid("0,1,2,3,5,6,7,8,");
- ok(resetButton.hasAttribute("modified"), "page is modified");
-
- yield getContentWindow().gToolbar.reset(TestRunner.next);
- checkGrid("0,1,2,3,4,5,6,7,8");
- ok(!resetButton.hasAttribute("modified"), "page is not modified");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_tabsync.js b/browser/base/content/test/newtab/browser_newtab_tabsync.js
deleted file mode 100644
index 2ffd11b30..000000000
--- a/browser/base/content/test/newtab/browser_newtab_tabsync.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that all changes that are made to a specific
- * 'New Tab Page' are synchronized with all other open 'New Tab Pages'
- * automatically. All about:newtab pages should always be in the same
- * state.
- */
-function runTests() {
- // Disabled until bug 716543 is fixed.
- return;
-
- yield setLinks("0,1,2,3,4,5,6,7,8,9");
- setPinnedLinks(",1");
-
- yield addNewTabPageTab();
- checkGrid("0,1p,2,3,4,5,6,7,8");
-
- let resetButton = getContentDocument().getElementById("toolbar-button-reset");
- ok(!resetButton.hasAttribute("modified"), "page is not modified");
-
- let oldSites = getGrid().sites;
- let oldResetButton = resetButton;
-
- // create the new tab page
- yield addNewTabPageTab();
- checkGrid("0,1p,2,3,4,5,6,7,8");
-
- resetButton = getContentDocument().getElementById("toolbar-button-reset");
- ok(!resetButton.hasAttribute("modified"), "page is not modified");
-
- // unpin a cell
- yield unpinCell(1);
- checkGrid("0,1,2,3,4,5,6,7,8");
- checkGrid("0,1,2,3,4,5,6,7,8", oldSites);
-
- // remove a cell
- yield blockCell(1);
- checkGrid("0,2,3,4,5,6,7,8,9");
- checkGrid("0,2,3,4,5,6,7,8,9", oldSites);
- ok(resetButton.hasAttribute("modified"), "page is modified");
- ok(oldResetButton.hasAttribute("modified"), "page is modified");
-
- // insert a new cell by dragging
- yield simulateDrop(1);
- checkGrid("0,99p,2,3,4,5,6,7,8");
- checkGrid("0,99p,2,3,4,5,6,7,8", oldSites);
-
- // drag a cell around
- yield simulateDrop(1, 2);
- checkGrid("0,2p,99p,3,4,5,6,7,8");
- checkGrid("0,2p,99p,3,4,5,6,7,8", oldSites);
-
- // reset the new tab page
- yield getContentWindow().gToolbar.reset(TestRunner.next);
- checkGrid("0,1,2,3,4,5,6,7,8");
- checkGrid("0,1,2,3,4,5,6,7,8", oldSites);
- ok(!resetButton.hasAttribute("modified"), "page is not modified");
- ok(!oldResetButton.hasAttribute("modified"), "page is not modified");
-}
diff --git a/browser/base/content/test/newtab/browser_newtab_undo.js b/browser/base/content/test/newtab/browser_newtab_undo.js
deleted file mode 100644
index bc0eb3df2..000000000
--- a/browser/base/content/test/newtab/browser_newtab_undo.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that the undo dialog works as expected.
- */
-function runTests() {
- // remove unpinned sites and undo it
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks("5");
-
- yield addNewTabPageTab();
- checkGrid("5p,0,1,2,3,4,6,7,8");
-
- yield blockCell(4);
- yield blockCell(4);
- checkGrid("5p,0,1,2,6,7,8");
-
- yield undo();
- checkGrid("5p,0,1,2,4,6,7,8");
-
- // now remove a pinned site and undo it
- yield blockCell(0);
- checkGrid("0,1,2,4,6,7,8");
-
- yield undo();
- checkGrid("5p,0,1,2,4,6,7,8");
-
- // remove a site and restore all
- yield blockCell(1);
- checkGrid("5p,1,2,4,6,7,8");
-
- yield undoAll();
- checkGrid("5p,0,1,2,3,4,6,7,8");
-}
-
-function undo() {
- let cw = getContentWindow();
- let target = cw.document.getElementById("newtab-undo-button");
- EventUtils.synthesizeMouseAtCenter(target, {}, cw);
- whenPagesUpdated();
-}
-
-function undoAll() {
- let cw = getContentWindow();
- let target = cw.document.getElementById("newtab-undo-restore-button");
- EventUtils.synthesizeMouseAtCenter(target, {}, cw);
- whenPagesUpdated();
-} \ No newline at end of file
diff --git a/browser/base/content/test/newtab/browser_newtab_unpin.js b/browser/base/content/test/newtab/browser_newtab_unpin.js
deleted file mode 100644
index 6d2d45b1e..000000000
--- a/browser/base/content/test/newtab/browser_newtab_unpin.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * These tests make sure that when a site gets unpinned it is either moved to
- * its actual place in the grid or removed in case it's not on the grid anymore.
- */
-function runTests() {
- // we have a pinned link that didn't change its position since it was pinned.
- // nothing should happend when we unpin it.
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",1");
-
- yield addNewTabPageTab();
- checkGrid("0,1p,2,3,4,5,6,7,8");
-
- yield unpinCell(1);
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- // we have a pinned link that is not anymore in the list of the most-visited
- // links. this should disappear, the remaining links adjust their positions
- // and a new link will appear at the end of the grid.
- yield setLinks("0,1,2,3,4,5,6,7,8");
- setPinnedLinks(",99");
-
- yield addNewTabPageTab();
- checkGrid("0,99p,1,2,3,4,5,6,7");
-
- yield unpinCell(1);
- checkGrid("0,1,2,3,4,5,6,7,8");
-
- // we have a pinned link that changed its position since it was pinned. it
- // should be moved to its new position after being unpinned.
- yield setLinks("0,1,2,3,4,5,6,7");
- setPinnedLinks(",1,,,,,,,0");
-
- yield addNewTabPageTab();
- checkGrid("2,1p,3,4,5,6,7,,0p");
-
- yield unpinCell(1);
- checkGrid("1,2,3,4,5,6,7,,0p");
-
- yield unpinCell(8);
- checkGrid("0,1,2,3,4,5,6,7,");
-
- // we have pinned link that changed its position since it was pinned. the
- // link will disappear from the grid because it's now a much lower priority
- yield setLinks("0,1,2,3,4,5,6,7,8,9");
- setPinnedLinks("9");
-
- yield addNewTabPageTab();
- checkGrid("9p,0,1,2,3,4,5,6,7");
-
- yield unpinCell(0);
- checkGrid("0,1,2,3,4,5,6,7,8");
-}
diff --git a/browser/base/content/test/newtab/head.js b/browser/base/content/test/newtab/head.js
deleted file mode 100644
index b14d20f27..000000000
--- a/browser/base/content/test/newtab/head.js
+++ /dev/null
@@ -1,390 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
-
-Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, true);
-
-let tmp = {};
-Cu.import("resource://gre/modules/NewTabUtils.jsm", tmp);
-Cc["@mozilla.org/moz/jssubscript-loader;1"]
- .getService(Ci.mozIJSSubScriptLoader)
- .loadSubScript("chrome://browser/content/sanitize.js", tmp);
-
-let {NewTabUtils, Sanitizer} = tmp;
-
-let uri = Services.io.newURI("about:newtab", null, null);
-let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
-
-let gWindow = window;
-
-registerCleanupFunction(function () {
- while (gWindow.gBrowser.tabs.length > 1)
- gWindow.gBrowser.removeTab(gWindow.gBrowser.tabs[1]);
-
- Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
-});
-
-/**
- * Provide the default test function to start our test runner.
- */
-function test() {
- TestRunner.run();
-}
-
-/**
- * The test runner that controls the execution flow of our tests.
- */
-let TestRunner = {
- /**
- * Starts the test runner.
- */
- run: function () {
- waitForExplicitFinish();
-
- this._iter = runTests();
- this.next();
- },
-
- /**
- * Runs the next available test or finishes if there's no test left.
- */
- next: function () {
- try {
- TestRunner._iter.next();
- } catch (e if e instanceof StopIteration) {
- TestRunner.finish();
- }
- },
-
- /**
- * Finishes all tests and cleans up.
- */
- finish: function () {
- function cleanupAndFinish() {
- clearHistory(function () {
- whenPagesUpdated(finish);
- NewTabUtils.restore();
- });
- }
-
- let callbacks = NewTabUtils.links._populateCallbacks;
- let numCallbacks = callbacks.length;
-
- if (numCallbacks)
- callbacks.splice(0, numCallbacks, cleanupAndFinish);
- else
- cleanupAndFinish();
- }
-};
-
-/**
- * Returns the selected tab's content window.
- * @return The content window.
- */
-function getContentWindow() {
- return gWindow.gBrowser.selectedBrowser.contentWindow;
-}
-
-/**
- * Returns the selected tab's content document.
- * @return The content document.
- */
-function getContentDocument() {
- return gWindow.gBrowser.selectedBrowser.contentDocument;
-}
-
-/**
- * Returns the newtab grid of the selected tab.
- * @return The newtab grid.
- */
-function getGrid() {
- return getContentWindow().gGrid;
-}
-
-/**
- * Returns the cell at the given index of the selected tab's newtab grid.
- * @param aIndex The cell index.
- * @return The newtab cell.
- */
-function getCell(aIndex) {
- return getGrid().cells[aIndex];
-}
-
-/**
- * Allows to provide a list of links that is used to construct the grid.
- * @param aLinksPattern the pattern (see below)
- *
- * Example: setLinks("1,2,3")
- * Result: [{url: "http://example.com/#1", title: "site#1"},
- * {url: "http://example.com/#2", title: "site#2"}
- * {url: "http://example.com/#3", title: "site#3"}]
- */
-function setLinks(aLinks) {
- let links = aLinks;
-
- if (typeof links == "string") {
- links = aLinks.split(/\s*,\s*/).map(function (id) {
- return {url: "http://example.com/#" + id, title: "site#" + id};
- });
- }
-
- // Call populateCache() once to make sure that all link fetching that is
- // currently in progress has ended. We clear the history, fill it with the
- // given entries and call populateCache() now again to make sure the cache
- // has the desired contents.
- NewTabUtils.links.populateCache(function () {
- clearHistory(function () {
- fillHistory(links, function () {
- NewTabUtils.links.populateCache(function () {
- NewTabUtils.allPages.update();
- TestRunner.next();
- }, true);
- });
- });
- });
-}
-
-function clearHistory(aCallback) {
- Services.obs.addObserver(function observe(aSubject, aTopic, aData) {
- Services.obs.removeObserver(observe, aTopic);
- executeSoon(aCallback);
- }, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
-
- PlacesUtils.history.removeAllPages();
-}
-
-function fillHistory(aLinks, aCallback) {
- let numLinks = aLinks.length;
- let transitionLink = Ci.nsINavHistoryService.TRANSITION_LINK;
-
- for (let link of aLinks.reverse()) {
- let place = {
- uri: makeURI(link.url),
- title: link.title,
- visits: [{visitDate: Date.now() * 1000, transitionType: transitionLink}]
- };
-
- PlacesUtils.asyncHistory.updatePlaces(place, {
- handleError: function () ok(false, "couldn't add visit to history"),
- handleResult: function () {},
- handleCompletion: function () {
- if (--numLinks == 0)
- aCallback();
- }
- });
- }
-}
-
-/**
- * Allows to specify the list of pinned links (that have a fixed position in
- * the grid.
- * @param aLinksPattern the pattern (see below)
- *
- * Example: setPinnedLinks("3,,1")
- * Result: 'http://example.com/#3' is pinned in the first cell. 'http://example.com/#1' is
- * pinned in the third cell.
- */
-function setPinnedLinks(aLinks) {
- let links = aLinks;
-
- if (typeof links == "string") {
- links = aLinks.split(/\s*,\s*/).map(function (id) {
- if (id)
- return {url: "http://example.com/#" + id, title: "site#" + id};
- });
- }
-
- let string = Cc["@mozilla.org/supports-string;1"]
- .createInstance(Ci.nsISupportsString);
- string.data = JSON.stringify(links);
- Services.prefs.setComplexValue("browser.newtabpage.pinned",
- Ci.nsISupportsString, string);
-
- NewTabUtils.pinnedLinks.resetCache();
- NewTabUtils.allPages.update();
-}
-
-/**
- * Restore the grid state.
- */
-function restore() {
- whenPagesUpdated();
- NewTabUtils.restore();
-}
-
-/**
- * Creates a new tab containing 'about:newtab'.
- */
-function addNewTabPageTab() {
- let tab = gWindow.gBrowser.selectedTab = gWindow.gBrowser.addTab("about:newtab");
- let browser = tab.linkedBrowser;
-
- function whenNewTabLoaded() {
- if (NewTabUtils.allPages.enabled) {
- // Continue when the link cache has been populated.
- NewTabUtils.links.populateCache(function () {
- executeSoon(TestRunner.next);
- });
- } else {
- // It's important that we call next() asynchronously.
- // 'yield addNewTabPageTab()' would fail if next() is called
- // synchronously because the iterator is already executing.
- executeSoon(TestRunner.next);
- }
- }
-
- // The new tab page might have been preloaded in the background.
- if (browser.contentDocument.readyState == "complete") {
- whenNewTabLoaded();
- return;
- }
-
- // Wait for the new tab page to be loaded.
- browser.addEventListener("load", function onLoad() {
- browser.removeEventListener("load", onLoad, true);
- whenNewTabLoaded();
- }, true);
-}
-
-/**
- * Compares the current grid arrangement with the given pattern.
- * @param the pattern (see below)
- * @param the array of sites to compare with (optional)
- *
- * Example: checkGrid("3p,2,,1p")
- * Result: We expect the first cell to contain the pinned site 'http://example.com/#3'.
- * The second cell contains 'http://example.com/#2'. The third cell is empty.
- * The fourth cell contains the pinned site 'http://example.com/#4'.
- */
-function checkGrid(aSitesPattern, aSites) {
- let length = aSitesPattern.split(",").length;
- let sites = (aSites || getGrid().sites).slice(0, length);
- let current = sites.map(function (aSite) {
- if (!aSite)
- return "";
-
- let pinned = aSite.isPinned();
- let pinButton = aSite.node.querySelector(".newtab-control-pin");
- let hasPinnedAttr = pinButton.hasAttribute("pinned");
-
- if (pinned != hasPinnedAttr)
- ok(false, "invalid state (site.isPinned() != site[pinned])");
-
- return aSite.url.replace(/^http:\/\/example\.com\/#(\d+)$/, "$1") + (pinned ? "p" : "");
- });
-
- is(current, aSitesPattern, "grid status = " + aSitesPattern);
-}
-
-/**
- * Blocks a site from the grid.
- * @param aIndex The cell index.
- */
-function blockCell(aIndex) {
- whenPagesUpdated();
- getCell(aIndex).site.block();
-}
-
-/**
- * Pins a site on a given position.
- * @param aIndex The cell index.
- * @param aPinIndex The index the defines where the site should be pinned.
- */
-function pinCell(aIndex, aPinIndex) {
- getCell(aIndex).site.pin(aPinIndex);
-}
-
-/**
- * Unpins the given cell's site.
- * @param aIndex The cell index.
- */
-function unpinCell(aIndex) {
- whenPagesUpdated();
- getCell(aIndex).site.unpin();
-}
-
-/**
- * Simulates a drop and drop operation.
- * @param aDropIndex The cell index of the drop target.
- * @param aDragIndex The cell index containing the dragged site (optional).
- */
-function simulateDrop(aDropIndex, aDragIndex) {
- let draggedSite;
- let {gDrag: drag, gDrop: drop} = getContentWindow();
- let event = createDragEvent("drop", "http://example.com/#99\nblank");
-
- if (typeof aDragIndex != "undefined")
- draggedSite = getCell(aDragIndex).site;
-
- if (draggedSite)
- drag.start(draggedSite, event);
-
- whenPagesUpdated();
- drop.drop(getCell(aDropIndex), event);
-
- if (draggedSite)
- drag.end(draggedSite);
-}
-
-/**
- * Sends a custom drag event to a given DOM element.
- * @param aEventType The drag event's type.
- * @param aTarget The DOM element that the event is dispatched to.
- * @param aData The event's drag data (optional).
- */
-function sendDragEvent(aEventType, aTarget, aData) {
- let event = createDragEvent(aEventType, aData);
- let ifaceReq = getContentWindow().QueryInterface(Ci.nsIInterfaceRequestor);
- let windowUtils = ifaceReq.getInterface(Ci.nsIDOMWindowUtils);
- windowUtils.dispatchDOMEventViaPresShell(aTarget, event, true);
-}
-
-/**
- * Creates a custom drag event.
- * @param aEventType The drag event's type.
- * @param aData The event's drag data (optional).
- * @return The drag event.
- */
-function createDragEvent(aEventType, aData) {
- let dataTransfer = {
- mozUserCancelled: false,
- setData: function () null,
- setDragImage: function () null,
- getData: function () aData,
-
- types: {
- contains: function (aType) aType == "text/x-moz-url"
- },
-
- mozGetDataAt: function (aType, aIndex) {
- if (aIndex || aType != "text/x-moz-url")
- return null;
-
- return aData;
- }
- };
-
- let event = getContentDocument().createEvent("DragEvents");
- event.initDragEvent(aEventType, true, true, getContentWindow(), 0, 0, 0, 0, 0,
- false, false, false, false, 0, null, dataTransfer);
-
- return event;
-}
-
-/**
- * Resumes testing when all pages have been updated.
- */
-function whenPagesUpdated(aCallback) {
- let page = {
- update: function () {
- NewTabUtils.allPages.unregister(this);
- executeSoon(aCallback || TestRunner.next);
- }
- };
-
- NewTabUtils.allPages.register(page);
- registerCleanupFunction(function () {
- NewTabUtils.allPages.unregister(page);
- });
-}
diff --git a/browser/base/content/test/newtab/moz.build b/browser/base/content/test/newtab/moz.build
deleted file mode 100644
index 895d11993..000000000
--- a/browser/base/content/test/newtab/moz.build
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-