зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1412456 - Test changes to no longer use interposition (r=felipe,bgrins,mrbkap)
MozReview-Commit-ID: 2nQPOSGTr1s
This commit is contained in:
Родитель
126a9b2c4e
Коммит
bef7c122df
|
@ -130,8 +130,14 @@ 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 &&
|
||||
event.accessible.id === expectedId) {
|
||||
id === expectedId) {
|
||||
Services.obs.removeObserver(this, "accessible-event");
|
||||
resolve(event);
|
||||
}
|
||||
|
|
|
@ -35,12 +35,11 @@ function test() {
|
|||
addNotificationPermission(notificationURL).then(function openTab() {
|
||||
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
|
||||
gBrowser.selectedTab = tab;
|
||||
tab.linkedBrowser.addEventListener("load", onLoad, true);
|
||||
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => onLoad());
|
||||
});
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
tab.linkedBrowser.removeEventListener("load", onLoad, true);
|
||||
openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,11 @@ function test() {
|
|||
addNotificationPermission(notificationURL).then(function openTab() {
|
||||
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
|
||||
gBrowser.selectedTab = tab;
|
||||
tab.linkedBrowser.addEventListener("load", onLoad, true);
|
||||
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => onLoad());
|
||||
});
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
tab.linkedBrowser.removeEventListener("load", onLoad, true);
|
||||
openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,7 @@ function test() {
|
|||
function loadPinningPage() {
|
||||
|
||||
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kPinningDomain + kURLPath + "valid").then(function() {
|
||||
gBrowser.selectedBrowser.addEventListener("load",
|
||||
successfulPinningPageListener,
|
||||
true);
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => successfulPinningPageListener.handleEvent());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,7 +57,6 @@ 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});
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", function(event) {
|
||||
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
|
||||
if (++count == URIS.length)
|
||||
executeSoon(doTabsTest);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
}
|
||||
|
||||
function doTabsTest() {
|
||||
|
|
|
@ -45,11 +45,11 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
|
||||
waitForStarChange(false, initTest);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = testURL;
|
||||
gBrowser.loadURI(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");
|
||||
|
||||
gBrowser.addEventListener("DOMLinkAdded", function(aEvent) {
|
||||
BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "DOMLinkAdded", true).then(() => {
|
||||
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,14 +11,12 @@ add_task(async function() {
|
|||
|
||||
let selectedBrowser = newwindow.gBrowser.selectedBrowser;
|
||||
await new Promise((resolve, reject) => {
|
||||
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);
|
||||
BrowserTestUtils.waitForContentEvent(selectedBrowser, "pageshow", true, (event) => {
|
||||
return content.location.href != "about:blank";
|
||||
}).then(function pageshowListener() {
|
||||
ok(true, "pageshow listener called: " + newwindow.gBrowser.currentURI.spec);
|
||||
resolve();
|
||||
}, true);
|
||||
});
|
||||
selectedBrowser.loadURI("data:text/html,<h1 id='h1'>Select Me</h1>");
|
||||
});
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@ 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");
|
||||
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
content.location = testURL;
|
||||
gBrowser.loadURI(testURL);
|
||||
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() => BookmarkingUI.status == BookmarkingUI.STATUS_STARRED,
|
||||
|
|
|
@ -76,12 +76,13 @@ function openNewTab(aWindow, aCallback) {
|
|||
|
||||
let browser = aWindow.gBrowser.selectedBrowser;
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
if (browser.contentDocument.readyState === "complete") {
|
||||
let doc = browser.contentDocumentAsCPOW;
|
||||
if (doc && doc.readyState === "complete") {
|
||||
executeSoon(aCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
browser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(browser).then(() => {
|
||||
executeSoon(aCallback);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ function preparePendingTab(aCallback) {
|
|||
});
|
||||
}
|
||||
|
||||
function whenLoaded(aElement, aCallback) {
|
||||
aElement.addEventListener("load", function() {
|
||||
function whenLoaded(aBrowser, aCallback) {
|
||||
BrowserTestUtils.browserLoaded(aBrowser).then(() => {
|
||||
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++;
|
||||
gBrowser.addEventListener("DOMLinkAdded", linkAddedHandler);
|
||||
gBrowser.addEventListener("DOMLinkChanged", linkChangedhandler);
|
||||
BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "DOMLinkAdded", linkAddedHandler);
|
||||
BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "DOMLinkChanged", linkChangedhandler);
|
||||
extraTab.linkedBrowser.loadURI(TEST_URL);
|
||||
let expectedFavicon = "http://example.org/yet-another-icon";
|
||||
await promiseTabLoaded(extraTab);
|
||||
|
@ -39,7 +39,5 @@ 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,16 +13,20 @@ 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 handleMessageEvents(event) {
|
||||
cacheCount++;
|
||||
switch (cacheCount) {
|
||||
function contentTask() {
|
||||
let resolve;
|
||||
let promise = new Promise(r => { resolve = r; });
|
||||
|
||||
var cacheCount = 0;
|
||||
var intervalID = 0;
|
||||
|
||||
function handleMessageEvents(event) {
|
||||
cacheCount++;
|
||||
switch (cacheCount) {
|
||||
case 1:
|
||||
// This is the initial caching off offline data.
|
||||
is(event.data, "oncache", "Child was successfully cached.");
|
||||
|
@ -54,12 +58,16 @@ function handleMessageEvents(event) {
|
|||
case 2:
|
||||
is(event.data, "onupdate", "Child was successfully updated.");
|
||||
clearInterval(intervalID);
|
||||
finish();
|
||||
resolve();
|
||||
break;
|
||||
default:
|
||||
// how'd we get here?
|
||||
ok(false, "cacheCount not 1 or 2");
|
||||
}
|
||||
}
|
||||
|
||||
content.addEventListener("message", handleMessageEvents);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
@ -72,9 +80,6 @@ function test() {
|
|||
registerCleanupFunction(() => gBrowser.removeCurrentTab());
|
||||
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
let window = gBrowser.selectedBrowser.contentWindow;
|
||||
|
||||
window.addEventListener("message", handleMessageEvents);
|
||||
ContentTask.spawn(gBrowser.selectedBrowser, null, contentTask).then(finish);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -45,9 +45,5 @@ add_task(async function test_keyword_bookmarklet() {
|
|||
});
|
||||
|
||||
function promisePageShow() {
|
||||
return new Promise(resolve => {
|
||||
gBrowser.selectedBrowser.addEventListener("pageshow", function() {
|
||||
resolve();
|
||||
}, {once: true});
|
||||
});
|
||||
return BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow");
|
||||
}
|
||||
|
|
|
@ -36,6 +36,45 @@ 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
|
||||
|
@ -50,11 +89,10 @@ 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.contentDocument.body.textContent;
|
||||
let loadedText = gBrowser.contentDocumentAsCPOW.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,12 +84,11 @@ function doTest() {
|
|||
|
||||
function waitForLoad(cb) {
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function listener() {
|
||||
if (browser.currentURI.spec == "about:blank")
|
||||
return;
|
||||
function wantLoad(url) {
|
||||
return url != "about:blank";
|
||||
}
|
||||
BrowserTestUtils.browserLoaded(browser, false, wantLoad).then(() => {
|
||||
info("Page loaded: " + browser.currentURI.spec);
|
||||
browser.removeEventListener("load", listener, true);
|
||||
|
||||
cb();
|
||||
}, true);
|
||||
}
|
||||
|
|
|
@ -66,19 +66,8 @@ function promiseStarState(aValue) {
|
|||
function promiseTabLoadEvent(aTab, aURL, aFinalURL) {
|
||||
if (!aFinalURL)
|
||||
aFinalURL = aURL;
|
||||
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);
|
||||
});
|
||||
|
||||
info("Wait for load tab event");
|
||||
aTab.linkedBrowser.loadURI(aURL);
|
||||
return BrowserTestUtils.browserLoaded(aTab.linkedBrowser, false, aFinalURL);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ add_task(async function() {
|
|||
|
||||
// Run tests once again.
|
||||
let promise = promiseTestsDone(win2);
|
||||
win2.content.test_panels();
|
||||
win2.gBrowser.contentWindowAsCPOW.test_panels();
|
||||
await promise;
|
||||
ok(true, "tests succeeded a second time");
|
||||
|
||||
|
|
|
@ -329,9 +329,7 @@ add_task(async function() {
|
|||
gURLBar.focus();
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
window.addEventListener("pageshow", function(event) {
|
||||
resolve();
|
||||
}, {capture: true, once: true});
|
||||
BrowserTestUtils.waitForContentEvent(window.gBrowser.selectedBrowser, "pageshow", true).then(() => resolve());
|
||||
document.getElementById("Browser:Back").doCommand();
|
||||
});
|
||||
|
||||
|
|
|
@ -314,7 +314,8 @@ function whenNewTabLoaded(aWindow, aCallback) {
|
|||
aWindow.BrowserOpenTab();
|
||||
|
||||
let browser = aWindow.gBrowser.selectedBrowser;
|
||||
if (browser.contentDocument.readyState === "complete") {
|
||||
let doc = browser.contentDocumentAsCPOW;
|
||||
if (doc && doc.readyState === "complete") {
|
||||
aCallback();
|
||||
return;
|
||||
}
|
||||
|
@ -433,11 +434,11 @@ var FullZoomHelper = {
|
|||
let didPs = false;
|
||||
let didZoom = false;
|
||||
|
||||
gBrowser.addEventListener("pageshow", function(event) {
|
||||
BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow", true).then(() => {
|
||||
didPs = true;
|
||||
if (didZoom)
|
||||
resolve();
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
if (direction == this.BACK)
|
||||
gBrowser.goBack();
|
||||
|
|
|
@ -40,50 +40,59 @@ requiredSize.innerWidth =
|
|||
(3 * (290 + 20)) + // 3 cols * (tile width + side margins)
|
||||
100; // breathing room
|
||||
|
||||
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];
|
||||
}
|
||||
});
|
||||
|
||||
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];
|
||||
}
|
||||
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.");
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_NEWTAB_ACTIVITY_STREAM);
|
||||
Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gOrigDirectorySource);
|
||||
|
|
|
@ -4,12 +4,11 @@ function test() {
|
|||
var pageInfo;
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
|
||||
Services.obs.addObserver(observer, "page-info-dialog-loaded");
|
||||
pageInfo = BrowserPageInfo();
|
||||
}, {capture: true, once: true});
|
||||
content.location =
|
||||
"https://example.com/browser/browser/base/content/test/pageinfo/feed_tab.html";
|
||||
});
|
||||
gBrowser.selectedBrowser.loadURI("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);
|
||||
content.location = "https://example.com/browser/browser/base/content/test/pageinfo/image.html";
|
||||
await waitForEvent(gBrowser.selectedBrowser, "load");
|
||||
gBrowser.selectedBrowser.loadURI("https://example.com/browser/browser/base/content/test/pageinfo/image.html");
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
let spec = gBrowser.selectedBrowser.currentURI.spec;
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ function test() {
|
|||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function() {
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
var doc = gBrowser.contentDocument;
|
||||
var doc = gBrowser.contentDocumentAsCPOW;
|
||||
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});
|
||||
});
|
||||
|
||||
content.location =
|
||||
gBrowser.loadURI(
|
||||
"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);
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
|
||||
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
|
||||
"mediaTab");
|
||||
|
||||
|
@ -26,9 +26,9 @@ function test() {
|
|||
});
|
||||
});
|
||||
}, {capture: true, once: true});
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location =
|
||||
gBrowser.selectedBrowser.loadURI(
|
||||
"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);
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
|
||||
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
|
||||
"mediaTab");
|
||||
|
||||
|
@ -30,8 +30,8 @@ function test() {
|
|||
});
|
||||
});
|
||||
}, {capture: true, once: true});
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location =
|
||||
"https://example.com/browser/browser/base/content/test/pageinfo/svg_image.html";
|
||||
gBrowser.selectedBrowser.loadURI(
|
||||
"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 = waitForEvent(gBrowser.selectedBrowser, "PluginBindingAttached", null, true, true);
|
||||
let bindingPromise = BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "PluginBindingAttached", true, null, 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 waitForEvent(gNewWindow, "load", null, true);
|
||||
await BrowserTestUtils.waitForEvent(gNewWindow, "load", 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 = waitForEvent(gBrowser.selectedBrowser, "PluginRemoved", null, true, true);
|
||||
let pluginRemovedPromise = BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "PluginRemoved", true, null, 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 = waitForEvent(gBrowser.tabContainer, "TabOpen", null, true);
|
||||
let promise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen", true);
|
||||
|
||||
await ContentTask.spawn(gTestBrowser, {}, async function() {
|
||||
let doc = content.document;
|
||||
|
@ -86,7 +86,7 @@ add_task(async function() {
|
|||
});
|
||||
await promise;
|
||||
|
||||
promise = waitForEvent(gBrowser.tabContainer, "TabClose", null, true);
|
||||
promise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabClose", true);
|
||||
gBrowser.removeCurrentTab();
|
||||
await promise;
|
||||
});
|
||||
|
|
|
@ -30,7 +30,7 @@ add_task(async function() {
|
|||
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
|
||||
|
||||
gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
|
||||
BrowserTestUtils.addContentEventListener(gTestBrowser, "PluginBindingAttached", pluginBindingAttached, true, null, 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");
|
||||
|
||||
gTestBrowser.addEventListener("PluginBindingAttached", function() { gNumPluginBindingsAttached++; }, true, true);
|
||||
BrowserTestUtils.addContentEventListener(gTestBrowser, "PluginBindingAttached", function() { gNumPluginBindingsAttached++; }, true, null, true);
|
||||
|
||||
await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_bug820497.html");
|
||||
|
||||
|
|
|
@ -9,12 +9,11 @@ var gSecondTestPermissionString = gPluginHost.getPermissionStringForType("applic
|
|||
|
||||
function doOnPageLoad(url, continuation) {
|
||||
gNextTest = continuation;
|
||||
gTestBrowser.addEventListener("load", pageLoad, true);
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
BrowserTestUtils.browserLoaded(gTestBrowser).then(pageLoad);
|
||||
gTestBrowser.loadURI(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);
|
||||
|
@ -63,10 +62,10 @@ function test() {
|
|||
|
||||
// The first test plugin is CtP and the second test plugin is enabled.
|
||||
function testPart1a() {
|
||||
let testElement = gTestBrowser.contentDocument.getElementById("test");
|
||||
let testElement = gTestBrowser.contentDocumentAsCPOW.getElementById("test");
|
||||
let objLoadingContent = testElement.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(!objLoadingContent.activated, "part 1a: Test plugin should not be activated");
|
||||
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA");
|
||||
let secondtest = gTestBrowser.contentDocumentAsCPOW.getElementById("secondtestA");
|
||||
objLoadingContent = secondtest.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(objLoadingContent.activated, "part 1a: Second Test plugin should be activated");
|
||||
|
||||
|
@ -94,11 +93,11 @@ function testPart1b() {
|
|||
|
||||
// Now, the Test plugin should be allowed, and the Test2 plugin should be CtP
|
||||
function testPart2() {
|
||||
let testElement = gTestBrowser.contentDocument.getElementById("test").
|
||||
let testElement = gTestBrowser.contentDocumentAsCPOW.getElementById("test").
|
||||
QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
ok(testElement.activated, "part 2: Test plugin should be activated");
|
||||
|
||||
let secondtest = gTestBrowser.contentDocument.getElementById("secondtestA").
|
||||
let secondtest = gTestBrowser.contentDocumentAsCPOW.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,
|
||||
|
@ -123,13 +122,13 @@ function testPart2() {
|
|||
|
||||
// Now, all the things should be blocked
|
||||
function testPart3() {
|
||||
let testElement = gTestBrowser.contentDocument.getElementById("test").
|
||||
let testElement = gTestBrowser.contentDocumentAsCPOW.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.contentDocument.getElementById("secondtestA").
|
||||
let secondtest = gTestBrowser.contentDocumentAsCPOW.getElementById("secondtestA").
|
||||
QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
|
||||
ok(!secondtest.activated, "part 3: Second Test plugin should not be activated");
|
||||
|
|
|
@ -44,28 +44,6 @@ 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,16 +34,19 @@ async function doTest(parentTabSpec, childTabSpec, testTaskFn, waitForMetaRefres
|
|||
await promiseReloaded;
|
||||
|
||||
// Wait for the script in the page to update the contents of the test div.
|
||||
let testDiv = content.document.getElementById("mctestdiv");
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
let testDiv = gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv");
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() => testDiv.innerHTML == "Mixed Content Blocker disabled");
|
||||
|
||||
// Add the link for the child tab to the page.
|
||||
let mainDiv = content.document.createElement("div");
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
let mainDiv = gBrowser.contentDocumentAsCPOW.createElement("div");
|
||||
// eslint-disable-next-line no-unsanitized/property
|
||||
mainDiv.innerHTML =
|
||||
'<p><a id="linkToOpenInNewTab" href="' + childTabSpec + '">Link</a></p>';
|
||||
content.document.body.appendChild(mainDiv);
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
gBrowser.contentDocumentAsCPOW.body.appendChild(mainDiv);
|
||||
|
||||
// Execute the test in the child tabs with the two methods to open it.
|
||||
for (let openFn of [simulateCtrlClick, simulateContextMenuOpenInTab]) {
|
||||
|
@ -85,14 +88,9 @@ 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 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);
|
||||
return BrowserTestUtils.firstBrowserLoaded(window, true, (browser) => {
|
||||
let tab = gBrowser.getTabForBrowser(browser);
|
||||
return !!tab;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -121,7 +119,8 @@ add_task(async function test_same_origin() {
|
|||
activeLoaded: true, activeBlocked: false, passiveLoaded: false,
|
||||
});
|
||||
|
||||
is(content.document.getElementById("mctestdiv").innerHTML,
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
|
||||
"Mixed Content Blocker disabled", "OK: Executed mixed script");
|
||||
});
|
||||
});
|
||||
|
@ -142,7 +141,8 @@ add_task(async function test_different_origin() {
|
|||
activeLoaded: false, activeBlocked: true, passiveLoaded: false,
|
||||
});
|
||||
|
||||
is(content.document.getElementById("mctestdiv").innerHTML,
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
|
||||
"Mixed Content Blocker enabled", "OK: Blocked mixed script");
|
||||
});
|
||||
});
|
||||
|
@ -163,7 +163,8 @@ add_task(async function test_same_origin_metarefresh_same_origin() {
|
|||
activeLoaded: true, activeBlocked: false, passiveLoaded: false,
|
||||
});
|
||||
|
||||
is(content.document.getElementById("mctestdiv").innerHTML,
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
|
||||
"Mixed Content Blocker disabled", "OK: Executed mixed script");
|
||||
}, true);
|
||||
});
|
||||
|
@ -183,7 +184,8 @@ add_task(async function test_same_origin_metarefresh_different_origin() {
|
|||
activeLoaded: false, activeBlocked: true, passiveLoaded: false,
|
||||
});
|
||||
|
||||
is(content.document.getElementById("mctestdiv").innerHTML,
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
|
||||
"Mixed Content Blocker enabled", "OK: Blocked mixed script");
|
||||
}, true);
|
||||
});
|
||||
|
@ -203,7 +205,8 @@ add_task(async function test_same_origin_302redirect_same_origin() {
|
|||
ok(!gIdentityHandler._identityBox.classList.contains("mixedActiveBlocked"),
|
||||
"OK: Mixed Content is NOT being blocked");
|
||||
|
||||
is(content.document.getElementById("mctestdiv").innerHTML,
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
is(gBrowser.contentDocumentAsCPOW.getElementById("mctestdiv").innerHTML,
|
||||
"Mixed Content Blocker disabled", "OK: Executed mixed script");
|
||||
});
|
||||
});
|
||||
|
@ -223,7 +226,8 @@ add_task(async function test_same_origin_302redirect_different_origin() {
|
|||
activeLoaded: false, activeBlocked: true, passiveLoaded: false,
|
||||
});
|
||||
|
||||
is(content.document.getElementById("mctestdiv").innerHTML,
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
is(gBrowser.contentDocumentAsCPOW.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(() => {
|
||||
gBrowser.selectedBrowser.addEventListener("load", checkResult, true);
|
||||
BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "load", checkResult, true);
|
||||
nextTest();
|
||||
});
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ function nextTest() {
|
|||
}
|
||||
|
||||
if (gCurrentTestIndex == -1) {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", checkResult, true);
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
return;
|
||||
|
@ -123,8 +122,8 @@ function nextTest() {
|
|||
}
|
||||
}
|
||||
|
||||
function checkResult(event) {
|
||||
if (event.target.URL == "about:blank")
|
||||
function checkResult() {
|
||||
if (gBrowser.selectedBrowser.currentURI.spec == "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.contentDocument.hidden);
|
||||
await BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocumentAsCPOW.hidden);
|
||||
let url = "https://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#foo";
|
||||
gURLBar.value = url;
|
||||
gURLBar.select();
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
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.
|
||||
await BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocument.hidden);
|
||||
await BrowserTestUtils.waitForCondition(() => browser.contentDocumentAsCPOW && !browser.contentDocumentAsCPOW.hidden);
|
||||
let errorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser);
|
||||
gURLBar.value = input;
|
||||
gURLBar.select();
|
||||
|
@ -30,9 +31,10 @@ 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.
|
||||
await BrowserTestUtils.waitForCondition(() => !tab.linkedBrowser.contentDocument.hidden);
|
||||
await BrowserTestUtils.waitForCondition(() => browser.contentDocumentAsCPOW && !browser.contentDocumentAsCPOW.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.contentDocument.title.trim().split("|");
|
||||
let title = browser.contentDocumentAsCPOW.title.trim().split("|");
|
||||
|
||||
// check each item in the title and validate it meets expectatations
|
||||
for (let part of title) {
|
||||
|
|
|
@ -162,9 +162,7 @@ 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") {
|
||||
gBrowser.selectedBrowser.addEventListener("load", function(e) {
|
||||
resolve();
|
||||
}, {capture: true, once: true});
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(resolve);
|
||||
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);
|
||||
|
||||
content.history.go(aDirection);
|
||||
gBrowser.contentWindowAsCPOW.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.contentDocument;
|
||||
let doc = gBrowser.selectedBrowser.contentDocumentAsCPOW;
|
||||
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.contentWindow, "test-indexedDB-done");
|
||||
await waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "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.contentWindow, "test-indexedDB-done");
|
||||
await waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "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);
|
||||
|
||||
newTabBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(newTabBrowser).then(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) {
|
||||
aWindow.gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser).then(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.contentDocument.getElementById("searchResetKeepCurrent").click();
|
||||
gBrowser.contentDocumentAsCPOW.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.contentDocument;
|
||||
let doc = gBrowser.contentDocumentAsCPOW;
|
||||
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.contentDocument.getElementById("linkSettingsPage").click();
|
||||
gBrowser.contentDocumentAsCPOW.getElementById("linkSettingsPage").click();
|
||||
await loadPromise;
|
||||
|
||||
checkTelemetryRecords(TELEMETRY_RESULT_ENUM.OPENED_SETTINGS);
|
||||
|
|
|
@ -21,37 +21,56 @@ const SEARCH_ENGINE_DETAILS = [{
|
|||
name: "Google",
|
||||
}];
|
||||
|
||||
function promiseStateChangeURI() {
|
||||
return new Promise(resolve => {
|
||||
async function promiseStateChangeURI() {
|
||||
let promise = BrowserTestUtils.waitForMessage(gBrowser.selectedBrowser.messageManager, "test:onStateChange");
|
||||
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
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) || !webProgress.isTopLevel)
|
||||
if ((flags & docStart) != docStart || !webProgress.isTopLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
|
||||
|
||||
let spec = req.originalURI.spec;
|
||||
if (spec == "about:blank")
|
||||
return;
|
||||
|
||||
gBrowser.removeProgressListener(listener);
|
||||
webProgress.removeProgressListener(listener);
|
||||
|
||||
info("received document start");
|
||||
|
||||
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
|
||||
|
||||
req.cancel(Components.results.NS_ERROR_FAILURE);
|
||||
|
||||
executeSoon(() => {
|
||||
resolve(spec);
|
||||
});
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
gBrowser.addProgressListener(listener);
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress);
|
||||
webProgress.addProgressListener(listener,
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
|
||||
});
|
||||
|
||||
return [promise];
|
||||
}
|
||||
|
||||
function promiseContentSearchReady(browser) {
|
||||
|
@ -172,7 +191,7 @@ async function testSearchEngine(engineDetails) {
|
|||
await test.preTest(tab);
|
||||
}
|
||||
|
||||
let stateChangePromise = promiseStateChangeURI();
|
||||
let [stateChangePromise] = await promiseStateChangeURI();
|
||||
|
||||
await test.run(tab);
|
||||
|
||||
|
|
|
@ -71,37 +71,56 @@ const SEARCH_ENGINE_DETAILS = [{
|
|||
name: "Yahoo",
|
||||
}];
|
||||
|
||||
function promiseStateChangeURI() {
|
||||
return new Promise(resolve => {
|
||||
async function promiseStateChangeURI() {
|
||||
let promise = BrowserTestUtils.waitForMessage(gBrowser.selectedBrowser.messageManager, "test:onStateChange");
|
||||
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
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) || !webProgress.isTopLevel)
|
||||
if ((flags & docStart) != docStart || !webProgress.isTopLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
|
||||
|
||||
let spec = req.originalURI.spec;
|
||||
if (spec == "about:blank")
|
||||
return;
|
||||
|
||||
gBrowser.removeProgressListener(listener);
|
||||
webProgress.removeProgressListener(listener);
|
||||
|
||||
info("received document start");
|
||||
|
||||
Assert.ok(req instanceof Ci.nsIChannel, "req is a channel");
|
||||
|
||||
req.cancel(Components.results.NS_ERROR_FAILURE);
|
||||
|
||||
executeSoon(() => {
|
||||
resolve(spec);
|
||||
});
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
gBrowser.addProgressListener(listener);
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress);
|
||||
webProgress.addProgressListener(listener,
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
|
||||
});
|
||||
|
||||
return [promise];
|
||||
}
|
||||
|
||||
function promiseContentSearchReady(browser) {
|
||||
|
@ -214,7 +233,7 @@ async function testSearchEngine(engineDetails) {
|
|||
await test.preTest(tab);
|
||||
}
|
||||
|
||||
let stateChangePromise = promiseStateChangeURI();
|
||||
let [stateChangePromise] = await promiseStateChangeURI();
|
||||
|
||||
await test.run(tab);
|
||||
|
||||
|
|
|
@ -13,11 +13,13 @@ function test() {
|
|||
|
||||
let loadCount = 0;
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, testURL);
|
||||
tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) {
|
||||
|
||||
let removeFunc;
|
||||
removeFunc = BrowserTestUtils.addContentEventListener(tab.linkedBrowser, "load", function onLoad(aEvent) {
|
||||
// make sure both the page and the frame are loaded
|
||||
if (++loadCount < 2)
|
||||
return;
|
||||
tab.linkedBrowser.removeEventListener("load", onLoad, true);
|
||||
removeFunc();
|
||||
|
||||
// executeSoon to allow the JS to execute on the page
|
||||
executeSoon(function() {
|
||||
|
|
|
@ -4,8 +4,6 @@ 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);
|
||||
|
||||
|
@ -34,7 +32,8 @@ function onPageLoad() {
|
|||
let shell = Cc["@mozilla.org/browser/shell-service;1"].
|
||||
getService(Ci.nsIShellService);
|
||||
|
||||
let image = content.document.images[0];
|
||||
// eslint-disable-next-line mozilla/no-cpows-in-tests
|
||||
let image = gBrowser.contentDocumentAsCPOW.images[0];
|
||||
shell.setDesktopBackground(image, 0, "logo.png");
|
||||
|
||||
setTimeout(function() {
|
||||
|
@ -59,8 +58,8 @@ function onPageLoad() {
|
|||
|
||||
function test() {
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", onPageLoad, true);
|
||||
content.location = "about:logo";
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(onPageLoad, false, "about:logo");
|
||||
gBrowser.loadURI("about:logo");
|
||||
|
||||
waitForExplicitFinish();
|
||||
}
|
||||
|
|
|
@ -121,12 +121,9 @@ function promiseTestPageLoad(url) {
|
|||
return new Promise(resolve => {
|
||||
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function listener() {
|
||||
if (browser.currentURI.spec == "about:blank")
|
||||
return;
|
||||
BrowserTestUtils.browserLoaded(browser, false, (loadurl) => loadurl != "about:blank").then(() => {
|
||||
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);
|
||||
});
|
||||
tab.linkedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
|
||||
(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});
|
||||
});
|
||||
|
||||
content.location = "http://example.com/";
|
||||
gBrowser.selectedBrowser.loadURI("http://example.com/");
|
||||
}
|
||||
|
||||
function getLanguageExceptions() {
|
||||
|
|
|
@ -77,7 +77,7 @@ function test() {
|
|||
Services.prefs.setBoolPref(kShowUIPref, true);
|
||||
let tab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedTab = tab;
|
||||
tab.linkedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
|
||||
TranslationStub.browser = gBrowser.selectedBrowser;
|
||||
registerCleanupFunction(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
|
@ -86,9 +86,9 @@ function test() {
|
|||
run_tests(() => {
|
||||
finish();
|
||||
});
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/plain,test page";
|
||||
gBrowser.selectedBrowser.loadURI("data:text/plain,test page");
|
||||
}
|
||||
|
||||
function checkURLBarIcon(aExpectTranslated = false) {
|
||||
|
|
|
@ -116,13 +116,10 @@ function promiseTestPageLoad(url) {
|
|||
return new Promise(resolve => {
|
||||
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function listener() {
|
||||
if (browser.currentURI.spec == "about:blank")
|
||||
return;
|
||||
BrowserTestUtils.browserLoaded(browser, false, (loadurl) => loadurl != "about:blank").then(() => {
|
||||
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;
|
||||
|
||||
gTestTab.linkedBrowser.addEventListener("load", function() {
|
||||
BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser).then(() => {
|
||||
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(!content.document.querySelector("#onboarding-skip-tour-button"), "should not render the skip button");
|
||||
ok(!gBrowser.contentDocumentAsCPOW.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 = content && content.document;
|
||||
let doc = gBrowser.contentDocumentAsCPOW;
|
||||
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 = content && content.document;
|
||||
let doc = gBrowser.contentDocumentAsCPOW;
|
||||
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 = content && content.document;
|
||||
let doc = gBrowser.contentDocumentAsCPOW;
|
||||
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.contentDocument.getElementById("app"), "App element was found");
|
||||
ok(browser.contentDocumentAsCPOW.getElementById("app"), "App element was found");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -43,6 +43,8 @@ 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, () => {
|
||||
|
@ -51,13 +53,9 @@ decorate_task(
|
|||
});
|
||||
});
|
||||
|
||||
/* eslint-disable mozilla/no-cpows-in-tests */
|
||||
if (gBrowser.contentDocument.readyState !== "complete") {
|
||||
await BrowserTestUtils.waitForEvent(gBrowser.contentWindow, "load");
|
||||
}
|
||||
await loadPromise;
|
||||
|
||||
const location = gBrowser.contentWindow.location.href;
|
||||
/* eslint-enable mozilla/no-cpows-in-tests */
|
||||
const location = gBrowser.currentURI.spec;
|
||||
is(
|
||||
location,
|
||||
"about:preferences#privacy",
|
||||
|
|
|
@ -53,12 +53,7 @@ add_task(async function test_abouthome_simpleQuery() {
|
|||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
info("Setup waiting for AboutHomeLoadSnippetsCompleted.");
|
||||
let promiseAboutHomeLoaded = new Promise(resolve => {
|
||||
tab.linkedBrowser.addEventListener("AboutHomeLoadSnippetsCompleted", function loadListener(event) {
|
||||
tab.linkedBrowser.removeEventListener("AboutHomeLoadSnippetsCompleted", loadListener, true);
|
||||
resolve();
|
||||
}, true, true);
|
||||
});
|
||||
let promiseAboutHomeLoaded = BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, "AboutHomeLoadSnippetsCompleted", true, null, true);
|
||||
|
||||
info("Load about:home.");
|
||||
tab.linkedBrowser.loadURI("about:home");
|
||||
|
@ -105,12 +100,7 @@ add_task(async function test_abouthome_activitystream_simpleQuery() {
|
|||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
|
||||
|
||||
info("Setup waiting for search input to initialise.");
|
||||
let promiseAboutHomeSearchLoaded = new Promise(resolve => {
|
||||
tab.linkedBrowser.addEventListener("ContentSearchClient", function loadListener(event) {
|
||||
tab.linkedBrowser.removeEventListener("ContentSearchClient", loadListener, true);
|
||||
executeSoon(resolve);
|
||||
}, true, true);
|
||||
});
|
||||
let promiseAboutHomeSearchLoaded = BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, "ContentSearchClient", true, null, true).then(() => false);
|
||||
|
||||
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 = helpers.listenOnce(options.browser, "load", true).then(function (ev) {
|
||||
var loaded = BrowserTestUtils.browserLoaded(options.browser).then(function () {
|
||||
var reply = callback.call(null, options);
|
||||
|
||||
return Promise.resolve(reply).catch(function (error) {
|
||||
|
@ -149,7 +149,7 @@ var { helpers, assert } = (function () {
|
|||
});
|
||||
});
|
||||
|
||||
options.browser.contentWindow.location = url;
|
||||
options.browser.loadURI(url);
|
||||
return loaded;
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ function test() {
|
|||
is(workerClient2.isClosed, false, "worker in tab 2 should not be closed");
|
||||
|
||||
executeSoon(() => {
|
||||
tab.linkedBrowser.contentWindow.history.back();
|
||||
tab.linkedBrowser.goBack();
|
||||
});
|
||||
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" ||
|
||||
content.document.querySelectorAll(node.selector).length == 1,
|
||||
gBrowser.contentDocumentAsCPOW.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" ||
|
||||
content.document.querySelectorAll(node.selector).length == 1,
|
||||
gBrowser.contentDocumentAsCPOW.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");
|
||||
|
||||
gBrowser.addEventListener("DOMContentLoaded", function (e) {
|
||||
BrowserTestUtils.waitForContentEvent(e.target.linkedBrowser, "DOMContentLoaded").then(function () {
|
||||
// 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.contentWindow.wrappedJSObject;
|
||||
let debuggee = tab.linkedBrowser.contentWindowAsCPOW.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 = content.document;
|
||||
doc = gBrowser.contentDocumentAsCPOW;
|
||||
node = doc.querySelector("h1");
|
||||
waitForFocus(setupKeyBindingsTest);
|
||||
});
|
||||
|
|
|
@ -83,15 +83,10 @@ function toggleServiceWorkersTestingCheckbox() {
|
|||
}
|
||||
|
||||
function reload() {
|
||||
let deferred = defer();
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
|
||||
gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
|
||||
deferred.resolve();
|
||||
}, true);
|
||||
let promise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
executeInContent("devtools:test:reload", {}, {}, false);
|
||||
return deferred.promise;
|
||||
return promise;
|
||||
}
|
||||
|
||||
function testRegisterSuccesses(data) {
|
||||
|
|
|
@ -88,7 +88,7 @@ const ConsoleObserver = {
|
|||
observe: function (subject, topic, data) {
|
||||
let message = subject.wrappedJSObject.arguments[0];
|
||||
|
||||
if (/Failed propType/.test(message)) {
|
||||
if (message && /Failed propType/.test(message.toString())) {
|
||||
ok(false, message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,5 @@ function* chooseWithInspectElementContextMenu(selector, tab) {
|
|||
}
|
||||
|
||||
function waitForLinkedBrowserEvent(tab, event) {
|
||||
return new Promise(resolve => {
|
||||
tab.linkedBrowser.addEventListener(event, function () {
|
||||
resolve();
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
return BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, event, 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 = waitForPageLoad(tab);
|
||||
let pageLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
||||
|
||||
info("Navigate to the test url and waiting for the page to be loaded.");
|
||||
yield navigateTo(inspector, TEST_URL);
|
||||
|
@ -64,7 +64,3 @@ 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,11 +69,7 @@ add_task(function* () {
|
|||
});
|
||||
|
||||
function waitForLinkedBrowserEvent(tab, event) {
|
||||
return new Promise(resolve => {
|
||||
tab.linkedBrowser.addEventListener(event, function () {
|
||||
resolve();
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
return BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, event, true);
|
||||
}
|
||||
|
||||
function contentReadyState(tab) {
|
||||
|
|
|
@ -9,7 +9,7 @@ add_task(function* () {
|
|||
let newWindow = yield newWindowPromise;
|
||||
|
||||
newWindow.focus();
|
||||
yield once(newWindow.gBrowser, "load", true);
|
||||
yield BrowserTestUtils.browserLoaded(newWindow.gBrowser.selectedBrowser);
|
||||
|
||||
let tab = newWindow.gBrowser.selectedTab;
|
||||
yield openRDM(tab);
|
||||
|
|
|
@ -14,11 +14,11 @@ function test()
|
|||
CloseObserver.init();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,<p>test browser last window closing</p>";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,Scratchpad test for bug 646070 - chrome context preference";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,test context switch in Scratchpad";
|
||||
gBrowser.loadURI("data:text/html,test context switch in Scratchpad");
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
|
@ -49,7 +49,7 @@ function runTests() {
|
|||
ok(!pageResult, "no content.foobarBug636725");
|
||||
},
|
||||
then: function* () {
|
||||
is(content.wrappedJSObject.foobarBug636725, "aloha",
|
||||
is(gBrowser.contentWindowAsCPOW.wrappedJSObject.foobarBug636725, "aloha",
|
||||
"content.foobarBug636725 has been set");
|
||||
}
|
||||
}, {
|
||||
|
|
|
@ -8,12 +8,12 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests, {"state":{"text":""}});
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html, test that exceptions are output as " +
|
||||
"comments correctly in Scratchpad";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests, {"state":{"text":""}});
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test that exceptions are output as " +
|
||||
"comments for 'display' and not sent to the console in Scratchpad";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,test Edit menu updates Scratchpad - bug 699130";
|
||||
gBrowser.loadURI("data:text/html,test Edit menu updates Scratchpad - bug 699130");
|
||||
}
|
||||
|
||||
function runTests()
|
||||
|
|
|
@ -7,11 +7,11 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,test Scratchpad eval function.";
|
||||
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad eval function.");
|
||||
}
|
||||
|
||||
function reportErrorAndQuit(error) {
|
||||
|
|
|
@ -7,11 +7,11 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test run() and display() in Scratchpad";
|
||||
gBrowser.loadURI("data:text/html,<p>test run() and display() in Scratchpad");
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
|
|
|
@ -8,11 +8,11 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(testFalsy);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test falsy display() values in Scratchpad";
|
||||
gBrowser.loadURI("data:text/html,<p>test falsy display() values in Scratchpad");
|
||||
}
|
||||
|
||||
function testFalsy()
|
||||
|
|
|
@ -16,11 +16,11 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test file open and save in Scratchpad";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test the 'Jump to line' feature in Scratchpad";
|
||||
gBrowser.loadURI("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);
|
||||
content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760";
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.loadURI("data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760");
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,initialization test for Scratchpad";
|
||||
gBrowser.loadURI("data:text/html,initialization test for Scratchpad");
|
||||
}
|
||||
|
||||
function runTests()
|
||||
|
|
|
@ -7,11 +7,11 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,<p>test inspect() in Scratchpad</p>";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,<p>test long string in Scratchpad</p>";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test file open and save in Scratchpad";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,test Scratchpad." +
|
||||
"openErrorConsole()";
|
||||
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad." +
|
||||
"openErrorConsole()");
|
||||
}
|
||||
|
||||
function runTests()
|
||||
|
|
|
@ -7,11 +7,11 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
|
||||
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad pretty print.");
|
||||
}
|
||||
|
||||
var gTabsize;
|
||||
|
|
|
@ -7,11 +7,11 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
|
||||
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad pretty print.");
|
||||
}
|
||||
|
||||
function runTests(sw)
|
||||
|
|
|
@ -10,12 +10,12 @@ function test()
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,"
|
||||
+ "test Scratchpad pretty print error goto line.";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(startTest);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test recent files in Scratchpad";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,Scratchpad test for bug 740948";
|
||||
gBrowser.loadURI("data:text/html,Scratchpad test for bug 740948");
|
||||
}
|
||||
|
||||
function runTests()
|
||||
|
@ -54,8 +54,8 @@ function runTests()
|
|||
let browser = gBrowser.selectedBrowser;
|
||||
|
||||
let deferred = defer();
|
||||
browser.addEventListener("DOMWindowCreated", function () {
|
||||
browser.contentWindow.addEventListener("foo", function () {
|
||||
browser.contentWindowAsCPOW.addEventListener("DOMWindowCreated", function () {
|
||||
browser.contentWindowAsCPOW.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.contentWindow.document.body.innerHTML !== "Modified text",
|
||||
ok(browser.contentWindowAsCPOW.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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<title>Bug 1140839</title>" +
|
||||
"<p>test Scratchpad should remember View options";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test that undo get's reset after file load in Scratchpad";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(startTest);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,<p>test reverting to last saved state of" +
|
||||
" a file </p>";
|
||||
gBrowser.loadURI("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);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
|
||||
gBrowser.loadURI("data:text/html;charset=utf8,test Scratchpad pretty print.");
|
||||
}
|
||||
|
||||
function runTests(sw)
|
||||
|
|
|
@ -9,13 +9,13 @@ function test() {
|
|||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
Services.prefs.setIntPref("devtools.editor.tabsize", 5);
|
||||
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
|
||||
content.location = "data:text/html,Scratchpad test for the Tab key, bug 660560";
|
||||
gBrowser.loadURI("data:text/html,Scratchpad test for the Tab key, bug 660560");
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
|
|
|
@ -12,16 +12,16 @@ function test()
|
|||
|
||||
tab1 = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedTab = tab1;
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
tab2 = BrowserTestUtils.addTab(gBrowser);
|
||||
gBrowser.selectedTab = tab2;
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function () {
|
||||
openScratchpad(runTests);
|
||||
}, {capture: true, once: true});
|
||||
content.location = "data:text/html,test context switch in Scratchpad tab 2";
|
||||
}, {capture: true, once: true});
|
||||
});
|
||||
gBrowser.loadURI("data:text/html,test context switch in Scratchpad tab 2");
|
||||
});
|
||||
|
||||
content.location = "data:text/html,test context switch in Scratchpad tab 1";
|
||||
gBrowser.loadURI("data:text/html,test context switch in Scratchpad tab 1");
|
||||
}
|
||||
|
||||
function runTests()
|
||||
|
@ -52,11 +52,11 @@ function runTests()
|
|||
|
||||
sp.setText("window.foosbug653108 = 'aloha';");
|
||||
|
||||
ok(!content.wrappedJSObject.foosbug653108,
|
||||
ok(!gBrowser.contentWindowAsCPOW.wrappedJSObject.foosbug653108,
|
||||
"no content.foosbug653108");
|
||||
|
||||
sp.run().then(function () {
|
||||
is(content.wrappedJSObject.foosbug653108, "aloha",
|
||||
is(gBrowser.contentWindowAsCPOW.wrappedJSObject.foosbug653108, "aloha",
|
||||
"content.foosbug653108 has been set");
|
||||
|
||||
gBrowser.tabContainer.addEventListener("TabSelect", runTests2, true);
|
||||
|
@ -75,17 +75,16 @@ function runTests2() {
|
|||
|
||||
sp.setText("window.foosbug653108 = 'ahoyhoy';");
|
||||
sp.run().then(function () {
|
||||
is(content.wrappedJSObject.foosbug653108, "ahoyhoy",
|
||||
is(gBrowser.contentWindowAsCPOW.wrappedJSObject.foosbug653108, "ahoyhoy",
|
||||
"content.foosbug653108 has been set 2");
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", runTests3, true);
|
||||
content.location = "data:text/html,test context switch in Scratchpad location 2";
|
||||
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(runTests3);
|
||||
gBrowser.loadURI("data:text/html,test context switch in Scratchpad location 2");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function runTests3() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", runTests3, true);
|
||||
// Check that the sandbox is not cached.
|
||||
|
||||
sp.setText("typeof foosbug653108;");
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче