Backed out 9 changesets (bug 1412456) for crashing talos g2 and unexpected network connections in browser-chrome's browser_searchEngine_behaviors.js r=backout a=backout on a CLOSED TREE

Backed out changeset 0c01a98f4fd5 (bug 1412456)
Backed out changeset 27077db47231 (bug 1412456)
Backed out changeset f35ec2a884f8 (bug 1412456)
Backed out changeset 602b30ac3c69 (bug 1412456)
Backed out changeset b1ff1050c589 (bug 1412456)
Backed out changeset f100d953f9eb (bug 1412456)
Backed out changeset d85af60fe259 (bug 1412456)
Backed out changeset 736f38486832 (bug 1412456)
Backed out changeset 13a637602dc2 (bug 1412456)
This commit is contained in:
Andreea Pavel 2017-12-07 12:20:21 +02:00
Родитель eb311a6f39
Коммит 89531e8dc3
179 изменённых файлов: 821 добавлений и 980 удалений

Просмотреть файл

@ -130,14 +130,8 @@ function waitForEvent(eventType, expectedId) {
let eventObserver = {
observe(subject) {
let event = subject.QueryInterface(Ci.nsIAccessibleEvent);
let id;
try {
id = event.accessible.id;
} catch (e) {
// This can throw NS_ERROR_FAILURE.
}
if (event.eventType === eventType &&
id === expectedId) {
event.accessible.id === expectedId) {
Services.obs.removeObserver(this, "accessible-event");
resolve(event);
}

Просмотреть файл

@ -1586,7 +1586,7 @@ pref("browser.tabs.crashReporting.emailMe", false);
pref("browser.tabs.crashReporting.email", "");
// Enable e10s add-on interposition by default.
pref("extensions.interposition.enabled", false);
pref("extensions.interposition.enabled", true);
pref("extensions.interposition.prefetching", true);
// But don't allow non-MPC extensions by default on Nightly

Просмотреть файл

@ -4301,10 +4301,10 @@
// Auxilliary state variables:
visibleTab: this.selectedTab, // Tab that's on screen.
spinnerTab: null, // Tab showing a spinner.
blankTab: null, // Tab showing blank.
lastPrimaryTab: this.selectedTab, // Tab with primary="true"
visibleTab: this.selectedTab, // Tab that's on screen.
spinnerTab: null, // Tab showing a spinner.
blankTab: null, // Tab showing blank.
originalTab: this.selectedTab, // Tab that we started on.
tabbrowser: this, // Reference to gBrowser.
loadTimer: null, // TAB_SWITCH_TIMEOUT nsITimer instance.
@ -4485,6 +4485,17 @@
this.destroy();
let toBrowser = this.requestedTab.linkedBrowser;
toBrowser.setAttribute("primary", "true");
let fromBrowser = this.originalTab.linkedBrowser;
// It's possible that the tab we're switching from closed
// before we were able to finalize, in which case, fromBrowser
// doesn't exist.
if (fromBrowser) {
fromBrowser.removeAttribute("primary");
}
document.commandDispatcher.unlock();
let event = new CustomEvent("TabSwitchDone", {
@ -4662,9 +4673,6 @@
if (this.lastVisibleTab && !this.lastVisibleTab.linkedBrowser) {
this.lastVisibleTab = null;
}
if (this.lastPrimaryTab && !this.lastPrimaryTab.linkedBrowser) {
this.lastPrimaryTab = null;
}
if (this.blankTab && !this.blankTab.linkedBrowser) {
this.blankTab = null;
}
@ -5043,12 +5051,6 @@
this.requestedTab = tab;
tab.linkedBrowser.setAttribute("primary", "true");
if (this.lastPrimaryTab && this.lastPrimaryTab != tab) {
this.lastPrimaryTab.linkedBrowser.removeAttribute("primary");
}
this.lastPrimaryTab = tab;
this.suppressDisplayPortAndQueueUnload(this.requestedTab, this.UNLOAD_DELAY);
this._requestingTab = false;
},

Просмотреть файл

@ -35,11 +35,12 @@ function test() {
addNotificationPermission(notificationURL).then(function openTab() {
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => onLoad());
tab.linkedBrowser.addEventListener("load", onLoad, true);
});
}
function onLoad() {
tab.linkedBrowser.removeEventListener("load", onLoad, true);
openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
}

Просмотреть файл

@ -16,11 +16,12 @@ function test() {
addNotificationPermission(notificationURL).then(function openTab() {
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => onLoad());
tab.linkedBrowser.addEventListener("load", onLoad, true);
});
}
function onLoad() {
tab.linkedBrowser.removeEventListener("load", onLoad, true);
openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
}

Просмотреть файл

@ -49,7 +49,9 @@ function test() {
function loadPinningPage() {
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kPinningDomain + kURLPath + "valid").then(function() {
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => successfulPinningPageListener.handleEvent());
gBrowser.selectedBrowser.addEventListener("load",
successfulPinningPageListener,
true);
});
}
@ -57,6 +59,7 @@ function loadPinningPage() {
// fail to validate
var successfulPinningPageListener = {
handleEvent() {
gBrowser.selectedBrowser.removeEventListener("load", this, true);
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kBadPinningDomain).then(function() {
return BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser);
}).then(errorPageLoaded);

Просмотреть файл

@ -24,10 +24,10 @@ function addTab(aURI, aIndex) {
if (aIndex == 0)
gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
tab.linkedBrowser.addEventListener("load", function(event) {
if (++count == URIS.length)
executeSoon(doTabsTest);
});
}, {capture: true, once: true});
}
function doTabsTest() {

Просмотреть файл

@ -45,11 +45,11 @@ function test() {
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
gBrowser.selectedBrowser.addEventListener("load", function() {
waitForStarChange(false, initTest);
});
}, {capture: true, once: true});
gBrowser.loadURI(testURL);
content.location = testURL;
}
function initTest() {

Просмотреть файл

@ -3,7 +3,7 @@ function test() {
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser,
"http://mochi.test:8888/browser/browser/base/content/test/general/browser_bug479408_sample.html");
BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "DOMLinkAdded", true).then(() => {
gBrowser.addEventListener("DOMLinkAdded", function(aEvent) {
executeSoon(function() {
ok(!tab.linkedBrowser.engines,
"the subframe's search engine wasn't detected");
@ -11,5 +11,5 @@ function test() {
gBrowser.removeTab(tab);
finish();
});
});
}, {capture: true, once: true});
}

Просмотреть файл

@ -11,12 +11,14 @@ add_task(async function() {
let selectedBrowser = newwindow.gBrowser.selectedBrowser;
await new Promise((resolve, reject) => {
BrowserTestUtils.waitForContentEvent(selectedBrowser, "pageshow", true, (event) => {
return content.location.href != "about:blank";
}).then(function pageshowListener() {
ok(true, "pageshow listener called: " + newwindow.gBrowser.currentURI.spec);
selectedBrowser.addEventListener("pageshow", function pageshowListener() {
if (selectedBrowser.currentURI.spec == "about:blank")
return;
selectedBrowser.removeEventListener("pageshow", pageshowListener, true);
ok(true, "pageshow listener called: " + newwindow.content.location);
resolve();
});
}, true);
selectedBrowser.loadURI("data:text/html,<h1 id='h1'>Select Me</h1>");
});

Просмотреть файл

@ -24,7 +24,8 @@ add_task(async function test_remove_bookmark_with_tag_via_edit_bookmark() {
Assert.ok(await PlacesUtils.bookmarks.fetch({url: testURL}), "the test url is bookmarked");
gBrowser.loadURI(testURL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
content.location = testURL;
await BrowserTestUtils.waitForCondition(
() => BookmarkingUI.status == BookmarkingUI.STATUS_STARRED,

Просмотреть файл

@ -76,13 +76,12 @@ function openNewTab(aWindow, aCallback) {
let browser = aWindow.gBrowser.selectedBrowser;
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocumentAsCPOW;
if (doc && doc.readyState === "complete") {
if (browser.contentDocument.readyState === "complete") {
executeSoon(aCallback);
return;
}
BrowserTestUtils.browserLoaded(browser).then(() => {
browser.addEventListener("load", function() {
executeSoon(aCallback);
});
}, {capture: true, once: true});
}

Просмотреть файл

@ -47,8 +47,8 @@ function preparePendingTab(aCallback) {
});
}
function whenLoaded(aBrowser, aCallback) {
BrowserTestUtils.browserLoaded(aBrowser).then(() => {
function whenLoaded(aElement, aCallback) {
aElement.addEventListener("load", function() {
executeSoon(aCallback);
});
}, {capture: true, once: true});
}

Просмотреть файл

@ -20,8 +20,8 @@ add_task(async function() {
let domLinkChangedFired = 0;
const linkAddedHandler = event => domLinkAddedFired++;
const linkChangedhandler = event => domLinkChangedFired++;
BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "DOMLinkAdded", linkAddedHandler);
BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "DOMLinkChanged", linkChangedhandler);
gBrowser.addEventListener("DOMLinkAdded", linkAddedHandler);
gBrowser.addEventListener("DOMLinkChanged", linkChangedhandler);
extraTab.linkedBrowser.loadURI(TEST_URL);
let expectedFavicon = "http://example.org/yet-another-icon";
await promiseTabLoaded(extraTab);
@ -39,5 +39,7 @@ add_task(async function() {
is(domLinkAddedFired, 2, "Should fire the correct number of DOMLinkAdded event.");
is(domLinkChangedFired, 0, "Should not fire any DOMLinkChanged event.");
gBrowser.removeEventListener("DOMLinkAdded", linkAddedHandler);
gBrowser.removeEventListener("DOMLinkChanged", linkChangedhandler);
gBrowser.removeTab(extraTab);
});

Просмотреть файл

@ -13,20 +13,16 @@ registerCleanupFunction(function() {
Services.prefs.clearUserPref("offline-apps.allow_by_default");
});
var cacheCount = 0;
var intervalID = 0;
//
// Handle "message" events which are posted from the iframe upon
// offline cache events.
//
function contentTask() {
let resolve;
let promise = new Promise(r => { resolve = r; });
var cacheCount = 0;
var intervalID = 0;
function handleMessageEvents(event) {
cacheCount++;
switch (cacheCount) {
function handleMessageEvents(event) {
cacheCount++;
switch (cacheCount) {
case 1:
// This is the initial caching off offline data.
is(event.data, "oncache", "Child was successfully cached.");
@ -58,16 +54,12 @@ function contentTask() {
case 2:
is(event.data, "onupdate", "Child was successfully updated.");
clearInterval(intervalID);
resolve();
finish();
break;
default:
// how'd we get here?
ok(false, "cacheCount not 1 or 2");
}
}
content.addEventListener("message", handleMessageEvents);
return promise;
}
function test() {
@ -80,6 +72,9 @@ function test() {
registerCleanupFunction(() => gBrowser.removeCurrentTab());
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
ContentTask.spawn(gBrowser.selectedBrowser, null, contentTask).then(finish);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let window = gBrowser.selectedBrowser.contentWindow;
window.addEventListener("message", handleMessageEvents);
});
}

Просмотреть файл

@ -45,5 +45,9 @@ add_task(async function test_keyword_bookmarklet() {
});
function promisePageShow() {
return BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow");
return new Promise(resolve => {
gBrowser.selectedBrowser.addEventListener("pageshow", function() {
resolve();
}, {once: true});
});
}

Просмотреть файл

@ -36,45 +36,6 @@ function test() {
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
// We use a web progress listener in the content process to cancel
// the request. For everything else, we can do the work in the
// parent, since it's easier.
ContentTask.spawn(gBrowser.selectedBrowser, null, function* gen() {
const Ci = Components.interfaces;
let listener = {
onStateChange: function onLocationChange(webProgress, req, flags, status) {
let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
Ci.nsIWebProgressListener.STATE_START;
if (!(flags & docStart)) {
return;
}
req.cancel(Components.results.NS_ERROR_FAILURE);
},
QueryInterface: function QueryInterface(aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsIWebProgressListener2) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgress.addProgressListener(listener,
Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
addEventListener("unload", () => {
webProgress.removeProgressListener(listener);
});
});
let listener = {
onStateChange: function onLocationChange(webProgress, req, flags, status) {
// Only care about document starts
@ -89,10 +50,11 @@ function test() {
is(req.originalURI.spec, gCurrTest.searchURL, "search URL was loaded");
info("Actual URI: " + req.URI.spec);
req.cancel(Components.results.NS_ERROR_FAILURE);
executeSoon(nextTest);
}
};
gBrowser.addProgressListener(listener);
registerCleanupFunction(function() {

Просмотреть файл

@ -68,7 +68,7 @@ function doTest() {
waitForLoad(function() {
// eslint-disable-next-line mozilla/no-cpows-in-tests
let loadedText = gBrowser.contentDocumentAsCPOW.body.textContent;
let loadedText = gBrowser.contentDocument.body.textContent;
ok(loadedText, "search page loaded");
let needle = "searchterms=" + gCurrTest.expectText;
is(loadedText, needle, "The query POST data should be returned in the response");
@ -84,11 +84,12 @@ function doTest() {
function waitForLoad(cb) {
let browser = gBrowser.selectedBrowser;
function wantLoad(url) {
return url != "about:blank";
}
BrowserTestUtils.browserLoaded(browser, false, wantLoad).then(() => {
browser.addEventListener("load", function listener() {
if (browser.currentURI.spec == "about:blank")
return;
info("Page loaded: " + browser.currentURI.spec);
browser.removeEventListener("load", listener, true);
cb();
}, true);
}

Просмотреть файл

@ -66,8 +66,19 @@ function promiseStarState(aValue) {
function promiseTabLoadEvent(aTab, aURL, aFinalURL) {
if (!aFinalURL)
aFinalURL = aURL;
info("Wait for load tab event");
aTab.linkedBrowser.loadURI(aURL);
return BrowserTestUtils.browserLoaded(aTab.linkedBrowser, false, aFinalURL);
return new Promise(resolve => {
info("Wait for load tab event");
aTab.linkedBrowser.addEventListener("load", function load(event) {
if (event.originalTarget != aTab.linkedBrowser.contentDocument ||
event.target.location.href == "about:blank" ||
event.target.location.href != aFinalURL) {
info("skipping spurious load event");
return;
}
aTab.linkedBrowser.removeEventListener("load", load, true);
info("Tab load event received");
resolve();
}, true, true);
aTab.linkedBrowser.loadURI(aURL);
});
}

Просмотреть файл

@ -39,7 +39,7 @@ add_task(async function() {
// Run tests once again.
let promise = promiseTestsDone(win2);
win2.gBrowser.contentWindowAsCPOW.test_panels();
win2.content.test_panels();
await promise;
ok(true, "tests succeeded a second time");

Просмотреть файл

@ -329,7 +329,9 @@ add_task(async function() {
gURLBar.focus();
await new Promise((resolve, reject) => {
BrowserTestUtils.waitForContentEvent(window.gBrowser.selectedBrowser, "pageshow", true).then(() => resolve());
window.addEventListener("pageshow", function(event) {
resolve();
}, {capture: true, once: true});
document.getElementById("Browser:Back").doCommand();
});

Просмотреть файл

@ -314,8 +314,7 @@ function whenNewTabLoaded(aWindow, aCallback) {
aWindow.BrowserOpenTab();
let browser = aWindow.gBrowser.selectedBrowser;
let doc = browser.contentDocumentAsCPOW;
if (doc && doc.readyState === "complete") {
if (browser.contentDocument.readyState === "complete") {
aCallback();
return;
}
@ -434,11 +433,11 @@ var FullZoomHelper = {
let didPs = false;
let didZoom = false;
BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow", true).then(() => {
gBrowser.addEventListener("pageshow", function(event) {
didPs = true;
if (didZoom)
resolve();
});
}, {capture: true, once: true});
if (direction == this.BACK)
gBrowser.goBack();

Просмотреть файл

@ -40,59 +40,50 @@ requiredSize.innerWidth =
(3 * (290 + 20)) + // 3 cols * (tile width + side margins)
100; // breathing room
add_task(async function setupWindowSize() {
let [oldSize, curWidth, curHeight] = await ContentTask.spawn(gBrowser.selectedBrowser, requiredSize, (requiredSizeArg) => {
var oldSizeVar = {};
Object.keys(requiredSizeArg).forEach(prop => {
info([prop, content[prop], requiredSizeArg[prop]]);
if (content[prop] < requiredSizeArg[prop]) {
oldSizeVar[prop] = content[prop];
info("Changing browser " + prop + " from " + oldSizeVar[prop] + " to " +
requiredSizeArg[prop]);
content[prop] = requiredSizeArg[prop];
}
});
return [oldSizeVar, content.outerWidth, content.outerHeight];
});
var screenHeight = {};
var screenWidth = {};
Cc["@mozilla.org/gfx/screenmanager;1"].
getService(Ci.nsIScreenManager).
primaryScreen.
GetAvailRectDisplayPix({}, {}, screenWidth, screenHeight);
screenHeight = screenHeight.value;
screenWidth = screenWidth.value;
if (screenHeight < curHeight) {
info("Warning: Browser outer height is now " +
curHeight + ", which is larger than the " +
"available screen height, " + screenHeight +
". That may cause problems.");
var 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];
}
if (screenWidth < curWidth) {
info("Warning: Browser outer width is now " +
curWidth + ", 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]);
ContentTask.spawn(gBrowser.selectedBrowser, oldSize, (oldSizeArg) => {
Object.keys(oldSizeArg).forEach(prop => {
if (oldSizeArg[prop]) {
content[prop] = oldSizeArg[prop];
}
});
});
});
});
var screenHeight = {};
var 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];
}
});
Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
Services.prefs.clearUserPref(PREF_NEWTAB_ACTIVITY_STREAM);
Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gOrigDirectorySource);

Просмотреть файл

@ -4,11 +4,12 @@ function test() {
var pageInfo;
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
gBrowser.selectedBrowser.addEventListener("load", function() {
Services.obs.addObserver(observer, "page-info-dialog-loaded");
pageInfo = BrowserPageInfo();
});
gBrowser.selectedBrowser.loadURI("https://example.com/browser/browser/base/content/test/pageinfo/feed_tab.html");
}, {capture: true, once: true});
content.location =
"https://example.com/browser/browser/base/content/test/pageinfo/feed_tab.html";
function observer(win, topic, data) {
Services.obs.removeObserver(observer, "page-info-dialog-loaded");

Просмотреть файл

@ -72,8 +72,8 @@ async function test() {
});
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedBrowser.loadURI("https://example.com/browser/browser/base/content/test/pageinfo/image.html");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
content.location = "https://example.com/browser/browser/base/content/test/pageinfo/image.html";
await waitForEvent(gBrowser.selectedBrowser, "load");
let spec = gBrowser.selectedBrowser.currentURI.spec;

Просмотреть файл

@ -13,9 +13,9 @@ function test() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function() {
gBrowser.selectedBrowser.addEventListener("load", function() {
// eslint-disable-next-line mozilla/no-cpows-in-tests
var doc = gBrowser.contentDocumentAsCPOW;
var doc = gBrowser.contentDocument;
var testImg = doc.getElementById("test-image");
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
"mediaTab", getImageInfo(testImg));
@ -35,14 +35,14 @@ function test() {
});
});
}, {capture: true, once: true});
});
}, {capture: true, once: true});
gBrowser.loadURI(
content.location =
"data:text/html," +
"<style type='text/css'>%23test-image,%23not-test-image {background-image: url('about:logo?c');}</style>" +
"<img src='about:logo?b' height=300 width=350 alt=2 id='not-test-image'>" +
"<img src='about:logo?b' height=300 width=350 alt=2>" +
"<img src='about:logo?a' height=200 width=250>" +
"<img src='about:logo?b' height=200 width=250 alt=1>" +
"<img src='about:logo?b' height=100 width=150 alt=2 id='test-image'>");
"<img src='about:logo?b' height=100 width=150 alt=2 id='test-image'>";
}

Просмотреть файл

@ -5,7 +5,7 @@ function test() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
gBrowser.selectedBrowser.addEventListener("load", function() {
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
"mediaTab");
@ -26,9 +26,9 @@ function test() {
});
});
}, {capture: true, once: true});
});
}, {capture: true, once: true});
gBrowser.selectedBrowser.loadURI(
content.location =
"data:text/html," +
"<html>" +
" <head>" +
@ -44,5 +44,5 @@ function test() {
" <a href='' style='cursor: url(about:logo?d),default;'>test link</a>" + // Cursor
" <object type='image/svg+xml' width=20 height=20 data='file:///dummy_object.svg'></object>" + // Object
" </body>" +
"</html>");
"</html>";
}

Просмотреть файл

@ -3,7 +3,7 @@ function test() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
gBrowser.selectedBrowser.addEventListener("load", function() {
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
"mediaTab");
@ -30,8 +30,8 @@ function test() {
});
});
}, {capture: true, once: true});
});
}, {capture: true, once: true});
gBrowser.selectedBrowser.loadURI(
"https://example.com/browser/browser/base/content/test/pageinfo/svg_image.html");
content.location =
"https://example.com/browser/browser/base/content/test/pageinfo/svg_image.html";
}

Просмотреть файл

@ -21,7 +21,7 @@ add_task(async function() {
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
let bindingPromise = BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "PluginBindingAttached", true, null, true);
let bindingPromise = waitForEvent(gBrowser.selectedBrowser, "PluginBindingAttached", null, true, true);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
await bindingPromise;

Просмотреть файл

@ -34,7 +34,7 @@ add_task(async function() {
gNewWindow = gBrowser.replaceTabWithWindow(gBrowser.selectedTab);
// XXX technically can't load fire before we get this call???
await BrowserTestUtils.waitForEvent(gNewWindow, "load", true);
await waitForEvent(gNewWindow, "load", null, true);
await promisePopupNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser);

Просмотреть файл

@ -31,7 +31,7 @@ add_task(async function() {
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser);
ok(popupNotification, "Test 1, Should have a click-to-play notification");
let pluginRemovedPromise = BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "PluginRemoved", true, null, true);
let pluginRemovedPromise = waitForEvent(gBrowser.selectedBrowser, "PluginRemoved", null, true, true);
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let plugin = content.document.getElementById("secondtestA");
plugin.remove();

Просмотреть файл

@ -70,7 +70,7 @@ add_task(async function() {
"Test 18a, Plugin should have an update link");
});
let promise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen", true);
let promise = waitForEvent(gBrowser.tabContainer, "TabOpen", null, true);
await ContentTask.spawn(gTestBrowser, {}, async function() {
let doc = content.document;
@ -86,7 +86,7 @@ add_task(async function() {
});
await promise;
promise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabClose", true);
promise = waitForEvent(gBrowser.tabContainer, "TabClose", null, true);
gBrowser.removeCurrentTab();
await promise;
});

Просмотреть файл

@ -30,7 +30,7 @@ add_task(async function() {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
BrowserTestUtils.addContentEventListener(gTestBrowser, "PluginBindingAttached", pluginBindingAttached, true, null, true);
gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
let testRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
await promiseTabLoadEvent(gBrowser.selectedTab, testRoot + "plugin_bug744745.html");

Просмотреть файл

@ -23,7 +23,7 @@ add_task(async function() {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
BrowserTestUtils.addContentEventListener(gTestBrowser, "PluginBindingAttached", function() { gNumPluginBindingsAttached++; }, true, null, true);
gTestBrowser.addEventListener("PluginBindingAttached", function() { gNumPluginBindingsAttached++; }, true, true);
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_bug820497.html");

Просмотреть файл

@ -9,11 +9,12 @@ var gSecondTestPermissionString = gPluginHost.getPermissionStringForType("applic
function doOnPageLoad(url, continuation) {
gNextTest = continuation;
BrowserTestUtils.browserLoaded(gTestBrowser).then(pageLoad);
gTestBrowser.loadURI(url);
gTestBrowser.addEventListener("load", pageLoad, true);
gTestBrowser.contentWindow.location = url;
}
function pageLoad() {
gTestBrowser.removeEventListener("load", pageLoad);
// The plugin events are async dispatched and can come after the load event
// This just allows the events to fire before we then go on to test the states
executeSoon(gNextTest);
@ -62,10 +63,10 @@ function test() {
// The first test plugin is CtP and the second test plugin is enabled.
function testPart1a() {
let testElement = gTestBrowser.contentDocumentAsCPOW.getElementById("test");
let testElement = gTestBrowser.contentDocument.getElementById("test");
let objLoadingContent = testElement.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "part 1a: Test plugin should not be activated");
let secondtest = gTestBrowser.contentDocumentAsCPOW.getElementById("secondtestA");
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA");
objLoadingContent = secondtest.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "part 1a: Second Test plugin should be activated");
@ -93,11 +94,11 @@ function testPart1b() {
// Now, the Test plugin should be allowed, and the Test2 plugin should be CtP
function testPart2() {
let testElement = gTestBrowser.contentDocumentAsCPOW.getElementById("test").
let testElement = gTestBrowser.contentDocument.getElementById("test").
QueryInterface(Ci.nsIObjectLoadingContent);
ok(testElement.activated, "part 2: Test plugin should be activated");
let secondtest = gTestBrowser.contentDocumentAsCPOW.getElementById("secondtestA").
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA").
QueryInterface(Ci.nsIObjectLoadingContent);
ok(!secondtest.activated, "part 2: Second Test plugin should not be activated");
is(secondtest.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY,
@ -122,13 +123,13 @@ function testPart2() {
// Now, all the things should be blocked
function testPart3() {
let testElement = gTestBrowser.contentDocumentAsCPOW.getElementById("test").
let testElement = gTestBrowser.contentDocument.getElementById("test").
QueryInterface(Ci.nsIObjectLoadingContent);
ok(!testElement.activated, "part 3: Test plugin should not be activated");
is(testElement.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED,
"part 3: Test plugin should be marked as PLUGIN_DISABLED");
let secondtest = gTestBrowser.contentDocumentAsCPOW.getElementById("secondtestA").
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA").
QueryInterface(Ci.nsIObjectLoadingContent);
ok(!secondtest.activated, "part 3: Second Test plugin should not be activated");

Просмотреть файл

@ -44,6 +44,28 @@ function waitForMs(aMs) {
});
}
function waitForEvent(subject, eventName, checkFn, useCapture, useUntrusted) {
return new Promise((resolve, reject) => {
subject.addEventListener(eventName, function listener(event) {
try {
if (checkFn && !checkFn(event)) {
return;
}
subject.removeEventListener(eventName, listener, useCapture);
resolve(event);
} catch (ex) {
try {
subject.removeEventListener(eventName, listener, useCapture);
} catch (ex2) {
// Maybe the provided object does not support removeEventListener.
}
reject(ex);
}
}, useCapture, useUntrusted);
});
}
/**
* Waits for a load (or custom) event to finish in a given tab. If provided
* load an uri into the tab.

Просмотреть файл

@ -34,19 +34,16 @@ async function doTest(parentTabSpec, childTabSpec, testTaskFn, waitForMetaRefres
await promiseReloaded;
// Wait for the script in the page to update the contents of the test div.
// eslint-disable-next-line mozilla/no-cpows-in-tests
let testDiv = gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv");
let testDiv = content.document.getElementById("mctestdiv");
await BrowserTestUtils.waitForCondition(
() => testDiv.innerHTML == "Mixed Content Blocker disabled");
// Add the link for the child tab to the page.
// eslint-disable-next-line mozilla/no-cpows-in-tests
let mainDiv = gBrowser.contentDocumentAsCPOW.createElement("div");
let mainDiv = content.document.createElement("div");
// eslint-disable-next-line no-unsanitized/property
mainDiv.innerHTML =
'<p><a id="linkToOpenInNewTab" href="' + childTabSpec + '">Link</a></p>';
// eslint-disable-next-line mozilla/no-cpows-in-tests
gBrowser.contentDocumentAsCPOW.body.appendChild(mainDiv);
content.document.body.appendChild(mainDiv);
// Execute the test in the child tabs with the two methods to open it.
for (let openFn of [simulateCtrlClick, simulateContextMenuOpenInTab]) {
@ -88,9 +85,14 @@ function simulateContextMenuOpenInTab(browser) {
// from <xul:browser>s without a tab assigned. That are most likely browsers
// that preload the new tab page.
function waitForSomeTabToLoad() {
return BrowserTestUtils.firstBrowserLoaded(window, true, (browser) => {
let tab = gBrowser.getTabForBrowser(browser);
return !!tab;
return new Promise(resolve => {
gBrowser.addEventListener("load", function onLoad(event) {
let tab = gBrowser._getTabForContentWindow(event.target.defaultView.top);
if (tab) {
gBrowser.removeEventListener("load", onLoad, true);
resolve();
}
}, true);
});
}
@ -119,8 +121,7 @@ add_task(async function test_same_origin() {
activeLoaded: true, activeBlocked: false, passiveLoaded: false,
});
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
is(content.document.getElementById("mctestdiv").innerHTML,
"Mixed Content Blocker disabled", "OK: Executed mixed script");
});
});
@ -141,8 +142,7 @@ add_task(async function test_different_origin() {
activeLoaded: false, activeBlocked: true, passiveLoaded: false,
});
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
is(content.document.getElementById("mctestdiv").innerHTML,
"Mixed Content Blocker enabled", "OK: Blocked mixed script");
});
});
@ -163,8 +163,7 @@ add_task(async function test_same_origin_metarefresh_same_origin() {
activeLoaded: true, activeBlocked: false, passiveLoaded: false,
});
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
is(content.document.getElementById("mctestdiv").innerHTML,
"Mixed Content Blocker disabled", "OK: Executed mixed script");
}, true);
});
@ -184,8 +183,7 @@ add_task(async function test_same_origin_metarefresh_different_origin() {
activeLoaded: false, activeBlocked: true, passiveLoaded: false,
});
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
is(content.document.getElementById("mctestdiv").innerHTML,
"Mixed Content Blocker enabled", "OK: Blocked mixed script");
}, true);
});
@ -205,8 +203,7 @@ add_task(async function test_same_origin_302redirect_same_origin() {
ok(!gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"),
"OK: Mixed Content is NOT being blocked");
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
is(content.document.getElementById("mctestdiv").innerHTML,
"Mixed Content Blocker disabled", "OK: Executed mixed script");
});
});
@ -226,8 +223,7 @@ add_task(async function test_same_origin_302redirect_different_origin() {
activeLoaded: false, activeBlocked: true, passiveLoaded: false,
});
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
is(content.document.getElementById("mctestdiv").innerHTML,
"Mixed Content Blocker enabled", "OK: Blocked mixed script");
});
});

Просмотреть файл

@ -7,7 +7,7 @@ function test() {
ok(gIdentityHandler, "gIdentityHandler should exist");
BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", true).then(() => {
BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "load", checkResult, true);
gBrowser.selectedBrowser.addEventListener("load", checkResult, true);
nextTest();
});
}
@ -79,6 +79,7 @@ function nextTest() {
}
if (gCurrentTestIndex == -1) {
gBrowser.selectedBrowser.removeEventListener("load", checkResult, true);
gBrowser.removeCurrentTab();
finish();
return;
@ -122,8 +123,8 @@ function nextTest() {
}
}
function checkResult() {
if (gBrowser.selectedBrowser.currentURI.spec == "about:blank")
function checkResult(event) {
if (event.target.URL == "about:blank")
return;
// Sanity check other values, and the value of gIdentityHandler.getEffectiveHost()

Просмотреть файл

@ -92,7 +92,7 @@ add_task(async function() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab", false);
// NB: CPOW usage because new tab pages can be preloaded, in which case no
// load events fire.
await BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocumentAsCPOW.hidden);
await BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocument.hidden);
let url = "https://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#foo";
gURLBar.value = url;
gURLBar.select();

Просмотреть файл

@ -7,11 +7,9 @@
add_task(async function() {
let input = "i-definitely-dont-exist.example.com";
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false);
let browser = tab.linkedBrowser;
// NB: CPOW usage because new tab pages can be preloaded, in which case no
// load events fire.
// eslint-disable-next-line mozilla/no-cpows-in-tests
await BrowserTestUtils.waitForCondition(() => browser.contentDocumentAsCPOW && !browser.contentDocumentAsCPOW.hidden);
await BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocument.hidden);
let errorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser);
gURLBar.value = input;
gURLBar.select();
@ -32,11 +30,9 @@ add_task(async function() {
let input = "To be or not to be-that is the question";
await SpecialPowers.pushPrefEnv({set: [["keyword.enabled", false]]});
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", false);
let browser = tab.linkedBrowser;
// NB: CPOW usage because new tab pages can be preloaded, in which case no
// load events fire.
// eslint-disable-next-line mozilla/no-cpows-in-tests
await BrowserTestUtils.waitForCondition(() => browser.contentDocumentAsCPOW && !browser.contentDocumentAsCPOW.hidden);
await BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocument.hidden);
let errorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser);
gURLBar.value = input;
gURLBar.select();

Просмотреть файл

@ -70,7 +70,7 @@ add_task(async function test() {
// get the title
// eslint-disable-next-line mozilla/no-cpows-in-tests
let title = browser.contentDocumentAsCPOW.title.trim().split("|");
let title = browser.contentDocument.title.trim().split("|");
// check each item in the title and validate it meets expectatations
for (let part of title) {

Просмотреть файл

@ -162,7 +162,9 @@ add_task(async function() {
is(gBrowser.tabs.length, 2, "there's a new tab");
await new Promise(resolve => {
if (gBrowser.selectedBrowser.currentURI.spec == "about:blank") {
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(resolve);
gBrowser.selectedBrowser.addEventListener("load", function(e) {
resolve();
}, {capture: true, once: true});
return;
}
// the new tab has already transitioned away from about:blank so we

Просмотреть файл

@ -401,7 +401,7 @@ function promiseTabHistoryNavigation(aDirection = -1, aConditionFn) {
}
gBrowser.addEventListener("pageshow", listener, true);
gBrowser.contentWindowAsCPOW.history.go(aDirection);
content.history.go(aDirection);
});
}

Просмотреть файл

@ -289,7 +289,7 @@ async function openContextMenuInSidebar(selector = "body") {
async function openContextMenuInFrame(frameId) {
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
let doc = gBrowser.selectedBrowser.contentDocumentAsCPOW;
let doc = gBrowser.selectedBrowser.contentDocument;
let frame = doc.getElementById(frameId);
EventUtils.synthesizeMouseAtCenter(frame.contentDocument.body, {type: "contextmenu"}, frame.contentWindow);
await popupShownPromise;

Просмотреть файл

@ -140,7 +140,7 @@ add_task(async function() {
// Open a test site which would save into quota manager
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_QUOTA_USAGE_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
await waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "test-indexedDB-done");
await waitForEvent(gBrowser.selectedBrowser.contentWindow, "test-indexedDB-done");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
let updatedPromise = promiseSiteDataManagerSitesUpdated();
@ -224,7 +224,7 @@ add_task(async function() {
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_QUOTA_USAGE_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
await waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "test-indexedDB-done");
await waitForEvent(gBrowser.selectedBrowser.contentWindow, "test-indexedDB-done");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });

Просмотреть файл

@ -103,7 +103,7 @@ function get_cache_for_private_window() {
win.gBrowser.selectedTab = tab;
let newTabBrowser = win.gBrowser.getBrowserForTab(tab);
BrowserTestUtils.browserLoaded(newTabBrowser).then(function() {
newTabBrowser.addEventListener("load", function() {
executeSoon(function() {
getStorageEntryCount("private", function(nrEntriesP) {
@ -119,7 +119,7 @@ function get_cache_for_private_window() {
});
});
});
});
}, {capture: true, once: true});
});
});
}

Просмотреть файл

@ -14,7 +14,7 @@ function test() {
let cmd;
function doTest(aIsPrivateMode, aWindow, aCallback) {
BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser).then(function() {
aWindow.gBrowser.selectedBrowser.addEventListener("load", function() {
ok(aWindow.gPrivateBrowsingUI, "The gPrivateBrowsingUI object exists");
pbMenuItem = aWindow.document.getElementById("menu_newPrivateWindow");
@ -30,7 +30,7 @@ function test() {
aIsPrivateMode + ")");
aCallback();
});
}, {capture: true, once: true});
aWindow.gBrowser.selectedBrowser.loadURI(testURI);
}

Просмотреть файл

@ -65,7 +65,7 @@ var gTests = [
let loadPromise = promiseStoppedLoad(expectedURL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
gBrowser.contentDocumentAsCPOW.getElementById("searchResetKeepCurrent").click();
gBrowser.contentDocument.getElementById("searchResetKeepCurrent").click();
await loadPromise;
is(engine, Services.search.currentEngine,
@ -84,7 +84,7 @@ var gTests = [
let currentEngine = Services.search.currentEngine;
let originalEngine = Services.search.originalDefaultEngine;
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = gBrowser.contentDocumentAsCPOW;
let doc = gBrowser.contentDocument;
let defaultEngineSpan = doc.getElementById("defaultEngine");
is(defaultEngineSpan.textContent, originalEngine.name,
"the name of the original default engine is displayed");
@ -117,7 +117,7 @@ var gTests = [
false,
"about:preferences#search");
// eslint-disable-next-line mozilla/no-cpows-in-tests
gBrowser.contentDocumentAsCPOW.getElementById("linkSettingsPage").click();
gBrowser.contentDocument.getElementById("linkSettingsPage").click();
await loadPromise;
checkTelemetryRecords(TELEMETRY_RESULT_ENUM.OPENED_SETTINGS);

Просмотреть файл

@ -21,56 +21,37 @@ const SEARCH_ENGINE_DETAILS = [{
name: "Google",
}];
async function promiseStateChangeURI() {
let promise = BrowserTestUtils.waitForMessage(gBrowser.selectedBrowser.messageManager, "test:onStateChange");
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
const Ci = Components.interfaces;
function promiseStateChangeURI() {
return new Promise(resolve => {
let listener = {
onStateChange: function onStateChange(webProgress, req, flags, status) {
info("onStateChange");
// Only care about top-level document starts
let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
Ci.nsIWebProgressListener.STATE_START;
if ((flags & docStart) != docStart || !webProgress.isTopLevel) {
if (!(flags & docStart) || !webProgress.isTopLevel)
return;
}
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
let spec = req.originalURI.spec;
if (spec == "about:blank")
return;
webProgress.removeProgressListener(listener);
gBrowser.removeProgressListener(listener);
info("received document start");
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
req.cancel(Components.results.NS_ERROR_FAILURE);
sendAsyncMessage("test:onStateChange", req.originalURI.spec);
},
QueryInterface: function QueryInterface(aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsIWebProgressListener2) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_ERROR_NO_INTERFACE;
executeSoon(() => {
resolve(spec);
});
}
};
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgress.addProgressListener(listener,
Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
gBrowser.addProgressListener(listener);
});
return [promise];
}
function promiseContentSearchReady(browser) {
@ -191,7 +172,7 @@ async function testSearchEngine(engineDetails) {
await test.preTest(tab);
}
let [stateChangePromise] = await promiseStateChangeURI();
let stateChangePromise = promiseStateChangeURI();
await test.run(tab);

Просмотреть файл

@ -71,56 +71,37 @@ const SEARCH_ENGINE_DETAILS = [{
name: "Yahoo",
}];
async function promiseStateChangeURI() {
let promise = BrowserTestUtils.waitForMessage(gBrowser.selectedBrowser.messageManager, "test:onStateChange");
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
const Ci = Components.interfaces;
function promiseStateChangeURI() {
return new Promise(resolve => {
let listener = {
onStateChange: function onStateChange(webProgress, req, flags, status) {
info("onStateChange");
// Only care about top-level document starts
let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
Ci.nsIWebProgressListener.STATE_START;
if ((flags & docStart) != docStart || !webProgress.isTopLevel) {
if (!(flags & docStart) || !webProgress.isTopLevel)
return;
}
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
let spec = req.originalURI.spec;
if (spec == "about:blank")
return;
webProgress.removeProgressListener(listener);
gBrowser.removeProgressListener(listener);
info("received document start");
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
req.cancel(Components.results.NS_ERROR_FAILURE);
sendAsyncMessage("test:onStateChange", req.originalURI.spec);
},
QueryInterface: function QueryInterface(aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsIWebProgressListener2) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_ERROR_NO_INTERFACE;
executeSoon(() => {
resolve(spec);
});
}
};
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgress.addProgressListener(listener,
Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
gBrowser.addProgressListener(listener);
});
return [promise];
}
function promiseContentSearchReady(browser) {
@ -233,7 +214,7 @@ async function testSearchEngine(engineDetails) {
await test.preTest(tab);
}
let [stateChangePromise] = await promiseStateChangeURI();
let stateChangePromise = promiseStateChangeURI();
await test.run(tab);

Просмотреть файл

@ -13,13 +13,11 @@ function test() {
let loadCount = 0;
let tab = BrowserTestUtils.addTab(gBrowser, testURL);
let removeFunc;
removeFunc = BrowserTestUtils.addContentEventListener(tab.linkedBrowser, "load", function onLoad(aEvent) {
tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) {
// make sure both the page and the frame are loaded
if (++loadCount < 2)
return;
removeFunc();
tab.linkedBrowser.removeEventListener("load", onLoad, true);
// executeSoon to allow the JS to execute on the page
executeSoon(function() {

Просмотреть файл

@ -4,6 +4,8 @@ let NS_MAC_USER_LIB_DIR = "ULibDir";
function onPageLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onPageLoad, true);
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIDirectoryServiceProvider);
@ -32,8 +34,7 @@ function onPageLoad() {
let shell = Cc["@mozilla.org/browser/shell-service;1"].
getService(Ci.nsIShellService);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let image = gBrowser.contentDocumentAsCPOW.images[0];
let image = content.document.images[0];
shell.setDesktopBackground(image, 0, "logo.png");
setTimeout(function() {
@ -58,8 +59,8 @@ function onPageLoad() {
function test() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(onPageLoad, false, "about:logo");
gBrowser.loadURI("about:logo");
gBrowser.selectedBrowser.addEventListener("load", onPageLoad, true);
content.location = "about:logo";
waitForExplicitFinish();
}

Просмотреть файл

@ -121,9 +121,12 @@ function promiseTestPageLoad(url) {
return new Promise(resolve => {
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
let browser = gBrowser.selectedBrowser;
BrowserTestUtils.browserLoaded(browser, false, (loadurl) => loadurl != "about:blank").then(() => {
browser.addEventListener("load", function listener() {
if (browser.currentURI.spec == "about:blank")
return;
info("Page loaded: " + browser.currentURI.spec);
browser.removeEventListener("load", listener, true);
resolve(tab);
});
}, true);
});
}

Просмотреть файл

@ -21,7 +21,7 @@ function test() {
gBrowser.removeTab(tab);
Services.prefs.clearUserPref(kShowUIPref);
});
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
tab.linkedBrowser.addEventListener("load", function() {
(async function() {
for (let testCase of gTests) {
info(testCase.desc);
@ -31,9 +31,9 @@ function test() {
ok(false, "Unexpected Exception: " + ex);
finish();
});
});
}, {capture: true, once: true});
gBrowser.selectedBrowser.loadURI("http://example.com/");
content.location = "http://example.com/";
}
function getLanguageExceptions() {

Просмотреть файл

@ -77,7 +77,7 @@ function test() {
Services.prefs.setBoolPref(kShowUIPref, true);
let tab = BrowserTestUtils.addTab(gBrowser);
gBrowser.selectedTab = tab;
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
tab.linkedBrowser.addEventListener("load", function() {
TranslationStub.browser = gBrowser.selectedBrowser;
registerCleanupFunction(function() {
gBrowser.removeTab(tab);
@ -86,9 +86,9 @@ function test() {
run_tests(() => {
finish();
});
});
}, {capture: true, once: true});
gBrowser.selectedBrowser.loadURI("data:text/plain,test page");
content.location = "data:text/plain,test page";
}
function checkURLBarIcon(aExpectTranslated = false) {

Просмотреть файл

@ -116,10 +116,13 @@ function promiseTestPageLoad(url) {
return new Promise(resolve => {
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
let browser = gBrowser.selectedBrowser;
BrowserTestUtils.browserLoaded(browser, false, (loadurl) => loadurl != "about:blank").then(() => {
browser.addEventListener("load", function listener() {
if (browser.currentURI.spec == "about:blank")
return;
info("Page loaded: " + browser.currentURI.spec);
browser.removeEventListener("load", listener, true);
resolve(tab);
});
}, true);
});
}

Просмотреть файл

@ -263,7 +263,7 @@ function loadUITourTestPage(callback, host = "https://example.org/") {
gTestTab = BrowserTestUtils.addTab(gBrowser, url);
gBrowser.selectedTab = gTestTab;
BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser).then(() => {
gTestTab.linkedBrowser.addEventListener("load", function() {
if (gMultiProcessBrowser) {
// When e10s is enabled, make gContentAPI and gContentWindow proxies which has every property
// return a function which calls the method of the same name on
@ -352,7 +352,7 @@ function loadUITourTestPage(callback, host = "https://example.org/") {
}
waitForFocus(callback, gTestTab.linkedBrowser);
});
}, {capture: true, once: true});
}
// Wrapper for UITourTest to be used by add_task tests.

Просмотреть файл

@ -37,7 +37,7 @@ add_task(async function test_hide_skip_button_via_perf() {
await promiseOnboardingOverlayOpened(tab.linkedBrowser);
// eslint-disable-next-line mozilla/no-cpows-in-tests
ok(!gBrowser.contentDocumentAsCPOW.querySelector("#onboarding-skip-tour-button"), "should not render the skip button");
ok(!content.document.querySelector("#onboarding-skip-tour-button"), "should not render the skip button");
await BrowserTestUtils.removeTab(tab);
});

Просмотреть файл

@ -14,7 +14,7 @@ add_task(async function test_onboarding_default_new_tourset() {
await promiseOnboardingOverlayOpened(tab.linkedBrowser);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = gBrowser.contentDocumentAsCPOW;
let doc = content && content.document;
let doms = doc.querySelectorAll(".onboarding-tour-item");
is(doms.length, TOUR_IDs.length, "has exact tour numbers");
doms.forEach((dom, idx) => {
@ -45,7 +45,7 @@ add_task(async function test_onboarding_custom_new_tourset() {
await promiseOnboardingOverlayOpened(tab.linkedBrowser);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = gBrowser.contentDocumentAsCPOW;
let doc = content && content.document;
let doms = doc.querySelectorAll(".onboarding-tour-item");
is(doms.length, CUSTOM_NEW_TOURs.length, "has exact tour numbers");
doms.forEach((dom, idx) => {
@ -75,7 +75,7 @@ add_task(async function test_onboarding_custom_update_tourset() {
await promiseOnboardingOverlayOpened(tab.linkedBrowser);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = gBrowser.contentDocumentAsCPOW;
let doc = content && content.document;
let doms = doc.querySelectorAll(".onboarding-tour-item");
is(doms.length, CUSTOM_UPDATE_TOURs.length, "has exact tour numbers");
doms.forEach((dom, idx) => {

Просмотреть файл

@ -15,7 +15,7 @@ decorate_task(
withAboutStudies,
async function testAboutStudiesWorks(browser) {
// eslint-disable-next-line mozilla/no-cpows-in-tests
ok(browser.contentDocumentAsCPOW.getElementById("app"), "App element was found");
ok(browser.contentDocument.getElementById("app"), "App element was found");
}
);
@ -43,8 +43,6 @@ decorate_task(
decorate_task(
withAboutStudies,
async function testUpdatePreferencesNewOrganization(browser) {
let loadPromise = BrowserTestUtils.firstBrowserLoaded(window);
// We have to use gBrowser instead of browser in most spots since we're
// dealing with a new tab outside of the about:studies tab.
const tab = await BrowserTestUtils.switchTab(gBrowser, () => {
@ -53,9 +51,13 @@ decorate_task(
});
});
await loadPromise;
/* eslint-disable mozilla/no-cpows-in-tests */
if (gBrowser.contentDocument.readyState !== "complete") {
await BrowserTestUtils.waitForEvent(gBrowser.contentWindow, "load");
}
const location = gBrowser.currentURI.spec;
const location = gBrowser.contentWindow.location.href;
/* eslint-enable mozilla/no-cpows-in-tests */
is(
location,
"about:preferences#privacy",

Просмотреть файл

@ -53,7 +53,12 @@ add_task(async function test_abouthome_simpleQuery() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
info("Setup waiting for AboutHomeLoadSnippetsCompleted.");
let promiseAboutHomeLoaded = BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, "AboutHomeLoadSnippetsCompleted", true, null, true);
let promiseAboutHomeLoaded = new Promise(resolve => {
tab.linkedBrowser.addEventListener("AboutHomeLoadSnippetsCompleted", function loadListener(event) {
tab.linkedBrowser.removeEventListener("AboutHomeLoadSnippetsCompleted", loadListener, true);
resolve();
}, true, true);
});
info("Load about:home.");
tab.linkedBrowser.loadURI("about:home");
@ -100,7 +105,12 @@ add_task(async function test_abouthome_activitystream_simpleQuery() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
info("Setup waiting for search input to initialise.");
let promiseAboutHomeSearchLoaded = BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, "ContentSearchClient", true, null, true).then(() => false);
let promiseAboutHomeSearchLoaded = new Promise(resolve => {
tab.linkedBrowser.addEventListener("ContentSearchClient", function loadListener(event) {
tab.linkedBrowser.removeEventListener("ContentSearchClient", loadListener, true);
executeSoon(resolve);
}, true, true);
});
info("Load about:home.");
tab.linkedBrowser.loadURI("about:home");

Просмотреть файл

@ -132,7 +132,7 @@ var { helpers, assert } = (function () {
options.browser = tabbrowser.getBrowserForTab(options.tab);
options.target = TargetFactory.forTab(options.tab);
var loaded = BrowserTestUtils.browserLoaded(options.browser).then(function () {
var loaded = helpers.listenOnce(options.browser, "load", true).then(function (ev) {
var reply = callback.call(null, options);
return Promise.resolve(reply).catch(function (error) {
@ -149,7 +149,7 @@ var { helpers, assert } = (function () {
});
});
options.browser.loadURI(url);
options.browser.contentWindow.location = url;
return loaded;
};

Просмотреть файл

@ -45,7 +45,7 @@ function test() {
is(workerClient2.isClosed, false, "worker in tab 2 should not be closed");
executeSoon(() => {
tab.linkedBrowser.goBack();
tab.linkedBrowser.contentWindow.history.back();
});
yield waitForWorkerClose(workerClient2);
is(workerClient2.isClosed, true, "worker in tab 2 should be closed");

Просмотреть файл

@ -90,7 +90,7 @@ function testEventListeners(aThreadClient) {
ok(node, "There is a node property.");
ok(node.object, "There is a node object property.");
ok(node.selector == "window" ||
gBrowser.contentDocumentAsCPOW.querySelectorAll(node.selector).length == 1,
content.document.querySelectorAll(node.selector).length == 1,
"The node property is a unique CSS selector.");
let func = l.function;

Просмотреть файл

@ -89,7 +89,7 @@ function testEventListeners(aThreadClient) {
ok(node, "There is a node property.");
ok(node.object, "There is a node object property.");
ok(node.selector == "window" ||
gBrowser.contentDocumentAsCPOW.querySelectorAll(node.selector).length == 1,
content.document.querySelectorAll(node.selector).length == 1,
"The node property is a unique CSS selector.");
let func = l.function;

Просмотреть файл

@ -43,10 +43,10 @@ function test() {
gBrowser.tabContainer.addEventListener("TabOpen", function (e) {
ok(true, "A new tab loaded");
BrowserTestUtils.waitForContentEvent(e.target.linkedBrowser, "DOMContentLoaded").then(function () {
gBrowser.addEventListener("DOMContentLoaded", function (e) {
// Pass along the new tab's URI.
resolve(gBrowser.currentURI.spec);
});
}, {once: true});
}, {once: true});
});
}

Просмотреть файл

@ -567,7 +567,7 @@ let initDebugger = Task.async(function*(urlOrTab, options) {
}
info("Debugee tab added successfully: " + urlOrTab);
let debuggee = tab.linkedBrowser.contentWindowAsCPOW.wrappedJSObject;
let debuggee = tab.linkedBrowser.contentWindow.wrappedJSObject;
let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "jsdebugger");

Просмотреть файл

@ -28,7 +28,7 @@ function test()
let keysetMap = { };
addTab(TEST_URL).then(function () {
doc = gBrowser.contentDocumentAsCPOW;
doc = content.document;
node = doc.querySelector("h1");
waitForFocus(setupKeyBindingsTest);
});

Просмотреть файл

@ -83,10 +83,15 @@ function toggleServiceWorkersTestingCheckbox() {
}
function reload() {
let promise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
let deferred = defer();
gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
deferred.resolve();
}, true);
executeInContent("devtools:test:reload", {}, {}, false);
return promise;
return deferred.promise;
}
function testRegisterSuccesses(data) {

Просмотреть файл

@ -88,7 +88,7 @@ const ConsoleObserver = {
observe: function (subject, topic, data) {
let message = subject.wrappedJSObject.arguments[0];
if (message && /Failed propType/.test(message.toString())) {
if (/Failed propType/.test(message)) {
ok(false, message);
}
}

Просмотреть файл

@ -74,5 +74,9 @@ function* chooseWithInspectElementContextMenu(selector, tab) {
}
function waitForLinkedBrowserEvent(tab, event) {
return BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, event, true);
return new Promise(resolve => {
tab.linkedBrowser.addEventListener(event, function () {
resolve();
}, {capture: true, once: true});
});
}

Просмотреть файл

@ -50,7 +50,7 @@ add_task(function* () {
info("Open the inspector to a blank page.");
let { inspector, tab, testActor } = yield openInspectorForURL("about:blank");
let pageLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
let pageLoaded = waitForPageLoad(tab);
info("Navigate to the test url and waiting for the page to be loaded.");
yield navigateTo(inspector, TEST_URL);
@ -64,3 +64,7 @@ add_task(function* () {
is(yield testActor.isHighlighting(), true,
"Box Model highlighter is working as expected.");
});
const waitForPageLoad = (tab) => new Promise(resolve => {
tab.linkedBrowser.addEventListener("load", resolve, {capture: true, once: true});
});

Просмотреть файл

@ -69,7 +69,11 @@ add_task(function* () {
});
function waitForLinkedBrowserEvent(tab, event) {
return BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, event, true);
return new Promise(resolve => {
tab.linkedBrowser.addEventListener(event, function () {
resolve();
}, {capture: true, once: true});
});
}
function contentReadyState(tab) {

Просмотреть файл

@ -9,7 +9,7 @@ add_task(function* () {
let newWindow = yield newWindowPromise;
newWindow.focus();
yield BrowserTestUtils.browserLoaded(newWindow.gBrowser.selectedBrowser);
yield once(newWindow.gBrowser, "load", true);
let tab = newWindow.gBrowser.selectedTab;
yield openRDM(tab);

Просмотреть файл

@ -14,11 +14,11 @@ function test()
CloseObserver.init();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,<p>test browser last window closing</p>");
content.location = "data:text/html;charset=utf8,<p>test browser last window closing</p>";
}

Просмотреть файл

@ -12,11 +12,11 @@ function test()
Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,Scratchpad test for bug 646070 - chrome context preference");
content.location = "data:text/html,Scratchpad test for bug 646070 - chrome context preference";
}
function runTests()

Просмотреть файл

@ -7,11 +7,11 @@ function test() {
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,test context switch in Scratchpad");
content.location = "data:text/html,test context switch in Scratchpad";
}
function runTests() {
@ -49,7 +49,7 @@ function runTests() {
ok(!pageResult, "no content.foobarBug636725");
},
then: function* () {
is(gBrowser.contentWindowAsCPOW.wrappedJSObject.foobarBug636725, "aloha",
is(content.wrappedJSObject.foobarBug636725, "aloha",
"content.foobarBug636725 has been set");
}
}, {

Просмотреть файл

@ -8,12 +8,12 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests, {"state":{"text":""}});
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html, test that exceptions are output as " +
"comments correctly in Scratchpad");
content.location = "data:text/html, test that exceptions are output as " +
"comments correctly in Scratchpad";
}
function runTests()

Просмотреть файл

@ -8,12 +8,12 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests, {"state":{"text":""}});
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test that exceptions are output as " +
"comments for 'display' and not sent to the console in Scratchpad");
content.location = "data:text/html,<p>test that exceptions are output as " +
"comments for 'display' and not sent to the console in Scratchpad";
}
function runTests()

Просмотреть файл

@ -13,11 +13,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, false);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,test Edit menu updates Scratchpad - bug 699130");
content.location = "data:text/html,test Edit menu updates Scratchpad - bug 699130";
}
function runTests()

Просмотреть файл

@ -7,11 +7,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad eval function.");
content.location = "data:text/html;charset=utf8,test Scratchpad eval function.";
}
function reportErrorAndQuit(error) {

Просмотреть файл

@ -7,11 +7,11 @@ function test() {
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test run() and display() in Scratchpad");
content.location = "data:text/html,<p>test run() and display() in Scratchpad";
}
function runTests() {

Просмотреть файл

@ -8,11 +8,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(testFalsy);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test falsy display() values in Scratchpad");
content.location = "data:text/html,<p>test falsy display() values in Scratchpad";
}
function testFalsy()

Просмотреть файл

@ -16,11 +16,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test file open and save in Scratchpad");
content.location = "data:text/html,<p>test file open and save in Scratchpad";
}
function runTests()

Просмотреть файл

@ -8,11 +8,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test the 'Jump to line' feature in Scratchpad");
content.location = "data:text/html,<p>test the 'Jump to line' feature in Scratchpad";
}
function runTests(aWindow, aScratchpad)

Просмотреть файл

@ -8,10 +8,10 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
gBrowser.loadURI("data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760");
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760";
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTest);
});
}, {capture: true, once: true});
}
function runTest()

Просмотреть файл

@ -10,11 +10,11 @@ function test()
Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, false);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,initialization test for Scratchpad");
content.location = "data:text/html,initialization test for Scratchpad";
}
function runTests()

Просмотреть файл

@ -7,11 +7,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,<p>test inspect() in Scratchpad</p>");
content.location = "data:text/html;charset=utf8,<p>test inspect() in Scratchpad</p>";
}
function runTests()

Просмотреть файл

@ -7,11 +7,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,<p>test long string in Scratchpad</p>");
content.location = "data:text/html;charset=utf8,<p>test long string in Scratchpad</p>";
}
function runTests()

Просмотреть файл

@ -15,11 +15,11 @@ function test() {
Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, false);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test file open and save in Scratchpad");
content.location = "data:text/html,<p>test file open and save in Scratchpad";
}
function runTests() {

Просмотреть файл

@ -9,12 +9,12 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad." +
"openErrorConsole()");
content.location = "data:text/html;charset=utf8,test Scratchpad." +
"openErrorConsole()";
}
function runTests()

Просмотреть файл

@ -7,11 +7,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad pretty print.");
content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
}
var gTabsize;

Просмотреть файл

@ -7,11 +7,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad pretty print.");
content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
}
function runTests(sw)

Просмотреть файл

@ -10,12 +10,12 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,"
+ "test Scratchpad pretty print error goto line.");
content.location = "data:text/html;charset=utf8,"
+ "test Scratchpad pretty print error goto line.";
}
function testJumpToPrettyPrintError(sp, error, remark) {

Просмотреть файл

@ -336,11 +336,11 @@ function test()
PreferenceObserver.init();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(startTest);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test recent files in Scratchpad");
content.location = "data:text/html,<p>test recent files in Scratchpad";
}
function finishTest()

Просмотреть файл

@ -17,11 +17,11 @@ function test()
Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, true);
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,Scratchpad test for bug 740948");
content.location = "data:text/html,Scratchpad test for bug 740948";
}
function runTests()
@ -54,8 +54,8 @@ function runTests()
let browser = gBrowser.selectedBrowser;
let deferred = defer();
browser.contentWindowAsCPOW.addEventListener("DOMWindowCreated", function () {
browser.contentWindowAsCPOW.addEventListener("foo", function () {
browser.addEventListener("DOMWindowCreated", function () {
browser.contentWindow.addEventListener("foo", function () {
is(browser.contentWindow.document.body.innerHTML, "Modified text",
"After reloading, HTML is different.");
@ -64,7 +64,7 @@ function runTests()
}, {capture: true, once: true});
}, {capture: true, once: true});
ok(browser.contentWindowAsCPOW.document.body.innerHTML !== "Modified text",
ok(browser.contentWindow.document.body.innerHTML !== "Modified text",
"Before reloading, HTML is intact.");
sp.reloadAndRun().then(deferred.promise).then(finish);
}

Просмотреть файл

@ -13,12 +13,12 @@ function test()
// preference value with the expected value.
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<title>Bug 1140839</title>" +
"<p>test Scratchpad should remember View options");
content.location = "data:text/html,<title>Bug 1140839</title>" +
"<p>test Scratchpad should remember View options";
}
function runTests()

Просмотреть файл

@ -25,11 +25,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test that undo get's reset after file load in Scratchpad");
content.location = "data:text/html,<p>test that undo get's reset after file load in Scratchpad";
}
function runTests()

Просмотреть файл

@ -124,10 +124,10 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(startTest);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html,<p>test reverting to last saved state of" +
" a file </p>");
content.location = "data:text/html,<p>test reverting to last saved state of" +
" a file </p>";
}

Просмотреть файл

@ -10,11 +10,11 @@ function test()
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
gBrowser.selectedBrowser.addEventListener("load", function () {
openScratchpad(runTests);
});
}, {capture: true, once: true});
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad pretty print.");
content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
}
function runTests(sw)

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше