diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js
index a91b2c93ec..ebc4498564 100644
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -424,9 +424,9 @@ function testAccessibleTree(aAccOrElmOrID, aAccTree, aFlags)
for (var offset in accTree[prop]) {
if (prevOffset !=- 1) {
var attrs = accTree[prop][prevOffset];
- testTextAttrs(acc, prevOffset, attrs, { }, prevOffset, offset, true);
+ testTextAttrs(acc, prevOffset, attrs, { }, prevOffset, +offset, true);
}
- prevOffset = offset;
+ prevOffset = +offset;
}
if (prevOffset != -1) {
diff --git a/accessible/tests/mochitest/events/test_text_alg.html b/accessible/tests/mochitest/events/test_text_alg.html
index ac77650f6d..97428fb3b0 100644
--- a/accessible/tests/mochitest/events/test_text_alg.html
+++ b/accessible/tests/mochitest/events/test_text_alg.html
@@ -20,8 +20,8 @@
////////////////////////////////////////////////////////////////////////////
// Invokers
- const kRemoval = 0;
- const kInsertion = 1;
+ const kRemoval = false;
+ const kInsertion = true;
const kUnexpected = true;
function changeText(aContainerID, aValue, aEventList)
diff --git a/accessible/tests/mochitest/events/test_tree.xul b/accessible/tests/mochitest/events/test_tree.xul
index f342f325d9..797e7bf97d 100644
--- a/accessible/tests/mochitest/events/test_tree.xul
+++ b/accessible/tests/mochitest/events/test_tree.xul
@@ -82,7 +82,7 @@
try {
var endCol = propBag.getPropertyAsInt32("endcolumn");
} catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
- startCol = null;
+ endCol = null;
}
is(endCol, aEndCol,
"Wrong 'endcolumn' of 'treeInvalidated' event on " + aMsg);
diff --git a/accessible/tests/mochitest/states.js b/accessible/tests/mochitest/states.js
index 5816addb2c..73ec126e38 100644
--- a/accessible/tests/mochitest/states.js
+++ b/accessible/tests/mochitest/states.js
@@ -52,7 +52,7 @@ const EXT_STATE_SUPPORTS_AUTOCOMPLETION =
nsIAccessibleStates.EXT_STATE_SUPPORTS_AUTOCOMPLETION;
const EXT_STATE_VERTICAL = nsIAccessibleStates.EXT_STATE_VERTICAL;
-const kOrdinalState = 0;
+const kOrdinalState = false;
const kExtraState = 1;
////////////////////////////////////////////////////////////////////////////////
diff --git a/accessible/tests/mochitest/table/test_sels_listbox.xul b/accessible/tests/mochitest/table/test_sels_listbox.xul
index 5084fb9586..83697e8d0d 100644
--- a/accessible/tests/mochitest/table/test_sels_listbox.xul
+++ b/accessible/tests/mochitest/table/test_sels_listbox.xul
@@ -77,7 +77,7 @@
aId + ": wrong number of selected columns");
if (!aSelIndexesArray) {
- is(selCols.value, null,
+ is(selCols.value, undefined,
aId + ": no columns should be selected");
} else {
for (var i = 0; i < selCols.length; i++) {
@@ -116,7 +116,7 @@
aId + ": wrong number of selected rows");
if (!aSelIndexesArray) {
- is(selCols.value, null,
+ is(selCols.value, undefined,
aId + ": no row should be selected");
} else {
for (var i = 0; i < selCols.length; i++) {
@@ -159,7 +159,7 @@
aId + ": wrong number of selected cells");
if (!aSelIndexesArray) {
- is(selCols.value, null,
+ is(selCols.value, undefined,
aId + ": no cells should be selected");
} else {
for (var i = 0; i < selCols.length; i++) {
diff --git a/browser/base/content/test/newtab/head.js b/browser/base/content/test/newtab/head.js
new file mode 100644
index 0000000000..a959d1c54e
--- /dev/null
+++ b/browser/base/content/test/newtab/head.js
@@ -0,0 +1,767 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
+const PREF_NEWTAB_DIRECTORYSOURCE = "browser.newtabpage.directory.source";
+
+Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, true);
+
+let tmp = {};
+Cu.import("resource://gre/modules/Promise.jsm", tmp);
+Cu.import("resource://gre/modules/NewTabUtils.jsm", tmp);
+Cu.import("resource:///modules/DirectoryLinksProvider.jsm", tmp);
+Cu.import("resource://testing-common/PlacesTestUtils.jsm", tmp);
+Cc["@mozilla.org/moz/jssubscript-loader;1"]
+ .getService(Ci.mozIJSSubScriptLoader)
+ .loadSubScript("chrome://browser/content/sanitize.js", tmp);
+Cu.import("resource://gre/modules/Timer.jsm", tmp);
+let {Promise, NewTabUtils, Sanitizer, clearTimeout, setTimeout, DirectoryLinksProvider, PlacesTestUtils} = tmp;
+
+let uri = Services.io.newURI("about:newtab", null, null);
+let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
+
+let isMac = ("nsILocalFileMac" in Ci);
+let isLinux = ("@mozilla.org/gnome-gconf-service;1" in Cc);
+let isWindows = ("@mozilla.org/windows-registry-key;1" in Cc);
+let gWindow = window;
+
+// Default to dummy/empty directory links
+let gDirectorySource = 'data:application/json,{"test":1}';
+let gOrigDirectorySource;
+
+// The tests assume all 3 rows and all 3 columns of sites are shown, but the
+// window may be too small to actually show everything. Resize it if necessary.
+let requiredSize = {};
+requiredSize.innerHeight =
+ 40 + 32 + // undo container + bottom margin
+ 44 + 32 + // search bar + bottom margin
+ (3 * (180 + 32)) + // 3 rows * (tile height + title and bottom margin)
+ 100; // breathing room
+requiredSize.innerWidth =
+ (3 * (290 + 20)) + // 3 cols * (tile width + side margins)
+ 100; // breathing room
+
+let oldSize = {};
+Object.keys(requiredSize).forEach(prop => {
+ info([prop, gBrowser.contentWindow[prop], requiredSize[prop]]);
+ if (gBrowser.contentWindow[prop] < requiredSize[prop]) {
+ oldSize[prop] = gBrowser.contentWindow[prop];
+ info("Changing browser " + prop + " from " + oldSize[prop] + " to " +
+ requiredSize[prop]);
+ gBrowser.contentWindow[prop] = requiredSize[prop];
+ }
+});
+
+let screenHeight = {};
+let screenWidth = {};
+Cc["@mozilla.org/gfx/screenmanager;1"].
+ getService(Ci.nsIScreenManager).
+ primaryScreen.
+ GetAvailRectDisplayPix({}, {}, screenWidth, screenHeight);
+screenHeight = screenHeight.value;
+screenWidth = screenWidth.value;
+
+if (screenHeight < gBrowser.contentWindow.outerHeight) {
+ info("Warning: Browser outer height is now " +
+ gBrowser.contentWindow.outerHeight + ", which is larger than the " +
+ "available screen height, " + screenHeight +
+ ". That may cause problems.");
+}
+
+if (screenWidth < gBrowser.contentWindow.outerWidth) {
+ info("Warning: Browser outer width is now " +
+ gBrowser.contentWindow.outerWidth + ", which is larger than the " +
+ "available screen width, " + screenWidth +
+ ". That may cause problems.");
+}
+
+registerCleanupFunction(function () {
+ while (gWindow.gBrowser.tabs.length > 1)
+ gWindow.gBrowser.removeTab(gWindow.gBrowser.tabs[1]);
+
+ Object.keys(oldSize).forEach(prop => {
+ if (oldSize[prop]) {
+ gBrowser.contentWindow[prop] = oldSize[prop];
+ }
+ });
+
+ // Stop any update timers to prevent unexpected updates in later tests
+ let timer = NewTabUtils.allPages._scheduleUpdateTimeout;
+ if (timer) {
+ clearTimeout(timer);
+ delete NewTabUtils.allPages._scheduleUpdateTimeout;
+ }
+
+ Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
+ Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gOrigDirectorySource);
+
+ return watchLinksChangeOnce();
+});
+
+/**
+ * Resolves promise when directory links are downloaded and written to disk
+ */
+function watchLinksChangeOnce() {
+ let deferred = Promise.defer();
+ let observer = {
+ onManyLinksChanged: () => {
+ DirectoryLinksProvider.removeObserver(observer);
+ deferred.resolve();
+ }
+ };
+ observer.onDownloadFail = observer.onManyLinksChanged;
+ DirectoryLinksProvider.addObserver(observer);
+ return deferred.promise;
+};
+
+/**
+ * Provide the default test function to start our test runner.
+ */
+function test() {
+ waitForExplicitFinish();
+ // start TestRunner.run() after directory links is downloaded and written to disk
+ watchLinksChangeOnce().then(() => {
+ // Wait for hidden page to update with the desired links
+ whenPagesUpdated(() => TestRunner.run(), true);
+ });
+
+ // Save the original directory source (which is set globally for tests)
+ gOrigDirectorySource = Services.prefs.getCharPref(PREF_NEWTAB_DIRECTORYSOURCE);
+ Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gDirectorySource);
+}
+
+/**
+ * The test runner that controls the execution flow of our tests.
+ */
+let TestRunner = {
+ /**
+ * Starts the test runner.
+ */
+ run: function () {
+ 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() {
+ PlacesTestUtils.clearHistory().then(() => {
+ 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,0,1,2,3")
+ * Result: [{url: "http://example.com/", title: "site#-1"},
+ * {url: "http://example0.com/", title: "site#0"},
+ * {url: "http://example1.com/", title: "site#1"},
+ * {url: "http://example2.com/", title: "site#2"},
+ * {url: "http://example3.com/", title: "site#3"}]
+ */
+function setLinks(aLinks, aCallback = TestRunner.next) {
+ let links = aLinks;
+
+ if (typeof links == "string") {
+ links = aLinks.split(/\s*,\s*/).map(function (id) {
+ return {url: "http://example" + (id != "-1" ? id : "") + ".com/",
+ 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 () {
+ PlacesTestUtils.clearHistory().then(() => {
+ fillHistory(links, function () {
+ NewTabUtils.links.populateCache(function () {
+ NewTabUtils.allPages.update();
+ aCallback();
+ }, true);
+ });
+ });
+ });
+}
+
+function fillHistory(aLinks, aCallback = TestRunner.next) {
+ let numLinks = aLinks.length;
+ if (!numLinks) {
+ if (aCallback)
+ executeSoon(aCallback);
+ return;
+ }
+
+ let transitionLink = Ci.nsINavHistoryService.TRANSITION_LINK;
+
+ // Important: To avoid test failures due to clock jitter on Windows XP, call
+ // Date.now() once here, not each time through the loop.
+ let now = Date.now() * 1000;
+
+ for (let i = 0; i < aLinks.length; i++) {
+ let link = aLinks[i];
+ let place = {
+ uri: makeURI(link.url),
+ title: link.title,
+ // Links are secondarily sorted by visit date descending, so decrease the
+ // visit date as we progress through the array so that links appear in the
+ // grid in the order they're present in the array.
+ visits: [{visitDate: now - i, transitionType: transitionLink}]
+ };
+
+ PlacesUtils.asyncHistory.updatePlaces(place, {
+ handleError: function () ok(false, "couldn't add visit to history"),
+ handleResult: function () {},
+ handleCompletion: function () {
+ if (--numLinks == 0 && aCallback)
+ 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://example3.com/' is pinned in the first cell. 'http://example1.com/' 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" + (id != "-1" ? id : "") + ".com/",
+ title: "site#" + id,
+ type: "history"};
+ });
+ }
+
+ 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();
+}
+
+/**
+ * Wait until a given condition becomes true.
+ */
+function waitForCondition(aConditionFn, aMaxTries=50, aCheckInterval=100) {
+ return new Promise((resolve, reject) => {
+ let tries = 0;
+
+ function tryNow() {
+ tries++;
+
+ if (aConditionFn()) {
+ resolve();
+ } else if (tries < aMaxTries) {
+ tryAgain();
+ } else {
+ reject("Condition timed out: " + aConditionFn.toSource());
+ }
+ }
+
+ function tryAgain() {
+ setTimeout(tryNow, aCheckInterval);
+ }
+
+ tryAgain();
+ });
+}
+
+/**
+ * Creates a new tab containing 'about:newtab'.
+ */
+function addNewTabPageTab() {
+ addNewTabPageTabPromise().then(TestRunner.next);
+}
+
+function addNewTabPageTabPromise() {
+ let deferred = Promise.defer();
+
+ 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 () {
+ deferred.resolve(whenSearchInitDone());
+ });
+ } else {
+ deferred.resolve();
+ }
+ }
+
+ // Wait for the new tab page to be loaded.
+ waitForBrowserLoad(browser, function () {
+ // Wait for the document to become visible in case it was preloaded.
+ waitForCondition(() => !browser.contentDocument.hidden).then(whenNewTabLoaded);
+ });
+
+ return deferred.promise;
+}
+
+function waitForBrowserLoad(browser, callback = TestRunner.next) {
+ if (browser.contentDocument.readyState == "complete") {
+ executeSoon(callback);
+ return;
+ }
+
+ browser.addEventListener("load", function onLoad() {
+ browser.removeEventListener("load", onLoad, true);
+ executeSoon(callback);
+ }, 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://example3.com/'.
+ * The second cell contains 'http://example2.com/'. The third cell is empty.
+ * The fourth cell contains the pinned site 'http://example4.com/'.
+ */
+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 hasPinnedAttr = aSite.node.hasAttribute("pinned");
+
+ if (pinned != hasPinnedAttr)
+ ok(false, "invalid state (site.isPinned() != site[pinned])");
+
+ return aSite.url.replace(/^http:\/\/example(\d+)\.com\/$/, "$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 drag and drop operation.
+ * @param aSourceIndex The cell index containing the dragged site.
+ * @param aDestIndex The cell index of the drop target.
+ */
+function simulateDrop(aSourceIndex, aDestIndex) {
+ let src = getCell(aSourceIndex).site.node;
+ let dest = getCell(aDestIndex).node;
+
+ // Drop 'src' onto 'dest' and continue testing when all newtab
+ // pages have been updated (i.e. the drop operation is completed).
+ startAndCompleteDragOperation(src, dest, whenPagesUpdated);
+}
+
+/**
+ * Simulates a drag and drop operation. Instead of rearranging a site that is
+ * is already contained in the newtab grid, this is used to simulate dragging
+ * an external link onto the grid e.g. the text from the URL bar.
+ * @param aDestIndex The cell index of the drop target.
+ */
+function simulateExternalDrop(aDestIndex) {
+ let dest = getCell(aDestIndex).node;
+
+ // Create an iframe that contains the external link we'll drag.
+ createExternalDropIframe().then(iframe => {
+ let link = iframe.contentDocument.getElementById("link");
+
+ // Drop 'link' onto 'dest'.
+ startAndCompleteDragOperation(link, dest, () => {
+ // Wait until the drop operation is complete
+ // and all newtab pages have been updated.
+ whenPagesUpdated(() => {
+ // Clean up and remove the iframe.
+ iframe.remove();
+ // Continue testing.
+ TestRunner.next();
+ });
+ });
+ });
+}
+
+/**
+ * Starts and complete a drag-and-drop operation.
+ * @param aSource The node that is being dragged.
+ * @param aDest The node we're dragging aSource onto.
+ * @param aCallback The function that is called when we're done.
+ */
+function startAndCompleteDragOperation(aSource, aDest, aCallback) {
+ // The implementation of this function varies by platform because each
+ // platform has particular quirks that we need to deal with
+
+ if (isMac) {
+ // On OS X once the drag starts, Cocoa manages the drag session and
+ // gives us a limited amount of time to complete the drag operation. In
+ // some cases as soon as the first mouse-move event is received (the one
+ // that starts the drag session), Cocoa becomes blind to subsequent mouse
+ // events and completes the drag session all by itself. Therefore it is
+ // important that the first mouse-move we send is already positioned at
+ // the destination.
+ synthesizeNativeMouseLDown(aSource);
+ synthesizeNativeMouseDrag(aDest);
+ // In some tests, aSource and aDest are at the same position, so to ensure
+ // a drag session is created (instead of it just turning into a click) we
+ // move the mouse 10 pixels away and then back.
+ synthesizeNativeMouseDrag(aDest, 10);
+ synthesizeNativeMouseDrag(aDest);
+ // Finally, release the drag and have it run the callback when done.
+ synthesizeNativeMouseLUp(aDest).then(aCallback, Cu.reportError);
+ } else if (isWindows) {
+ // on Windows once the drag is initiated, Windows doesn't spin our
+ // message loop at all, so with async event synthesization the async
+ // messages never get processed while a drag is in progress. So if
+ // we did a mousedown followed by a mousemove, we would never be able
+ // to successfully dispatch the mouseup. Instead, we just skip the move
+ // entirely, so and just generate the up at the destination. This way
+ // Windows does the drag and also terminates it right away. Note that
+ // this only works for tests where aSource and aDest are sufficiently
+ // far to trigger a drag, otherwise it may just end up doing a click.
+ synthesizeNativeMouseLDown(aSource);
+ synthesizeNativeMouseLUp(aDest).then(aCallback, Cu.reportError);
+ } else if (isLinux) {
+ // Start by pressing the left mouse button.
+ synthesizeNativeMouseLDown(aSource);
+
+ // Move the mouse in 5px steps until the drag operation starts.
+ // Note that we need to do this with pauses in between otherwise the
+ // synthesized events get coalesced somewhere in the guts of GTK. In order
+ // to successfully initiate a drag session in the case where aSource and
+ // aDest are at the same position, we synthesize a bunch of drags until
+ // we know the drag session has started, and then move to the destination.
+ let offset = 0;
+ let interval = setInterval(() => {
+ synthesizeNativeMouseDrag(aSource, offset += 5);
+ }, 10);
+
+ // When the drag operation has started we'll move
+ // the dragged element to its target position.
+ aSource.addEventListener("dragstart", function onDragStart() {
+ aSource.removeEventListener("dragstart", onDragStart);
+ clearInterval(interval);
+
+ // Place the cursor above the drag target.
+ synthesizeNativeMouseMove(aDest);
+ });
+
+ // As soon as the dragged element hovers the target, we'll drop it.
+ // Note that we need to actually wait for the dragenter event here, because
+ // the mousemove synthesization is "more async" than the mouseup
+ // synthesization - they use different gdk APIs. If we don't wait, the
+ // up could get processed before the moves, dropping the item in the
+ // wrong position.
+ aDest.addEventListener("dragenter", function onDragEnter() {
+ aDest.removeEventListener("dragenter", onDragEnter);
+
+ // Finish the drop operation.
+ synthesizeNativeMouseLUp(aDest).then(aCallback, Cu.reportError);
+ });
+ } else {
+ throw "Unsupported platform";
+ }
+}
+
+/**
+ * Helper function that creates a temporary iframe in the about:newtab
+ * document. This will contain a link we can drag to the test the dropping
+ * of links from external documents.
+ */
+function createExternalDropIframe() {
+ const url = "data:text/html;charset=utf-8," +
+ "link";
+
+ let deferred = Promise.defer();
+ let doc = getContentDocument();
+ let iframe = doc.createElement("iframe");
+ iframe.setAttribute("src", url);
+ iframe.style.width = "50px";
+ iframe.style.height = "50px";
+ iframe.style.position = "absolute";
+ iframe.style.zIndex = 50;
+
+ let margin = doc.getElementById("newtab-margin-top");
+ margin.appendChild(iframe);
+
+ iframe.addEventListener("load", function onLoad() {
+ iframe.removeEventListener("load", onLoad);
+ executeSoon(() => deferred.resolve(iframe));
+ });
+
+ return deferred.promise;
+}
+
+/**
+ * Fires a synthetic 'mousedown' event on the current about:newtab page.
+ * @param aElement The element used to determine the cursor position.
+ */
+function synthesizeNativeMouseLDown(aElement) {
+ if (isLinux) {
+ let win = aElement.ownerDocument.defaultView;
+ EventUtils.synthesizeMouseAtCenter(aElement, {type: "mousedown"}, win);
+ } else {
+ let msg = isWindows ? 2 : 1;
+ synthesizeNativeMouseEvent(aElement, msg);
+ }
+}
+
+/**
+ * Fires a synthetic 'mouseup' event on the current about:newtab page.
+ * @param aElement The element used to determine the cursor position.
+ */
+function synthesizeNativeMouseLUp(aElement) {
+ let msg = isWindows ? 4 : (isMac ? 2 : 7);
+ return synthesizeNativeMouseEvent(aElement, msg);
+}
+
+/**
+ * Fires a synthetic mouse drag event on the current about:newtab page.
+ * @param aElement The element used to determine the cursor position.
+ * @param aOffsetX The left offset that is added to the position.
+ */
+function synthesizeNativeMouseDrag(aElement, aOffsetX) {
+ let msg = isMac ? 6 : 1;
+ synthesizeNativeMouseEvent(aElement, msg, aOffsetX);
+}
+
+/**
+ * Fires a synthetic 'mousemove' event on the current about:newtab page.
+ * @param aElement The element used to determine the cursor position.
+ */
+function synthesizeNativeMouseMove(aElement) {
+ let msg = isMac ? 5 : 1;
+ synthesizeNativeMouseEvent(aElement, msg);
+}
+
+/**
+ * Fires a synthetic mouse event on the current about:newtab page.
+ * @param aElement The element used to determine the cursor position.
+ * @param aOffsetX The left offset that is added to the position (optional).
+ * @param aOffsetY The top offset that is added to the position (optional).
+ */
+function synthesizeNativeMouseEvent(aElement, aMsg, aOffsetX = 0, aOffsetY = 0) {
+ return new Promise((resolve, reject) => {
+ let rect = aElement.getBoundingClientRect();
+ let win = aElement.ownerDocument.defaultView;
+ let x = aOffsetX + win.mozInnerScreenX + rect.left + rect.width / 2;
+ let y = aOffsetY + win.mozInnerScreenY + rect.top + rect.height / 2;
+
+ let utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+
+ let scale = utils.screenPixelsPerCSSPixel;
+ let observer = {
+ observe: function(aSubject, aTopic, aData) {
+ if (aTopic == "mouseevent") {
+ resolve();
+ }
+ }
+ };
+ utils.sendNativeMouseEvent(x * scale, y * scale, aMsg, 0, null, observer);
+ });
+}
+
+/**
+ * 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 = new (getContentWindow()).DataTransfer("dragstart", false);
+ dataTransfer.mozSetDataAt("text/x-moz-url", aData, 0);
+ 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.
+ * @param aCallback Called when done. If not specified, TestRunner.next is used.
+ */
+function whenPagesUpdated(aCallback = TestRunner.next) {
+ let page = {
+ observe: _ => _,
+
+ update() {
+ NewTabUtils.allPages.unregister(this);
+ executeSoon(aCallback);
+ }
+ };
+
+ NewTabUtils.allPages.register(page);
+ registerCleanupFunction(function () {
+ NewTabUtils.allPages.unregister(page);
+ });
+}
+
+/**
+ * Waits for the response to the page's initial search state request.
+ */
+function whenSearchInitDone() {
+ let deferred = Promise.defer();
+ if (getContentWindow().gSearch._initialStateReceived) {
+ return Promise.resolve();
+ }
+ let eventName = "ContentSearchService";
+ getContentWindow().addEventListener(eventName, function onEvent(event) {
+ if (event.detail.type == "State") {
+ getContentWindow().removeEventListener(eventName, onEvent);
+ deferred.resolve();
+ }
+ });
+ return deferred.promise;
+}
+
+/**
+ * Changes the newtab customization option and waits for the panel to open and close
+ *
+ * @param {string} aTheme
+ * Can be any of("blank"|"classic"|"enhanced")
+ */
+function customizeNewTabPage(aTheme) {
+ let document = getContentDocument();
+ let panel = document.getElementById("newtab-customize-panel");
+ let customizeButton = document.getElementById("newtab-customize-button");
+
+ // Attache onShown the listener on panel
+ panel.addEventListener("popupshown", function onShown() {
+ panel.removeEventListener("popupshown", onShown);
+
+ // Get the element for the specific option and click on it,
+ // then trigger an escape to close the panel
+ document.getElementById("newtab-customize-" + aTheme).click();
+ executeSoon(() => { panel.hidePopup(); });
+ });
+
+ // Attache the listener for panel closing, this will resolve the promise
+ panel.addEventListener("popuphidden", function onHidden() {
+ panel.removeEventListener("popuphidden", onHidden);
+ executeSoon(TestRunner.next);
+ });
+
+ // Click on the customize button to display the panel
+ customizeButton.click();
+}
diff --git a/caps/tests/mochitest/test_disableScript.xul b/caps/tests/mochitest/test_disableScript.xul
index fe9dc11047..cef5f401a2 100644
--- a/caps/tests/mochitest/test_disableScript.xul
+++ b/caps/tests/mochitest/test_disableScript.xul
@@ -77,7 +77,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=840488
// We need to append 'name' to avoid running afoul of recursive frame detection.
let frameURI = uri + "?name=" + name;
navigateFrame(ifr, frameURI).then(function() {
- is(ifr.contentWindow.location, frameURI, "Successful load");
+ is(String(ifr.contentWindow.location), frameURI, "Successful load");
is(!!ifr.contentWindow.wrappedJSObject.gFiredOnload, expectOnload,
"onload should only fire when scripts are enabled");
deferred.resolve();
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index cec73f91eb..a26a30452a 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -151,7 +151,7 @@
#include "nsIJARChannel.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "nsISelectionDisplay.h"
@@ -3125,7 +3125,7 @@ nsDocShell::AddProfileTimelineMarker(const char* aName,
}
void
-nsDocShell::AddProfileTimelineMarker(UniquePtr& aMarker)
+nsDocShell::AddProfileTimelineMarker(UniquePtr&& aMarker)
{
if (mProfileTimelineRecording) {
mProfileTimelineMarkers.AppendElement(aMarker.release());
diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h
index aed769919e..18a084e9f7 100644
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -276,7 +276,7 @@ public:
// See nsIDocShell::recordProfileTimelineMarkers
void AddProfileTimelineMarker(const char* aName,
TracingMetadata aMetaData);
- void AddProfileTimelineMarker(mozilla::UniquePtr& aMarker);
+ void AddProfileTimelineMarker(mozilla::UniquePtr&& aMarker);
// Global counter for how many docShells are currently recording profile
// timeline markers
diff --git a/docshell/test/navigation/test_bug430723.html b/docshell/test/navigation/test_bug430723.html
index 55dd9f13c6..eb53e0d220 100644
--- a/docshell/test/navigation/test_bug430723.html
+++ b/docshell/test/navigation/test_bug430723.html
@@ -59,7 +59,7 @@ var nextTest =function() {
}
var step1 =function() {
- window.is(testWindow.location, gTallRedBoxURI, "Ensure red page loaded.");
+ window.is(String(testWindow.location), gTallRedBoxURI, "Ensure red page loaded.");
// Navigate down and up.
is(testWindow.document.body.scrollTop, 0,
@@ -87,7 +87,7 @@ var step1 =function() {
var step2 =function() {
- window.is(testWindow.location, gTallBlueBoxURI, "Ensure blue page loaded.");
+ window.is(String(testWindow.location), gTallBlueBoxURI, "Ensure blue page loaded.");
// Scroll around a bit.
is(testWindow.document.body.scrollTop, 0,
@@ -111,7 +111,7 @@ var step2 =function() {
}
var step3 =function() {
- window.is(testWindow.location, gTallRedBoxURI,
+ window.is(String(testWindow.location), gTallRedBoxURI,
"Ensure red page restored from history.");
// Check we can still scroll with the keys.
diff --git a/dom/apps/tests/test_import_export.html b/dom/apps/tests/test_import_export.html
index 524eda9462..f7b08fd02b 100644
--- a/dom/apps/tests/test_import_export.html
+++ b/dom/apps/tests/test_import_export.html
@@ -229,7 +229,7 @@ function runTest() {
size: 0,
readyToApplyDownload: false
};
- PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, 2, expected,
+ PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, "2", expected,
true, false, continueTest);
};
};
diff --git a/dom/apps/tests/test_packaged_app_install.html b/dom/apps/tests/test_packaged_app_install.html
index 6f3d791821..4cbff025b9 100644
--- a/dom/apps/tests/test_packaged_app_install.html
+++ b/dom/apps/tests/test_packaged_app_install.html
@@ -58,24 +58,6 @@ function checkUninstallApp(aApp) {
};
}
-function checkInstalledApp(aMiniManifestURL,
- aVersion,
- aExpectedApp,
- aLaunchable,
- aCb) {
- var req = navigator.mozApps.checkInstalled(aMiniManifestURL);
- req.onsuccess = function(evt) {
- ok(req.result, "The app is installed");
-
- if (!req.result) {
- PackagedTestHelper.finish();
- }
-
- PackagedTestHelper.checkAppState(evt.application, aVersion, aExpectedApp,
- aLaunchable, false, aCb);
- };
-}
-
var gIconData =
"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52" +
"\x00\x00\x00\x0F\x00\x00\x00\x0F\x08\x03\x00\x00\x00\x0C\x08\x65" +
@@ -240,7 +222,7 @@ var steps = [
size: 0,
readyToApplyDownload: false
};
- PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, 2, expected,
+ PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, "2", expected,
true, false, PackagedTestHelper.next);
};
};
@@ -327,7 +309,7 @@ var steps = [
size: 0,
readyToApplyDownload: alreadyCanceled
};
- PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, 3, expected,
+ PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, "3", expected,
true, false, function() {});
};
@@ -345,7 +327,7 @@ var steps = [
size: 0,
readyToApplyDownload: false
};
- PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, 3, expected,
+ PackagedTestHelper.checkAppState(PackagedTestHelper.gApp, "3", expected,
true, false, PackagedTestHelper.next);
}
diff --git a/dom/apps/tests/test_packaged_app_update.html b/dom/apps/tests/test_packaged_app_update.html
index 858c7f8d6b..8dc18c56c3 100644
--- a/dom/apps/tests/test_packaged_app_update.html
+++ b/dom/apps/tests/test_packaged_app_update.html
@@ -172,7 +172,7 @@ var steps = [
};
PackagedTestHelper.gApp.ondownloadsuccess =
checkLastAppState.bind(undefined, miniManifestURL, false, false,
- 2, PackagedTestHelper.next);
+ "2", PackagedTestHelper.next);
};
var request = navigator.mozApps.installPackage(miniManifestURL);
@@ -231,7 +231,7 @@ var steps = [
},
function() {
info("== TEST == Update packaged app");
- updateApp(true, 2, 3);
+ updateApp(true, "2", "3");
},
function() {
info("== TEST == Check that saved permissions were kept");
diff --git a/dom/base/Console.cpp b/dom/base/Console.cpp
index 89502d9301..c0f3630ca5 100644
--- a/dom/base/Console.cpp
+++ b/dom/base/Console.cpp
@@ -1057,7 +1057,7 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
MakeUnique(docShell,
aMethodName == MethodTime ? TRACING_INTERVAL_START : TRACING_INTERVAL_END,
key);
- docShell->AddProfileTimelineMarker(marker);
+ docShell->AddProfileTimelineMarker(Move(marker));
}
}
}
diff --git a/dom/base/ThirdPartyUtil.cpp b/dom/base/ThirdPartyUtil.cpp
index f52834f005..034f791114 100644
--- a/dom/base/ThirdPartyUtil.cpp
+++ b/dom/base/ThirdPartyUtil.cpp
@@ -15,7 +15,7 @@
#include "nsIScriptObjectPrincipal.h"
#include "nsIURI.h"
#include "nsThreadUtils.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil)
diff --git a/dom/base/nsContentPolicy.cpp b/dom/base/nsContentPolicy.cpp
index eeaa154602..6b61b14d15 100644
--- a/dom/base/nsContentPolicy.cpp
+++ b/dom/base/nsContentPolicy.cpp
@@ -8,7 +8,7 @@
* Implementation of the "@mozilla.org/layout/content-policy;1" contract.
*/
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "nsISupports.h"
#include "nsXPCOM.h"
diff --git a/dom/base/nsContentSink.h b/dom/base/nsContentSink.h
index d56b174288..327990e0eb 100644
--- a/dom/base/nsContentSink.h
+++ b/dom/base/nsContentSink.h
@@ -23,7 +23,7 @@
#include "nsITimer.h"
#include "nsStubDocumentObserver.h"
#include "nsIContentSink.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "nsCycleCollectionParticipant.h"
#include "nsThreadUtils.h"
diff --git a/dom/base/nsDOMDataChannel.cpp b/dom/base/nsDOMDataChannel.cpp
index 4159b579db..c3fb62f58c 100644
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -7,7 +7,7 @@
#include "nsDOMDataChannel.h"
#include "base/basictypes.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
extern PRLogModuleInfo* GetDataChannelLog();
#undef LOG
diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp
index 239c4c1707..78b5d2273c 100644
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1301,7 +1301,8 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout,
int32_t aNativeKeyCode,
int32_t aModifiers,
const nsAString& aCharacters,
- const nsAString& aUnmodifiedCharacters)
+ const nsAString& aUnmodifiedCharacters,
+ nsIObserver* aObserver)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
@@ -1310,8 +1311,11 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout,
if (!widget)
return NS_ERROR_FAILURE;
- return widget->SynthesizeNativeKeyEvent(aNativeKeyboardLayout, aNativeKeyCode,
- aModifiers, aCharacters, aUnmodifiedCharacters);
+ NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
+
+ (widget, &nsIWidget::SynthesizeNativeKeyEvent, aNativeKeyboardLayout,
+ aNativeKeyCode, aModifiers, aCharacters, aUnmodifiedCharacters, aObserver));
+ return NS_OK;
}
NS_IMETHODIMP
@@ -1319,7 +1323,8 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
int32_t aScreenY,
int32_t aNativeMessage,
int32_t aModifierFlags,
- nsIDOMElement* aElement)
+ nsIDOMElement* aElement,
+ nsIObserver* aObserver)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
@@ -1328,8 +1333,12 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
if (!widget)
return NS_ERROR_FAILURE;
- return widget->SynthesizeNativeMouseEvent(LayoutDeviceIntPoint(aScreenX, aScreenY),
- aNativeMessage, aModifierFlags);
+ NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
+
+ (widget, &nsIWidget::SynthesizeNativeMouseEvent,
+ LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags,
+ aObserver));
+ return NS_OK;
}
NS_IMETHODIMP
@@ -1341,7 +1350,8 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX,
double aDeltaZ,
uint32_t aModifierFlags,
uint32_t aAdditionalFlags,
- nsIDOMElement* aElement)
+ nsIDOMElement* aElement,
+ nsIObserver* aObserver)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
@@ -1351,12 +1361,12 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX,
return NS_ERROR_FAILURE;
}
- return widget->SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint(aScreenX,
- aScreenY),
- aNativeMessage,
- aDeltaX, aDeltaY, aDeltaZ,
- aModifierFlags,
- aAdditionalFlags);
+ NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
+
+ (widget, &nsIWidget::SynthesizeNativeMouseScrollEvent,
+ LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aDeltaX, aDeltaY,
+ aDeltaZ, aModifierFlags, aAdditionalFlags, aObserver));
+ return NS_OK;
}
NS_IMETHODIMP
@@ -1365,7 +1375,8 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
int32_t aScreenX,
int32_t aScreenY,
double aPressure,
- uint32_t aOrientation)
+ uint32_t aOrientation,
+ nsIObserver* aObserver)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
@@ -1378,16 +1389,19 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
return NS_ERROR_INVALID_ARG;
}
- return widget->SynthesizeNativeTouchPoint(aPointerId,
- (nsIWidget::TouchPointerState)aTouchState,
- nsIntPoint(aScreenX, aScreenY),
- aPressure, aOrientation);
+ NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
+
+ (widget, &nsIWidget::SynthesizeNativeTouchPoint, aPointerId,
+ (nsIWidget::TouchPointerState)aTouchState, nsIntPoint(aScreenX, aScreenY),
+ aPressure, aOrientation, aObserver));
+ return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX,
int32_t aScreenY,
- bool aLongTap)
+ bool aLongTap,
+ nsIObserver* aObserver)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
@@ -1395,11 +1409,16 @@ nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX,
if (!widget) {
return NS_ERROR_FAILURE;
}
- return widget->SynthesizeNativeTouchTap(nsIntPoint(aScreenX, aScreenY), aLongTap);
+
+ NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
+
+ (widget, &nsIWidget::SynthesizeNativeTouchTap,
+ nsIntPoint(aScreenX, aScreenY), aLongTap, aObserver));
+ return NS_OK;
}
NS_IMETHODIMP
-nsDOMWindowUtils::ClearNativeTouchSequence()
+nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
@@ -1407,7 +1426,10 @@ nsDOMWindowUtils::ClearNativeTouchSequence()
if (!widget) {
return NS_ERROR_FAILURE;
}
- return widget->ClearNativeTouchSequence();
+
+ NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
+ (widget, &nsIWidget::ClearNativeTouchSequence, aObserver));
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index f2cddaf15d..105ea094f6 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -18,7 +18,7 @@
#include "mozilla/Likely.h"
#include
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "plstr.h"
#include "prprf.h"
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index 8d97fe5e4e..295c847a6d 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -176,7 +176,7 @@
#include "nsFrameLoader.h"
#include "nsISupportsPrimitives.h"
#include "nsXPCOMCID.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "prenv.h"
#include "prprf.h"
diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
index a0b110b614..237f41eb0b 100644
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -77,7 +77,7 @@
#endif
#include "AccessCheck.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "prthread.h"
#include "mozilla/Preferences.h"
diff --git a/dom/base/nsNodeInfoManager.cpp b/dom/base/nsNodeInfoManager.cpp
index 324e9a22f4..0c6d7d48e6 100644
--- a/dom/base/nsNodeInfoManager.cpp
+++ b/dom/base/nsNodeInfoManager.cpp
@@ -33,7 +33,7 @@
using namespace mozilla;
using mozilla::dom::NodeInfo;
-#include "prlog.h"
+#include "mozilla/Logging.h"
static PRLogModuleInfo* gNodeInfoManagerLeakPRLog;
diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp
index b870bb9bee..0a0fe4b1e6 100644
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -44,7 +44,7 @@
// Util headers
#include "prenv.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "nsAutoPtr.h"
#include "nsCURILoader.h"
diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp
index fb7a94419e..0fdb6d4c47 100644
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -40,7 +40,7 @@
#include "nsThreadUtils.h"
#include "nsDocShellCID.h"
#include "nsIContentSecurityPolicy.h"
-#include "prlog.h"
+#include "mozilla/Logging.h"
#include "nsCRT.h"
#include "nsContentCreatorFunctions.h"
#include "nsCORSListenerProxy.h"
diff --git a/dom/base/test/csp/test_csp_report.html b/dom/base/test/csp/test_csp_report.html
index bb3acaee5f..72805d4c75 100644
--- a/dom/base/test/csp/test_csp_report.html
+++ b/dom/base/test/csp/test_csp_report.html
@@ -60,7 +60,7 @@ window.checkResults = function(reportObj) {
is(cspReport["script-sample"], "\n var foo = \"propEscFoo\";\n var bar...",
"Incorrect script-sample");
- is(cspReport["line-number"], "7", "Incorrect line-number");
+ is(cspReport["line-number"], 7, "Incorrect line-number");
}
// This is used to watch requests go out so we can see if the report is
diff --git a/dom/base/test/file_bug426646-1.html b/dom/base/test/file_bug426646-1.html
index dbb589d008..db07734412 100644
--- a/dom/base/test/file_bug426646-1.html
+++ b/dom/base/test/file_bug426646-1.html
@@ -25,8 +25,8 @@ function doe3() {
}
function doe4() {
- opener.is(window.frames[0].location, url1, "History.go(-1) didn't work?");
- opener.is(window.frames[1].location, "about:blank",
+ opener.is(String(window.frames[0].location), url1, "History.go(-1) didn't work?");
+ opener.is(String(window.frames[1].location), "about:blank",
"History.go(-1) didn't work?");
close();
}
diff --git a/dom/base/test/file_bug426646-2.html b/dom/base/test/file_bug426646-2.html
index e149a2280a..1f8fae950c 100644
--- a/dom/base/test/file_bug426646-2.html
+++ b/dom/base/test/file_bug426646-2.html
@@ -55,7 +55,7 @@ function doe4() {
}
function doe5() {
- opener.is(win0.location, url1, "History.go(-1) didn't work?");
+ opener.is(String(win0.location), url1, "History.go(-1) didn't work?");
close();
}
diff --git a/dom/base/test/fileutils.js b/dom/base/test/fileutils.js
index cf2476528d..ecfc801b86 100644
--- a/dom/base/test/fileutils.js
+++ b/dom/base/test/fileutils.js
@@ -55,7 +55,7 @@ function testFile(file, contents, test) {
file.type ? file.type : null,
"request content-type in XMLHttpRequest send of " + test);
is(event.target.getResponseHeader("Result-Content-Length"),
- file.size,
+ String(file.size),
"request content-length in XMLHttpRequest send of " + test);
};
xhr.addEventListener("load",
diff --git a/dom/base/test/test_CrossSiteXHR.html b/dom/base/test/test_CrossSiteXHR.html
index c9e6386189..d80d078f98 100644
--- a/dom/base/test/test_CrossSiteXHR.html
+++ b/dom/base/test/test_CrossSiteXHR.html
@@ -694,7 +694,7 @@ function runTest() {
is(res.responseHeaders[header], null,
"|xhr.getResponseHeader()|wrong response header (" + header + ") in test for " +
test.toSource());
- is(res.allResponseHeaders[header], null,
+ is(res.allResponseHeaders[header], undefined,
"|xhr.getAllResponseHeaderss()|wrong response header (" + header + ") in test for " +
test.toSource());
}
diff --git a/dom/base/test/test_XHRSendData.html b/dom/base/test/test_XHRSendData.html
index b65dfb5a4e..fce8d56982 100644
--- a/dom/base/test/test_XHRSendData.html
+++ b/dom/base/test/test_XHRSendData.html
@@ -232,7 +232,9 @@ try {
}
if (test.resContentLength) {
- is(xhr.getResponseHeader("Result-Content-Length"), test.resContentLength, "Wrong Content-Length sent");
+ is(xhr.getResponseHeader("Result-Content-Length"),
+ String(test.resContentLength),
+ "Wrong Content-Length sent");
}
if (test.resType == "arraybuffer") {
diff --git a/dom/base/test/test_audioWindowUtils.html b/dom/base/test/test_audioWindowUtils.html
index 4018ce6aef..45fc358755 100644
--- a/dom/base/test/test_audioWindowUtils.html
+++ b/dom/base/test/test_audioWindowUtils.html
@@ -23,10 +23,10 @@ function runTest() {
is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
utils.audioVolume = 0.4;
- is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
utils.audioMuted = true;
is(utils.audioMuted, true, "utils.audioMuted is true");
- is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
utils.audioMuted = false;
utils.audioVolume = 2.0;
@@ -60,10 +60,10 @@ function runTest() {
is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
utils.audioVolume = 0.4;
- is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
utils.audioMuted = true;
is(utils.audioMuted, true, "utils.audioMuted is true");
- is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
+ is(utils.audioVolume.toFixed(2), "0.40", "utils.audioVolume is ok");
utils.audioMuted = false;
utils.audioVolume = 2.0;
diff --git a/dom/base/test/test_bug346485.html b/dom/base/test/test_bug346485.html
index 688c5f0e24..b0543ced20 100644
--- a/dom/base/test/test_bug346485.html
+++ b/dom/base/test/test_bug346485.html
@@ -25,9 +25,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=346485
* This test is testing DOMSettableTokenList used by the output element.
*/
+function checkHtmlFor(htmlFor, list, msg) {
+ var length = htmlFor.length;
+ is(length, list.length, htmlFor + ": incorrect htmlFor length (" + msg + ")");
+ for (var i = 0; i < length; ++i) {
+ is(htmlFor[i], list[i], htmlFor + ": wrong element at " + i + " (" + msg + ")");
+ }
+}
+
var o = document.getElementById('o');
-is(o.htmlFor, 'a b',
+is(String(o.htmlFor), 'a b',
"htmlFor IDL attribute should reflect for content attribute");
is(o.htmlFor.value, 'a b',
@@ -42,32 +50,25 @@ is(o.htmlFor.item(0), 'a', "First item is 'a' token'");
is(o.htmlFor.item(42), null, "Out-of-range should return null");
o.htmlFor.add('c');
-is(o.htmlFor, 'a b c', "'c' token should have been added");
-is(o.htmlFor.length, 3, "Size should be '3'");
+checkHtmlFor(o.htmlFor, ['a', 'b', 'c'], "'c' token should have been added");
o.htmlFor.add('a');
-is(o.htmlFor, 'a b c', "Nothing should have changed");
-is(o.htmlFor.length, 3, "Size should be '3'");
+checkHtmlFor(o.htmlFor, ['a', 'b', 'c'], "Nothing should have changed");
o.htmlFor.remove('a');
-is(o.htmlFor, 'b c', "'a' token should have been removed");
-is(o.htmlFor.length, 2, "Size should be '2'");
+checkHtmlFor(o.htmlFor, ['b', 'c'], "'a' token should have been removed");
o.htmlFor.remove('d');
-is(o.htmlFor, 'b c', "Nothing should have been removed");
-is(o.htmlFor.length, 2, "Size should be '2'");
+checkHtmlFor(o.htmlFor, ['b', 'c'], "Nothing should have been removed");
o.htmlFor.toggle('a');
-is(o.htmlFor, 'b c a', "'a' token should have been added");
-is(o.htmlFor.length, 3, "Size should be '3'");
+checkHtmlFor(o.htmlFor, ['b', 'c', 'a'], "'a' token should have been added");
o.htmlFor.toggle('b');
-is(o.htmlFor, 'c a', "Nothing should have changed");
-is(o.htmlFor.length, 2, "Size should be '2'");
+checkHtmlFor(o.htmlFor, ['c', 'a'], "Nothing should have changed");
o.htmlFor.value = "foo bar";
-is(o.htmlFor, 'foo bar', "The underlying string should have changed");
-is(o.htmlFor.length, 2, "Size should be '2'");
+checkHtmlFor(o.htmlFor, ['foo', 'bar'], "The underlying string should have changed");
ok(o.htmlFor.contains('foo'), "It should contain 'foo'");
diff --git a/dom/base/test/test_bug461555.html b/dom/base/test/test_bug461555.html
index 5902f79745..b91ca98326 100644
--- a/dom/base/test/test_bug461555.html
+++ b/dom/base/test/test_bug461555.html
@@ -26,7 +26,7 @@ function done() {
nodes = document.getElementsByTagName('span');
is(nodes.length, 3, "wrong length");
for (i = 0; i < nodes.length; ++i) {
- is(nodes[i].textContent, i+1, "wrong order");
+ is(nodes[i].textContent, String(i + 1), "wrong order");
}
SimpleTest.finish();
}
diff --git a/dom/base/test/test_bug622088.html b/dom/base/test/test_bug622088.html
index f8be69f5d3..134bb898d3 100644
--- a/dom/base/test/test_bug622088.html
+++ b/dom/base/test/test_bug622088.html
@@ -30,13 +30,13 @@ function innerLoaded(inner) {
// Here, we're being called through inner's onload handler, so our referrer
// should be inner's URL.
var referrer = inner.doXHR();
- is (referrer, inner.document.location, 'Expected inner frame location');
+ is (referrer, String(inner.document.location), 'Expected inner frame location');
// Now change the location of the inner frame. This should be reflected in
// the XHR's referrer.
inner.history.pushState('', '', Math.random());
referrer = inner.doXHR();
- is (referrer, inner.document.location, 'Expected inner frame location after pushstate');
+ is (referrer, String(inner.document.location), 'Expected inner frame location after pushstate');
innerFinishedLoading = true;
}
@@ -50,11 +50,11 @@ function callXHR() {
if (innerFinishedLoading && dataWindowFinishedLoading) {
var inner = document.getElementById('iframe').contentWindow;
var referrer = inner.doXHR();
- is (referrer, inner.document.location,
+ is (referrer, String(inner.document.location),
'Expected inner frame location when called from outer frame.');
var referrer = inner.doXHR(new XMLHttpRequest());
- is (referrer, document.location,
+ is (referrer, String(document.location),
"Expected outer frame location when called with outer's XHR object.");
// Now do a request within the inner window using an XMLHttpRequest
@@ -62,7 +62,7 @@ function callXHR() {
// data: URI.
var dataWindow = document.getElementById('dataWindow').contentWindow;
var referrer = inner.doXHR(dataWindow.getXHRObject());
- is (referrer, document.location,
+ is (referrer, String(document.location),
"Expected outer frame location when called with data's XHR object.");
// Now do that test again, but after having changed the outer window's URI.
@@ -71,7 +71,7 @@ function callXHR() {
history.replaceState('', '', Math.random());
var referrer = inner.doXHR(dataWindow.getXHRObject());
- todo_is (referrer, document.location,
+ todo_is (referrer, String(document.location),
"Expected outer frame location when called with data's XHR object " +
"after replaceState.");
diff --git a/dom/base/test/test_domrequesthelper.xul b/dom/base/test/test_domrequesthelper.xul
index 6a1420a104..708c55b7f8 100644
--- a/dom/base/test/test_domrequesthelper.xul
+++ b/dom/base/test/test_domrequesthelper.xul
@@ -43,9 +43,9 @@
* Init & destroy.
*/
function initDOMRequestHelperTest(aMessages) {
- is(dummy._requests, undefined, "Request is undefined");
+ is_loosely(dummy._requests, undefined, "Request is undefined");
is(dummy._messages, undefined, "Messages is undefined");
- is(dummy._window, undefined, "Window is undefined");
+ is_loosely(dummy._window, undefined, "Window is undefined");
dummy.initDOMRequestHelper(window, aMessages);
@@ -59,9 +59,9 @@
function destroyDOMRequestHelperTest() {
dummy.destroyDOMRequestHelper();
- is(dummy._requests, undefined, "Request is undefined");
+ is_loosely(dummy._requests, undefined, "Request is undefined");
is(dummy._messages, undefined, "Messages is undefined");
- is(dummy._window, undefined, "Window is undefined");
+ is_loosely(dummy._window, undefined, "Window is undefined");
}
/**
@@ -388,7 +388,7 @@
is(req, req_, "Got correct request");
dummy.removeRequest(id);
req = dummy.getRequest(id);
- is(req, null, "No request");
+ is(req, undefined, "No request");
next();
},
function() {
diff --git a/dom/base/test/test_url.html b/dom/base/test/test_url.html
index 43d3ca81fa..f8784ef356 100644
--- a/dom/base/test/test_url.html
+++ b/dom/base/test/test_url.html
@@ -310,7 +310,7 @@
url = new URL("http://localhost/");
url.host = "[2001::1]:30";
is(url.hostname, "[2001::1]", "IPv6 hostname");
- is(url.port, 30, "Port");
+ is(url.port, "30", "Port");
is(url.host, "[2001::1]:30", "IPv6 host");
url = new URL("http://localhost/");
diff --git a/dom/base/test/test_url_empty_port.html b/dom/base/test/test_url_empty_port.html
index 2e0d8c0577..2a164c1d62 100644
--- a/dom/base/test/test_url_empty_port.html
+++ b/dom/base/test/test_url_empty_port.html
@@ -24,14 +24,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=930450
diff --git a/dom/html/test/test_bug332893-3.html b/dom/html/test/test_bug332893-3.html
index 7cb9a4572a..372319c224 100644
--- a/dom/html/test/test_bug332893-3.html
+++ b/dom/html/test/test_bug332893-3.html
@@ -45,11 +45,11 @@
var form1 = document.getElementById("form1");
var form2 = document.getElementById("form2");
- is(form1.elements.length, "2", "Form 1 has the correct length");
+ is(form1.elements.length, 2, "Form 1 has the correct length");
is(form1.elements[0].value, "12", "Form 1 element 1 is correct");
is(form1.elements[1].value, "10", "Form 1 element 2 is correct");
- is(form2.elements.length, "3", "Form 2 has the correct length");
+ is(form2.elements.length, 3, "Form 2 has the correct length");
is(form2.elements[0].value, "11", "Form 2 element 1 is correct");
is(form2.elements[1].value, "21", "Form 2 element 2 is correct");
is(form2.elements[2].value, "22", "Form 2 element 2 is correct");
diff --git a/dom/html/test/test_bug332893-4.html b/dom/html/test/test_bug332893-4.html
index d8a5719097..abbc60ca63 100644
--- a/dom/html/test/test_bug332893-4.html
+++ b/dom/html/test/test_bug332893-4.html
@@ -16,7 +16,7 @@
var form1 = document.getElementById("form1");
form1.insertBefore(input2, input1);
- is(form1.elements["input"].length, "3", "Form 1 'input' has the correct length");
+ is(form1.elements["input"].length, 3, "Form 1 'input' has the correct length");
is(form1.elements["input"][0].value, "2", "Form 1 element 1 is correct");
is(form1.elements["input"][1].value, "1", "Form 1 element 2 is correct");
is(form1.elements["input"][2].value, "3", "Form 1 element 3 is correct");
diff --git a/dom/html/test/test_bug332893-5.html b/dom/html/test/test_bug332893-5.html
index 85166a7785..6898f9157e 100644
--- a/dom/html/test/test_bug332893-5.html
+++ b/dom/html/test/test_bug332893-5.html
@@ -16,7 +16,7 @@
var form1 = document.getElementById("form1");
form1.insertBefore(input2, input1);
- is(form1.elements["input"].length, "3", "Form 1 'input' has the correct length");
+ is(form1.elements["input"].length, 3, "Form 1 'input' has the correct length");
is(form1.elements["input"][0].value, "2", "Form 1 element 1 is correct");
is(form1.elements["input"][1].value, "1", "Form 1 element 2 is correct");
is(form1.elements["input"][2].value, "3", "Form 1 element 3 is correct");
diff --git a/dom/html/test/test_bug332893-6.html b/dom/html/test/test_bug332893-6.html
index e02a1c3f79..c5e6fe3765 100644
--- a/dom/html/test/test_bug332893-6.html
+++ b/dom/html/test/test_bug332893-6.html
@@ -16,7 +16,7 @@
var form1 = document.getElementById("form1");
form1.insertBefore(input2, input1);
- is(form1.elements["input"].length, "3", "Form 1 'input' has the correct length");
+ is(form1.elements["input"].length, 3, "Form 1 'input' has the correct length");
is(form1.elements["input"][0].value, "2", "Form 1 element 1 is correct");
is(form1.elements["input"][1].value, "1", "Form 1 element 2 is correct");
diff --git a/dom/html/test/test_bug332893-7.html b/dom/html/test/test_bug332893-7.html
index 6322923c03..7939b34ae3 100644
--- a/dom/html/test/test_bug332893-7.html
+++ b/dom/html/test/test_bug332893-7.html
@@ -41,7 +41,7 @@
form1.insertBefore(input8, input4);
form1.insertBefore(input9, input2);
- is(form1.elements["input"].length, "10", "Form 1 'input' has the correct length");
+ is(form1.elements["input"].length, 10, "Form 1 'input' has the correct length");
is(form1.elements["input"][0].value, "9", "Form 1 element 1 is correct");
is(form1.elements["input"][1].value, "2", "Form 1 element 2 is correct");
is(form1.elements["input"][2].value, "1", "Form 1 element 3 is correct");
diff --git a/dom/html/test/test_bug405242.html b/dom/html/test/test_bug405242.html
index e91efdc052..9ca3c11568 100644
--- a/dom/html/test/test_bug405242.html
+++ b/dom/html/test/test_bug405242.html
@@ -28,7 +28,7 @@ sel.options.remove(0);
sel.options.remove(1000);
sel.options.remove(-1);
is(sel.length, 1, "Unexpected option collection length");
-is(sel[0].value, 10, "Unexpected remained option");
+is(sel[0].value, "10", "Unexpected remained option");