mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1588193 - Fix broken tests, r=mccr8
Most of these tests relied on assumptions that were broken by the updated content event helpers (timing, being in a ContentTask, etc). Depends on D51441 Differential Revision: https://phabricator.services.mozilla.com/D51442 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
53846e37ba
commit
449e7a00a5
@ -17,7 +17,10 @@ const TEST_URL = TEST_ROOT + "file_favicon_change_not_in_document.html";
|
||||
* event after its href gets updated later.
|
||||
*/
|
||||
add_task(async function() {
|
||||
let extraTab = (gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser));
|
||||
let extraTab = (gBrowser.selectedTab = BrowserTestUtils.addTab(
|
||||
gBrowser,
|
||||
TEST_ROOT
|
||||
));
|
||||
let domLinkAddedFired = 0;
|
||||
let domLinkChangedFired = 0;
|
||||
const linkAddedHandler = event => domLinkAddedFired++;
|
||||
|
@ -14,7 +14,7 @@ add_task(async function() {
|
||||
"pageshow",
|
||||
true,
|
||||
event => {
|
||||
return content.location.href != "about:blank";
|
||||
return event.target.location != "about:blank";
|
||||
}
|
||||
).then(function pageshowListener() {
|
||||
ok(
|
||||
|
@ -1,6 +1,14 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
|
||||
// Bug 1588193 - BrowserTestUtils.waitForContentEvent now resolves slightly
|
||||
// earlier than before, so it no longer suffices to only wait for a single event
|
||||
// tick before checking if browser.engines has been updated. Instead we use a 1s
|
||||
// timeout, which may cause the test to take more time.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
add_task(async function() {
|
||||
let url =
|
||||
"http://mochi.test:8888/browser/browser/base/content/test/general/discovery.html";
|
||||
@ -73,7 +81,7 @@ async function searchDiscovery() {
|
||||
});
|
||||
|
||||
await promiseLinkAdded;
|
||||
await new Promise(resolve => executeSoon(resolve));
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
if (browser.engines) {
|
||||
info(`Found ${browser.engines.length} engines`);
|
||||
@ -112,7 +120,7 @@ async function searchDiscovery() {
|
||||
});
|
||||
|
||||
await promiseLinkAdded;
|
||||
await new Promise(resolve => executeSoon(resolve));
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
ok(browser.engines, "has engines");
|
||||
is(browser.engines.length, 1, "only one engine");
|
||||
|
@ -3,23 +3,9 @@ var gTestRoot = getRootDirectory(gTestPath).replace(
|
||||
"http://127.0.0.1:8888/"
|
||||
);
|
||||
var gTestBrowser = null;
|
||||
var gNumPluginBindingsAttached = 0;
|
||||
|
||||
function pluginBindingAttached() {
|
||||
gNumPluginBindingsAttached++;
|
||||
if (gNumPluginBindingsAttached != 1) {
|
||||
ok(false, "if we've gotten here, something is quite wrong");
|
||||
}
|
||||
}
|
||||
|
||||
add_task(async function() {
|
||||
registerCleanupFunction(function() {
|
||||
gTestBrowser.removeEventListener(
|
||||
"PluginBindingAttached",
|
||||
pluginBindingAttached,
|
||||
true,
|
||||
true
|
||||
);
|
||||
clearAllPluginPermissions();
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
setTestPluginEnabledState(
|
||||
@ -38,25 +24,20 @@ add_task(async function() {
|
||||
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
|
||||
|
||||
BrowserTestUtils.addContentEventListener(
|
||||
let promisePluginBindingAttached = BrowserTestUtils.waitForContentEvent(
|
||||
gTestBrowser,
|
||||
"PluginBindingAttached",
|
||||
pluginBindingAttached,
|
||||
{ capture: true, wantUntrusted: true }
|
||||
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"
|
||||
gTestRoot + "plugin_bug744745.html"
|
||||
);
|
||||
|
||||
await promiseForCondition(function() {
|
||||
return gNumPluginBindingsAttached == 1;
|
||||
});
|
||||
await promisePluginBindingAttached;
|
||||
|
||||
await ContentTask.spawn(gTestBrowser, {}, async function() {
|
||||
let plugin = content.document.getElementById("test");
|
||||
|
@ -85,7 +85,6 @@ function waitForMessage(aMessage, browser) {
|
||||
checkFn.toSource = function() {
|
||||
return `function checkFn(event) {
|
||||
let message = ${aMessage.toSource()};
|
||||
is(event.data, message, "Received: " + message);
|
||||
if (event.data == message) {
|
||||
return true;
|
||||
}
|
||||
@ -101,7 +100,12 @@ function waitForMessage(aMessage, browser) {
|
||||
/* capture */ true,
|
||||
checkFn,
|
||||
/* wantsUntrusted */ true
|
||||
);
|
||||
).then(() => {
|
||||
// An assertion in checkFn wouldn't be recorded as part of the test, so we
|
||||
// use this assertion to confirm that we've successfully received the
|
||||
// message (we'll only reach this point if that's the case).
|
||||
ok(true, "Received message: " + aMessage);
|
||||
});
|
||||
}
|
||||
|
||||
function dispatchEvent(eventName) {
|
||||
|
@ -107,7 +107,6 @@ function waitForMessage(aMessage, browser) {
|
||||
checkFn.toSource = function() {
|
||||
return `function checkFn(event) {
|
||||
let message = ${aMessage.toSource()};
|
||||
is(event.data, message, "Received: " + message);
|
||||
if (event.data == message) {
|
||||
return true;
|
||||
}
|
||||
@ -123,7 +122,12 @@ function waitForMessage(aMessage, browser) {
|
||||
/* capture */ true,
|
||||
checkFn,
|
||||
/* wantsUntrusted */ true
|
||||
);
|
||||
).then(() => {
|
||||
// An assertion in checkFn wouldn't be recorded as part of the test, so we
|
||||
// use this assertion to confirm that we've successfully received the
|
||||
// message (we'll only reach this point if that's the case).
|
||||
ok(true, "Received message: " + aMessage);
|
||||
});
|
||||
}
|
||||
|
||||
function removePermission(url, permission) {
|
||||
|
@ -202,7 +202,12 @@ function testOnWindow(aTestData) {
|
||||
wp.addProgressListener(progressListener, wp.NOTIFY_CONTENT_BLOCKING);
|
||||
|
||||
await BrowserTestUtils.loadURI(browser, aTestData.url);
|
||||
await BrowserTestUtils.waitForContentEvent(browser, "DOMContentLoaded");
|
||||
await BrowserTestUtils.browserLoaded(
|
||||
browser,
|
||||
false,
|
||||
`http://${aTestData.url}`,
|
||||
true
|
||||
);
|
||||
checkResults(aTestData, expected);
|
||||
win.close();
|
||||
resolve();
|
||||
|
@ -153,22 +153,8 @@ async function expand_addon_element(aManager, aId) {
|
||||
addon.click();
|
||||
}
|
||||
|
||||
function wait_for_page_show(browser) {
|
||||
let promise = new Promise(resolve => {
|
||||
let removeFunc;
|
||||
let listener = () => {
|
||||
removeFunc();
|
||||
resolve();
|
||||
};
|
||||
removeFunc = BrowserTestUtils.addContentEventListener(
|
||||
browser,
|
||||
"pageshow",
|
||||
listener,
|
||||
{},
|
||||
event => event.target.location == "http://example.com/"
|
||||
);
|
||||
});
|
||||
return promise;
|
||||
function wait_for_page_load(browser) {
|
||||
return BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
|
||||
}
|
||||
|
||||
// Tests simple forward and back navigation and that the right heading and
|
||||
@ -400,7 +386,7 @@ add_task(async function test_navigate_back_from_website() {
|
||||
is_in_list(aManager, "addons://list/plugin", false, false);
|
||||
|
||||
BrowserTestUtils.loadURI(gBrowser, "http://example.com/");
|
||||
await wait_for_page_show(gBrowser.selectedBrowser);
|
||||
await wait_for_page_load(gBrowser.selectedBrowser);
|
||||
|
||||
info("Part 2");
|
||||
|
||||
@ -424,7 +410,7 @@ add_task(async function test_navigate_back_from_website() {
|
||||
is_in_list(aManager, "addons://list/plugin", false, true);
|
||||
|
||||
executeSoon(() => go_forward());
|
||||
wait_for_page_show(gBrowser.selectedBrowser).then(() => {
|
||||
wait_for_page_load(gBrowser.selectedBrowser).then(() => {
|
||||
info("Part 4");
|
||||
|
||||
executeSoon(function() {
|
||||
|
Loading…
Reference in New Issue
Block a user