Bug 1443964: Part 1 - Fix most tests that rely on add-on shims. r?mconley
browser_google_behavior.js is the only remaining exception.
MozReview-Commit-ID: GA15P7f0KBv
--- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js
+++ b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js
@@ -5,30 +5,27 @@
function test() {
waitForExplicitFinish();
let tabOne = BrowserTestUtils.addTab(gBrowser, "about:blank");
let tabTwo = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/");
gBrowser.selectedTab = tabTwo;
let browser = gBrowser.getBrowserForTab(tabTwo);
- let onLoad = function() {
- browser.removeEventListener("load", onLoad, true);
-
+ BrowserTestUtils.browserLoaded(browser).then(() => {
gBrowser.showOnlyTheseTabs([tabTwo]);
is(gBrowser.visibleTabs.length, 1, "Only one tab is visible");
let uris = PlacesCommandHook.uniqueCurrentPages;
is(uris.length, 1, "Only one uri is returned");
is(uris[0].uri.spec, tabTwo.linkedBrowser.currentURI.spec, "It's the correct URI");
gBrowser.removeTab(tabOne);
gBrowser.removeTab(tabTwo);
Array.forEach(gBrowser.tabs, function(tab) {
gBrowser.showTab(tab);
});
finish();
- };
- browser.addEventListener("load", onLoad, true);
+ });
}
--- a/devtools/client/jsonview/test/head.js
+++ b/devtools/client/jsonview/test/head.js
@@ -66,23 +66,25 @@ async function addJsonViewTab(url, {
})]);
// Load devtools/shared/frame-script-utils.js
getFrameScript();
let rootDir = getRootDirectory(gTestPath);
// Catch RequireJS errors (usually timeouts)
let error = tabLoaded.then(() => new Promise((resolve, reject) => {
- let {requirejs} = content.wrappedJSObject;
- if (requirejs) {
- requirejs.onError = err => {
- info(err);
- ok(false, "RequireJS error");
- reject(err);
- };
+ if (content) {
+ let {requirejs} = content.wrappedJSObject;
+ if (requirejs) {
+ requirejs.onError = err => {
+ info(err);
+ ok(false, "RequireJS error");
+ reject(err);
+ };
+ }
}
}));
let data = {rootDir, appReadyState, docReadyState};
// eslint-disable-next-line no-shadow
await Promise.race([error, ContentTask.spawn(browser, data, async function (data) {
// Check if there is a JSONView object.
let {JSONView} = content.window.wrappedJSObject;
--- a/dom/html/test/browser_refresh_wyciwyg_url.js
+++ b/dom/html/test/browser_refresh_wyciwyg_url.js
@@ -4,29 +4,38 @@
/*
Test that after using document.write(...), refreshing the document and calling write again,
resulting document.URL does not contain 'wyciwyg' schema
and instead is identical to the original URL.
This testcase is aimed at preventing bug 619092
*/
var testURL = "http://mochi.test:8888/browser/dom/html/test/file_refresh_wyciwyg_url.html";
-let aTab, aBrowser, test_btn;
+let aTab, aBrowser;
function test(){
waitForExplicitFinish();
aTab = BrowserTestUtils.addTab(gBrowser, testURL);
aBrowser = gBrowser.getBrowserForTab(aTab);
BrowserTestUtils.browserLoaded(aBrowser).then(() => {
- is(aBrowser.contentDocument.URL, testURL, "Make sure we start at the correct URL");
+ is(aBrowser.currentURI.spec, testURL, "Make sure we start at the correct URL");
+
+ ContentTask.spawn(aBrowser, null, () => {
+ // test_btn calls document.write() then reloads the document
+ let test_btn = content.document.getElementById("test_btn");
- // test_btn calls document.write() then reloads the document
- test_btn = aBrowser.contentDocument.getElementById("test_btn");
- test_btn.click();
+ addEventListener("load", () => {
+ test_btn.click();
+ }, {once: true, capture: true});
+
+ test_btn.click();
+ });
+
return BrowserTestUtils.browserLoaded(aBrowser);
}).then(() => {
- test_btn.click();
- is(aBrowser.contentDocument.URL, testURL, "Document URL should be identical after reload");
+ return ContentTask.spawn(aBrowser, null, () => content.document.URL);
+ }).then(url => {
+ is(url, testURL, "Document URL should be identical after reload");
gBrowser.removeTab(aTab);
finish();
});
}