Bug 1374282 - script generated patch to remove Task.jsm calls, r=Mossop.
This commit is contained in:
@@ -8,7 +8,6 @@ const { Ci, Cu } = require("chrome");
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Subprocess.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
const Runtime = require("sdk/system/runtime");
|
||||
const Environment = require("sdk/system/environment").env;
|
||||
@@ -35,11 +34,11 @@ function awaitPromise(promise) {
|
||||
throw value;
|
||||
}
|
||||
|
||||
let readAllData = Task.async(function* (pipe, read, callback) {
|
||||
let readAllData = async function(pipe, read, callback) {
|
||||
let string;
|
||||
while (string = yield read(pipe))
|
||||
while (string = await read(pipe))
|
||||
callback(string);
|
||||
});
|
||||
};
|
||||
|
||||
let write = (pipe, data) => {
|
||||
let buffer = new Uint8Array(Array.from(data, c => c.charCodeAt(0)));
|
||||
@@ -50,7 +49,7 @@ var subprocess = {
|
||||
call: function(options) {
|
||||
var result;
|
||||
|
||||
let procPromise = Task.spawn(function*() {
|
||||
let procPromise = (async function() {
|
||||
let opts = {};
|
||||
|
||||
if (options.mergeStderr) {
|
||||
@@ -62,7 +61,7 @@ var subprocess = {
|
||||
if (options.command instanceof Ci.nsIFile) {
|
||||
opts.command = options.command.path;
|
||||
} else {
|
||||
opts.command = yield Subprocess.pathSearch(options.command);
|
||||
opts.command = await Subprocess.pathSearch(options.command);
|
||||
}
|
||||
|
||||
if (options.workdir) {
|
||||
@@ -87,7 +86,7 @@ var subprocess = {
|
||||
}
|
||||
|
||||
|
||||
let proc = yield Subprocess.call(opts);
|
||||
let proc = await Subprocess.call(opts);
|
||||
|
||||
Object.defineProperty(result, "pid", {
|
||||
value: proc.pid,
|
||||
@@ -131,7 +130,7 @@ var subprocess = {
|
||||
.then(options.done);
|
||||
|
||||
return proc;
|
||||
});
|
||||
})();
|
||||
|
||||
procPromise.catch(e => {
|
||||
if (options.done)
|
||||
|
||||
@@ -238,8 +238,8 @@ function testURL(source, target, canLoad, canLoadWithoutInherit, canCreate, flag
|
||||
(inheritDisallowed ? " without" : " with") + " principal inheritance.");
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
yield kAboutPagesRegistered;
|
||||
add_task(async function() {
|
||||
await kAboutPagesRegistered;
|
||||
let baseFlags = ssm.STANDARD | ssm.DONT_REPORT_ERRORS;
|
||||
for (let [sourceString, targetsAndExpectations] of URLs) {
|
||||
let source;
|
||||
@@ -256,11 +256,11 @@ add_task(function* () {
|
||||
}
|
||||
|
||||
// Now test blob URIs, which we need to do in-content.
|
||||
yield BrowserTestUtils.withNewTab("http://www.example.com/", function* (browser) {
|
||||
yield ContentTask.spawn(
|
||||
await BrowserTestUtils.withNewTab("http://www.example.com/", async function(browser) {
|
||||
await ContentTask.spawn(
|
||||
browser,
|
||||
testURL.toString(),
|
||||
function* (testURLFn) {
|
||||
async function(testURLFn) {
|
||||
// eslint-disable-next-line no-shadow , no-eval
|
||||
let testURL = eval("(" + testURLFn + ")");
|
||||
// eslint-disable-next-line no-shadow
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
let url = getRootDirectory(gTestPath) + "file_bug1206879.html";
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url, true);
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url, true);
|
||||
|
||||
let numLocationChanges = 0;
|
||||
|
||||
@@ -18,11 +18,11 @@ add_task(function*() {
|
||||
listener.resolve = resolve;
|
||||
gBrowser.addTabsProgressListener(listener);
|
||||
});
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function() {
|
||||
await ContentTask.spawn(tab.linkedBrowser, {}, function() {
|
||||
content.frames[0].history.pushState(null, null, "foo");
|
||||
});
|
||||
|
||||
yield locationPromise;
|
||||
await locationPromise;
|
||||
|
||||
gBrowser.removeTab(tab);
|
||||
gBrowser.removeTabsProgressListener(listener);
|
||||
|
||||
@@ -4,32 +4,32 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
add_task(function* runTests() {
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:about");
|
||||
add_task(async function runTests() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:about");
|
||||
|
||||
registerCleanupFunction(function* () {
|
||||
registerCleanupFunction(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
browser.loadURI("about:accounts");
|
||||
let href = yield BrowserTestUtils.browserLoaded(browser);
|
||||
let href = await BrowserTestUtils.browserLoaded(browser);
|
||||
is(href, "about:accounts", "Check about:accounts loaded");
|
||||
|
||||
// Using a dummy onunload listener to disable the bfcache as that can prevent
|
||||
// the test browser load detection mechanism from working.
|
||||
browser.loadURI("data:text/html,<body%20onunload=''><iframe></iframe></body>");
|
||||
href = yield BrowserTestUtils.browserLoaded(browser);
|
||||
href = await BrowserTestUtils.browserLoaded(browser);
|
||||
is(href, "data:text/html,<body%20onunload=''><iframe></iframe></body>",
|
||||
"Check data URL loaded");
|
||||
|
||||
browser.goBack();
|
||||
href = yield BrowserTestUtils.browserLoaded(browser);
|
||||
href = await BrowserTestUtils.browserLoaded(browser);
|
||||
is(href, "about:accounts", "Check we've gone back to about:accounts");
|
||||
|
||||
browser.goForward();
|
||||
href = yield BrowserTestUtils.browserLoaded(browser);
|
||||
href = await BrowserTestUtils.browserLoaded(browser);
|
||||
is(href, "data:text/html,<body%20onunload=''><iframe></iframe></body>",
|
||||
"Check we've gone forward to data URL");
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
add_task(function* test() {
|
||||
add_task(async function test() {
|
||||
const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
|
||||
const uris = [undefined, "about:blank"];
|
||||
|
||||
function checkContentProcess(newBrowser, uri) {
|
||||
return ContentTask.spawn(newBrowser, uri, function* (uri) {
|
||||
return ContentTask.spawn(newBrowser, uri, async function(uri) {
|
||||
var prin = content.document.nodePrincipal;
|
||||
Assert.notEqual(prin, null, "Loaded principal must not be null when adding " + uri);
|
||||
Assert.notEqual(prin, undefined, "Loaded principal must not be undefined when loading " + uri);
|
||||
@@ -16,8 +16,8 @@ add_task(function* test() {
|
||||
}
|
||||
|
||||
for (var uri of uris) {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser }, function* (newBrowser) {
|
||||
yield BrowserTestUtils.loadURI(newBrowser, uri);
|
||||
await BrowserTestUtils.withNewTab({ gBrowser }, async function(newBrowser) {
|
||||
await BrowserTestUtils.loadURI(newBrowser, uri);
|
||||
|
||||
var prin = newBrowser.contentPrincipal;
|
||||
isnot(prin, null, "Forced principal must not be null when loading " + uri);
|
||||
@@ -28,9 +28,9 @@ add_task(function* test() {
|
||||
|
||||
// Belt-and-suspenders e10s check: make sure that the same checks hold
|
||||
// true in the content process.
|
||||
yield checkContentProcess(newBrowser, uri);
|
||||
await checkContentProcess(newBrowser, uri);
|
||||
|
||||
yield BrowserTestUtils.browserLoaded(newBrowser);
|
||||
await BrowserTestUtils.browserLoaded(newBrowser);
|
||||
|
||||
prin = newBrowser.contentPrincipal;
|
||||
isnot(prin, null, "Loaded principal must not be null when adding " + uri);
|
||||
@@ -40,7 +40,7 @@ add_task(function* test() {
|
||||
|
||||
// Belt-and-suspenders e10s check: make sure that the same checks hold
|
||||
// true in the content process.
|
||||
yield checkContentProcess(newBrowser, uri);
|
||||
await checkContentProcess(newBrowser, uri);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
add_task(function* test() {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (newBrowser) {
|
||||
yield ContentTask.spawn(newBrowser, null, function* () {
|
||||
add_task(async function test() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, async function(newBrowser) {
|
||||
await ContentTask.spawn(newBrowser, null, async function() {
|
||||
var prin = content.document.nodePrincipal;
|
||||
Assert.notEqual(prin, null, "Loaded principal must not be null");
|
||||
Assert.notEqual(prin, undefined, "Loaded principal must not be undefined");
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
add_task(function* runTests() {
|
||||
yield setup();
|
||||
add_task(async function runTests() {
|
||||
await setup();
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
// Now that we're set up, initialize our frame script.
|
||||
yield checkListeners("initial", "listeners initialized");
|
||||
await checkListeners("initial", "listeners initialized");
|
||||
|
||||
// Check if all history listeners are always notified.
|
||||
info("# part 1");
|
||||
yield whenPageShown(browser, () => browser.loadURI("http://www.example.com/"));
|
||||
yield checkListeners("newentry", "shistory has a new entry");
|
||||
await whenPageShown(browser, () => browser.loadURI("http://www.example.com/"));
|
||||
await checkListeners("newentry", "shistory has a new entry");
|
||||
ok(browser.canGoBack, "we can go back");
|
||||
|
||||
yield whenPageShown(browser, () => browser.goBack());
|
||||
yield checkListeners("goback", "back to the first shentry");
|
||||
await whenPageShown(browser, () => browser.goBack());
|
||||
await checkListeners("goback", "back to the first shentry");
|
||||
ok(browser.canGoForward, "we can go forward");
|
||||
|
||||
yield whenPageShown(browser, () => browser.goForward());
|
||||
yield checkListeners("goforward", "forward to the second shentry");
|
||||
await whenPageShown(browser, () => browser.goForward());
|
||||
await checkListeners("goforward", "forward to the second shentry");
|
||||
|
||||
yield whenPageShown(browser, () => browser.reload());
|
||||
yield checkListeners("reload", "current shentry reloaded");
|
||||
await whenPageShown(browser, () => browser.reload());
|
||||
await checkListeners("reload", "current shentry reloaded");
|
||||
|
||||
yield whenPageShown(browser, () => browser.gotoIndex(0));
|
||||
yield checkListeners("gotoindex", "back to the first index");
|
||||
await whenPageShown(browser, () => browser.gotoIndex(0));
|
||||
await checkListeners("gotoindex", "back to the first index");
|
||||
|
||||
// Check nsISHistoryInternal.notifyOnHistoryReload
|
||||
info("# part 2");
|
||||
ok((yield notifyReload()), "reloading has not been canceled");
|
||||
yield checkListeners("reload", "saw the reload notification");
|
||||
ok((await notifyReload()), "reloading has not been canceled");
|
||||
await checkListeners("reload", "saw the reload notification");
|
||||
|
||||
// Let the first listener cancel the reload action.
|
||||
info("# part 3");
|
||||
yield resetListeners();
|
||||
yield setListenerRetval(0, false);
|
||||
ok(!(yield notifyReload()), "reloading has been canceled");
|
||||
yield checkListeners("reload", "saw the reload notification");
|
||||
await resetListeners();
|
||||
await setListenerRetval(0, false);
|
||||
ok(!(await notifyReload()), "reloading has been canceled");
|
||||
await checkListeners("reload", "saw the reload notification");
|
||||
|
||||
// Let both listeners cancel the reload action.
|
||||
info("# part 4");
|
||||
yield resetListeners();
|
||||
yield setListenerRetval(1, false);
|
||||
ok(!(yield notifyReload()), "reloading has been canceled");
|
||||
yield checkListeners("reload", "saw the reload notification");
|
||||
await resetListeners();
|
||||
await setListenerRetval(1, false);
|
||||
ok(!(await notifyReload()), "reloading has been canceled");
|
||||
await checkListeners("reload", "saw the reload notification");
|
||||
|
||||
// Let the second listener cancel the reload action.
|
||||
info("# part 5");
|
||||
yield resetListeners();
|
||||
yield setListenerRetval(0, true);
|
||||
ok(!(yield notifyReload()), "reloading has been canceled");
|
||||
yield checkListeners("reload", "saw the reload notification");
|
||||
await resetListeners();
|
||||
await setListenerRetval(0, true);
|
||||
ok(!(await notifyReload()), "reloading has been canceled");
|
||||
await checkListeners("reload", "saw the reload notification");
|
||||
});
|
||||
|
||||
function listenOnce(message, arg = {}) {
|
||||
@@ -91,8 +91,8 @@ function setup() {
|
||||
"http://mochi.test:8888")
|
||||
.then(function (tab) {
|
||||
let browser = tab.linkedBrowser;
|
||||
registerCleanupFunction(function* () {
|
||||
yield listenOnce("bug422543:cleanup");
|
||||
registerCleanupFunction(async function() {
|
||||
await listenOnce("bug422543:cleanup");
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=503832
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
var pagetitle = "Page Title for Bug 503832";
|
||||
var pageurl = "http://mochi.test:8888/browser/docshell/test/browser/file_bug503832.html";
|
||||
var fragmenturl = "http://mochi.test:8888/browser/docshell/test/browser/file_bug503832.html#firefox";
|
||||
@@ -76,12 +76,12 @@ add_task(function* () {
|
||||
ok(!info, "The fragment test page must not have been visited already.");
|
||||
|
||||
// Now open the test page in a new tab
|
||||
yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageurl);
|
||||
await BrowserTestUtils.openNewForegroundTab(gBrowser, pageurl);
|
||||
|
||||
// Now that the page is loaded, click on fragment link
|
||||
yield BrowserTestUtils.synthesizeMouseAtCenter("#firefox-link", {},
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter("#firefox-link", {},
|
||||
gBrowser.selectedBrowser);
|
||||
yield fragmentPromise;
|
||||
await fragmentPromise;
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_task(function* test() {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "http://example.com" }, function* (browser) {
|
||||
add_task(async function test() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "http://example.com" }, async function(browser) {
|
||||
let numLocationChanges = 0;
|
||||
|
||||
let listener = {
|
||||
@@ -11,13 +11,13 @@ add_task(function* test() {
|
||||
|
||||
gBrowser.addTabsProgressListener(listener);
|
||||
|
||||
yield ContentTask.spawn(browser, null, function() {
|
||||
await ContentTask.spawn(browser, null, function() {
|
||||
// pushState to a new URL (http://example.com/foo"). This should trigger
|
||||
// exactly one LocationChange event.
|
||||
content.history.pushState(null, null, "foo");
|
||||
});
|
||||
|
||||
yield Promise.resolve();
|
||||
await Promise.resolve();
|
||||
|
||||
gBrowser.removeTabsProgressListener(listener);
|
||||
is(numLocationChanges, 1,
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
* SHEntry.
|
||||
**/
|
||||
|
||||
add_task(function* test() {
|
||||
add_task(async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "http://example.com" },
|
||||
function* (browser) {
|
||||
yield ContentTask.spawn(browser, null, function* () {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "http://example.com" },
|
||||
async function(browser) {
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
let cw = content;
|
||||
let oldTitle = cw.document.title;
|
||||
ok(oldTitle, 'Content window should initially have a title.');
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
const URL = "http://mochi.test:8888/browser/docshell/test/browser/file_bug670318.html";
|
||||
|
||||
add_task(function* test() {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" },
|
||||
function* (browser) {
|
||||
yield ContentTask.spawn(browser, URL, function* (URL) {
|
||||
add_task(async function test() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" },
|
||||
async function(browser) {
|
||||
await ContentTask.spawn(browser, URL, async function(URL) {
|
||||
let history = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
|
||||
let count = 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ add_task(function* test() {
|
||||
content._testListener = listener;
|
||||
content.location = URL;
|
||||
|
||||
yield testDone.promise;
|
||||
await testDone.promise;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* clicking a link within that view-source page is not blocked by security checks.
|
||||
*/
|
||||
|
||||
add_task(function* test_click_link_within_view_source() {
|
||||
add_task(async function test_click_link_within_view_source() {
|
||||
let TEST_FILE = "file_click_link_within_view_source.html";
|
||||
let TEST_FILE_URI = getChromeDir(getResolvedURI(gTestPath));
|
||||
TEST_FILE_URI.append(TEST_FILE);
|
||||
@@ -18,7 +18,7 @@ add_task(function* test_click_link_within_view_source() {
|
||||
DUMMY_FILE_URI.append(DUMMY_FILE);
|
||||
DUMMY_FILE_URI = Services.io.newFileURI(DUMMY_FILE_URI).spec;
|
||||
|
||||
yield BrowserTestUtils.withNewTab(TEST_FILE_URI, function*(aBrowser) {
|
||||
await BrowserTestUtils.withNewTab(TEST_FILE_URI, async function(aBrowser) {
|
||||
let tabSpec = gBrowser.selectedBrowser.currentURI.spec;
|
||||
info("loading: " + tabSpec);
|
||||
ok(tabSpec.startsWith("file://") && tabSpec.endsWith(TEST_FILE),
|
||||
@@ -28,7 +28,7 @@ add_task(function* test_click_link_within_view_source() {
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser);
|
||||
document.getElementById("View:PageSource").doCommand();
|
||||
|
||||
let tab = yield tabPromise;
|
||||
let tab = await tabPromise;
|
||||
tabSpec = gBrowser.selectedBrowser.currentURI.spec;
|
||||
info("loading: " + tabSpec);
|
||||
ok(tabSpec.startsWith("view-source:file://") && tabSpec.endsWith(TEST_FILE),
|
||||
@@ -36,9 +36,9 @@ add_task(function* test_click_link_within_view_source() {
|
||||
|
||||
info("click testlink within view-source page");
|
||||
let loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, url => url.endsWith("dummy_page.html"));
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
|
||||
if (content.document.readyState != "complete") {
|
||||
yield ContentTaskUtils.waitForEvent(content.document, "readystatechange", false, () =>
|
||||
await ContentTaskUtils.waitForEvent(content.document, "readystatechange", false, () =>
|
||||
content.document.readyState == "complete");
|
||||
}
|
||||
// document.getElementById() does not work on a view-source page, hence we use document.links
|
||||
@@ -48,13 +48,13 @@ add_task(function* test_click_link_within_view_source() {
|
||||
myLink.click();
|
||||
});
|
||||
|
||||
yield loadPromise;
|
||||
await loadPromise;
|
||||
|
||||
tabSpec = gBrowser.selectedBrowser.currentURI.spec;
|
||||
info("loading: " + tabSpec);
|
||||
ok(tabSpec.startsWith("view-source:file://") && tabSpec.endsWith(DUMMY_FILE),
|
||||
"loading view-source of html succeeded");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_task(function* () {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.groupedhistory.enabled", true]]
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ add_task(function* () {
|
||||
!tab.linkedBrowser.frameLoader.isDead;
|
||||
}
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, function* (browser1) {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, async function(browser1) {
|
||||
// Set up the grouped SHEntry setup
|
||||
let tab2 = gBrowser.loadOneTab("data:text/html,b", {
|
||||
referrerPolicy: Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
|
||||
@@ -28,25 +28,25 @@ add_task(function* () {
|
||||
isPrerendered: true,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
});
|
||||
yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
|
||||
browser1.frameLoader.appendPartialSHistoryAndSwap(tab2.linkedBrowser.frameLoader);
|
||||
yield awaitProcessChange(browser1);
|
||||
await awaitProcessChange(browser1);
|
||||
ok(isAlive(tab2));
|
||||
|
||||
// Load some URIs and make sure that we lose the old process once we are 3 history entries away.
|
||||
browser1.loadURI("data:text/html,c", null, null);
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
await BrowserTestUtils.browserLoaded(browser1);
|
||||
ok(isAlive(tab2), "frameloader should still be alive");
|
||||
browser1.loadURI("data:text/html,d", null, null);
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
await BrowserTestUtils.browserLoaded(browser1);
|
||||
ok(isAlive(tab2), "frameloader should still be alive");
|
||||
browser1.loadURI("data:text/html,e", null, null);
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
await BrowserTestUtils.browserLoaded(browser1);
|
||||
ok(isAlive(tab2), "frameloader should still be alive");
|
||||
|
||||
// The 4th navigation should kill the frameloader
|
||||
browser1.loadURI("data:text/html,f", null, null);
|
||||
yield new Promise(resolve => {
|
||||
await new Promise(resolve => {
|
||||
tab2.addEventListener("TabClose", function() {
|
||||
ok(true, "The tab is being closed!\n");
|
||||
resolve();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_task(function* () {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.groupedhistory.enabled", true]]
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ add_task(function* () {
|
||||
});
|
||||
}
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, function* (browser1) {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, async function(browser1) {
|
||||
// Set up the grouped SHEntry setup
|
||||
let tab2 = gBrowser.loadOneTab("data:text/html,b", {
|
||||
referrerPolicy: Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
|
||||
@@ -32,14 +32,14 @@ add_task(function* () {
|
||||
isPrerendered: true,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
});
|
||||
yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
|
||||
browser1.frameLoader.appendPartialSHistoryAndSwap(tab2.linkedBrowser.frameLoader);
|
||||
yield awaitProcessChange(browser1);
|
||||
await awaitProcessChange(browser1);
|
||||
|
||||
// Load a URI which will involve loading in the parent process
|
||||
let tabClose = awaitTabClose(tab2);
|
||||
browser1.loadURI("about:config", Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
await BrowserTestUtils.browserLoaded(browser1);
|
||||
let docshell = browser1.frameLoader.docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
ok(docshell, "The browser should be loaded in the chrome process");
|
||||
is(docshell.canGoForward, false, "canGoForward is correct");
|
||||
@@ -47,6 +47,6 @@ add_task(function* () {
|
||||
is(docshell.sessionHistory.count, 3, "Count is correct");
|
||||
is(browser1.frameLoader.groupedSHistory, null,
|
||||
"browser1's session history is now complete");
|
||||
yield tabClose;
|
||||
await tabClose;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_task(function* () {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.groupedhistory.enabled", true],
|
||||
["dom.ipc.processCount", 1]]
|
||||
});
|
||||
@@ -14,7 +14,7 @@ add_task(function* () {
|
||||
});
|
||||
}
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, function* (browser1) {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, async function(browser1) {
|
||||
// Set up the grouped SHEntry setup
|
||||
let tab2 = gBrowser.loadOneTab("data:text/html,b", {
|
||||
referrerPolicy: Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
|
||||
@@ -23,16 +23,16 @@ add_task(function* () {
|
||||
isPrerendered: true,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
});
|
||||
yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
|
||||
browser1.frameLoader.appendPartialSHistoryAndSwap(tab2.linkedBrowser.frameLoader);
|
||||
yield awaitProcessChange(browser1);
|
||||
await awaitProcessChange(browser1);
|
||||
|
||||
// Close tab2 such that the back frameloader is dead
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
yield BrowserTestUtils.waitForCondition(() => browser1.canGoBack);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.waitForCondition(() => browser1.canGoBack);
|
||||
browser1.goBack();
|
||||
yield BrowserTestUtils.browserLoaded(browser1);
|
||||
yield ContentTask.spawn(browser1, null, function() {
|
||||
await BrowserTestUtils.browserLoaded(browser1);
|
||||
await ContentTask.spawn(browser1, null, function() {
|
||||
is(content.window.location + "", "data:text/html,a");
|
||||
let webNav = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation);
|
||||
|
||||
@@ -4,9 +4,9 @@ const TEST_PATH = getRootDirectory(gTestPath).replace("chrome://mochitests/conte
|
||||
const HTML_URI = TEST_PATH + "dummy_page.html";
|
||||
const VIEW_SRC_URI = "view-source:" + HTML_URI;
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
info("load baseline html in new tab");
|
||||
yield BrowserTestUtils.withNewTab(HTML_URI, function*(aBrowser) {
|
||||
await BrowserTestUtils.withNewTab(HTML_URI, async function(aBrowser) {
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, HTML_URI,
|
||||
"sanity check to make sure html loaded");
|
||||
|
||||
@@ -14,21 +14,21 @@ add_task(function*() {
|
||||
let vSrcCtxtMenu = document.getElementById("contentAreaContextMenu");
|
||||
let popupPromise = BrowserTestUtils.waitForEvent(vSrcCtxtMenu, "popupshown");
|
||||
BrowserTestUtils.synthesizeMouseAtCenter("body", { type: "contextmenu", button: 2 }, aBrowser);
|
||||
yield popupPromise;
|
||||
await popupPromise;
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, VIEW_SRC_URI);
|
||||
let vSrcItem = vSrcCtxtMenu.getElementsByAttribute("id", "context-viewsource")[0];
|
||||
vSrcItem.click();
|
||||
vSrcCtxtMenu.hidePopup();
|
||||
let tab = yield tabPromise;
|
||||
let tab = await tabPromise;
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, VIEW_SRC_URI,
|
||||
"loading view-source of html succeeded");
|
||||
|
||||
info ("load html file again before going .back()");
|
||||
let loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, HTML_URI);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, HTML_URI, HTML_URI => {
|
||||
await ContentTask.spawn(tab.linkedBrowser, HTML_URI, HTML_URI => {
|
||||
content.document.location = HTML_URI;
|
||||
});
|
||||
yield loadPromise;
|
||||
await loadPromise;
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, HTML_URI,
|
||||
"loading html another time succeeded");
|
||||
|
||||
@@ -36,15 +36,15 @@ add_task(function*() {
|
||||
let backCtxtMenu = document.getElementById("contentAreaContextMenu");
|
||||
popupPromise = BrowserTestUtils.waitForEvent(backCtxtMenu, "popupshown");
|
||||
BrowserTestUtils.synthesizeMouseAtCenter("body", { type: "contextmenu", button: 2 }, aBrowser);
|
||||
yield popupPromise;
|
||||
await popupPromise;
|
||||
loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, VIEW_SRC_URI);
|
||||
let backItem = backCtxtMenu.getElementsByAttribute("id", "context-back")[0];
|
||||
backItem.click();
|
||||
backCtxtMenu.hidePopup();
|
||||
yield loadPromise;
|
||||
await loadPromise;
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, VIEW_SRC_URI,
|
||||
"clicking .back() to view-source of html succeeded");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
add_task(function* test_multiple_pushState() {
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
add_task(async function test_multiple_pushState() {
|
||||
await BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: "http://example.org/browser/docshell/test/browser/file_multiple_pushState.html",
|
||||
}, function* (browser) {
|
||||
}, async function(browser) {
|
||||
const kExpected = "http://example.org/bar/ABC/DEF?key=baz";
|
||||
|
||||
let contentLocation = yield ContentTask.spawn(browser, null, function* () {
|
||||
let contentLocation = await ContentTask.spawn(browser, null, async function() {
|
||||
return content.document.location.href;
|
||||
});
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
const URI = "data:text/html;charset=utf-8,<iframe id='test-iframe'></iframe>";
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: URI }, function* (browser) {
|
||||
yield ContentTask.spawn(browser, null, test_body);
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: URI }, async function(browser) {
|
||||
await ContentTask.spawn(browser, null, test_body);
|
||||
});
|
||||
});
|
||||
|
||||
function* test_body() {
|
||||
async function test_body() {
|
||||
let docshell = docShell;
|
||||
|
||||
is(docshell.touchEventsOverride, Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_NONE,
|
||||
@@ -39,7 +39,7 @@ function* test_body() {
|
||||
"Newly created frames should use the new touchEventsOverride flag");
|
||||
|
||||
newFrameWin.location.reload();
|
||||
yield ContentTaskUtils.waitForEvent(newFrameWin, "load");
|
||||
await ContentTaskUtils.waitForEvent(newFrameWin, "load");
|
||||
|
||||
docshell = newFrameWin.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
const URL = "data:text/html;charset=utf-8,Test page";
|
||||
|
||||
add_task(function* () {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: URL },
|
||||
function* (browser) {
|
||||
yield ContentTask.spawn(browser, null, function() {
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: URL },
|
||||
async function(browser) {
|
||||
await ContentTask.spawn(browser, null, function() {
|
||||
ok("recordProfileTimelineMarkers" in docShell,
|
||||
"The recordProfileTimelineMarkers attribute exists");
|
||||
ok("popProfileTimelineMarkers" in docShell,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
const URL = "data:text/html;charset=utf-8,<iframe id='test-iframe'></iframe>";
|
||||
|
||||
// Test that the docShell UA emulation works
|
||||
function* contentTask() {
|
||||
async function contentTask() {
|
||||
let docshell = docShell;
|
||||
is(docshell.customUserAgent, "", "There should initially be no customUserAgent");
|
||||
|
||||
@@ -23,14 +23,14 @@ function* contentTask() {
|
||||
is(newFrameWin.navigator.userAgent, "foo", "Newly created frames should use the new UA");
|
||||
|
||||
newFrameWin.location.reload();
|
||||
yield ContentTaskUtils.waitForEvent(newFrameWin, "load");
|
||||
await ContentTaskUtils.waitForEvent(newFrameWin, "load");
|
||||
|
||||
is(newFrameWin.navigator.userAgent, "foo", "New UA should persist across reloads");
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: URL },
|
||||
function* (browser) {
|
||||
yield ContentTask.spawn(browser, null, contentTask);
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: URL },
|
||||
async function(browser) {
|
||||
await ContentTask.spawn(browser, null, contentTask);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
const REDIRECTURL = "http://www.example.com/browser/docshell/test/browser/redirect_to_example.sjs"
|
||||
|
||||
add_task(function* () {
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
add_task(async function() {
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
gURLBar.value = REDIRECTURL;
|
||||
gURLBar.select();
|
||||
let errorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser);
|
||||
EventUtils.sendKey("return");
|
||||
yield errorPageLoaded;
|
||||
let [contentURL, originalURL] = yield ContentTask.spawn(tab.linkedBrowser, null, () => {
|
||||
await errorPageLoaded;
|
||||
let [contentURL, originalURL] = await ContentTask.spawn(tab.linkedBrowser, null, () => {
|
||||
return [
|
||||
content.document.documentURI,
|
||||
content.document.mozDocumentURIIfNotForErrorPages.spec,
|
||||
@@ -20,5 +20,5 @@ add_task(function* () {
|
||||
originalURL = new URL(originalURL);
|
||||
is(originalURL.host, "example", "Should be an error for http://example, not http://www.example.com/");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
const kSearchEngineID = "browser_urifixup_search_engine";
|
||||
const kSearchEngineURL = "http://example.com/?search={searchTerms}";
|
||||
|
||||
add_task(function* setup() {
|
||||
add_task(async function setup() {
|
||||
// Add a new fake search engine.
|
||||
Services.search.addEngineWithDetails(kSearchEngineID, "", "", "", "get",
|
||||
kSearchEngineURL);
|
||||
@@ -27,17 +27,17 @@ add_task(function* setup() {
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* test() {
|
||||
add_task(async function test() {
|
||||
for (let searchParams of ["foo bar", "brokenprotocol:somethingelse"]) {
|
||||
// Add a new blank tab.
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
// Enter search terms and start a search.
|
||||
gURLBar.value = searchParams;
|
||||
gURLBar.focus();
|
||||
EventUtils.synthesizeKey("VK_RETURN", {});
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
// Check that we arrived at the correct URL.
|
||||
let escapedParams = encodeURIComponent(searchParams).replace("%20", "+");
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// timeline tests.
|
||||
|
||||
var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
var { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
|
||||
var { Promise } = Cu.import('resource://gre/modules/Promise.jsm', {});
|
||||
|
||||
Cu.import("resource://gre/modules/Timer.jsm");
|
||||
@@ -50,7 +49,7 @@ this.finish = function() {
|
||||
* as an argument and checks the results of the test.
|
||||
*/
|
||||
this.timelineContentTest = function(tests) {
|
||||
Task.spawn(function*() {
|
||||
(async function() {
|
||||
let docShell = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell);
|
||||
@@ -69,7 +68,7 @@ this.timelineContentTest = function(tests) {
|
||||
let onMarkers = timelineWaitForMarkers(docShell, searchFor);
|
||||
setup(docShell);
|
||||
info("Waiting for new markers on the docShell");
|
||||
let markers = yield onMarkers;
|
||||
let markers = await onMarkers;
|
||||
|
||||
// Cycle collection markers are non-deterministic, and none of these tests
|
||||
// expect them to show up.
|
||||
@@ -82,7 +81,7 @@ this.timelineContentTest = function(tests) {
|
||||
info("Stop recording");
|
||||
docShell.recordProfileTimelineMarkers = false;
|
||||
finish();
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
function timelineWaitForMarkers(docshell, searchFor) {
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
*/
|
||||
function makeTimelineTest(frameScriptName, url) {
|
||||
info("in timelineTest");
|
||||
return Task.async(function*() {
|
||||
return async function() {
|
||||
info("in in timelineTest");
|
||||
waitForExplicitFinish();
|
||||
|
||||
yield timelineTestOpenUrl(url);
|
||||
await timelineTestOpenUrl(url);
|
||||
|
||||
const here = "chrome://mochitests/content/browser/docshell/test/browser/";
|
||||
|
||||
@@ -34,7 +34,7 @@ function makeTimelineTest(frameScriptName, url) {
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/* Open a URL for a timeline test. */
|
||||
|
||||
@@ -27,8 +27,8 @@ function oneShotListener(aElem, aType, aCallback) {
|
||||
}
|
||||
|
||||
function waitForPageshow(aBrowser, callback) {
|
||||
return ContentTask.spawn(aBrowser, null, function* () {
|
||||
yield ContentTaskUtils.waitForEvent(this, "pageshow");
|
||||
return ContentTask.spawn(aBrowser, null, async function() {
|
||||
await ContentTaskUtils.waitForEvent(this, "pageshow");
|
||||
}).then(callback);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ function step3() {
|
||||
|
||||
// Tab 2's window _and_ its iframes should be inactive
|
||||
ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
|
||||
ContentTask.spawn(ctx.tab2Browser, null, function* () {
|
||||
ContentTask.spawn(ctx.tab2Browser, null, async function() {
|
||||
Assert.equal(content.frames.length, 2, "Tab 2 should have 2 iframes");
|
||||
for (var i = 0; i < content.frames.length; i++) {
|
||||
info("step 3, frame " + i + " info: " + content.frames[i].location);
|
||||
@@ -113,7 +113,7 @@ function step3() {
|
||||
|
||||
function step4() {
|
||||
function checkTab2Active(expected) {
|
||||
return ContentTask.spawn(ctx.tab2Browser, expected, function* (expected) {
|
||||
return ContentTask.spawn(ctx.tab2Browser, expected, async function(expected) {
|
||||
function isActive(aWindow) {
|
||||
var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
@@ -163,7 +163,7 @@ function step5() {
|
||||
ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
|
||||
ok(!ctx.tab1Browser.docShellIsActive, "Tab 1 should be inactive");
|
||||
ok(ctx.tab2Browser.docShellIsActive, "Tab 2 should be active");
|
||||
ContentTask.spawn(ctx.tab2Browser, null, function* () {
|
||||
ContentTask.spawn(ctx.tab2Browser, null, async function() {
|
||||
for (var i = 0; i < content.frames.length; i++) {
|
||||
let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
@@ -189,7 +189,7 @@ function step6() {
|
||||
// Check everything
|
||||
ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
|
||||
ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active");
|
||||
ContentTask.spawn(ctx.tab1Browser, null, function* () {
|
||||
ContentTask.spawn(ctx.tab1Browser, null, async function() {
|
||||
function isActive(aWindow) {
|
||||
var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
@@ -202,7 +202,7 @@ function step6() {
|
||||
Assert.ok(isActive(content.frames[1]), "Tab1 iframe 1 should be active");
|
||||
}).then(() => {
|
||||
ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
|
||||
return ContentTask.spawn(ctx.tab2Browser, null, function* () {
|
||||
return ContentTask.spawn(ctx.tab2Browser, null, async function() {
|
||||
for (var i = 0; i < content.frames.length; i++) {
|
||||
let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
@@ -221,7 +221,7 @@ function step6() {
|
||||
function step7() {
|
||||
function checkBrowser(browser, tabNum, active) {
|
||||
return ContentTask.spawn(browser, { tabNum, active },
|
||||
function* ({ tabNum, active }) {
|
||||
async function({ tabNum, active }) {
|
||||
function isActive(aWindow) {
|
||||
var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
|
||||
@@ -6,10 +6,10 @@ const CHROME_REMOTE_WINDOW = Ci.nsIWebBrowserChrome.CHROME_REMOTE_WINDOW;
|
||||
* Tests that when we open new browser windows from content they
|
||||
* get the full browser chrome.
|
||||
*/
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
// Make sure that the window.open call will open a new
|
||||
// window instead of a new tab.
|
||||
yield new Promise(resolve => {
|
||||
await new Promise(resolve => {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["browser.link.open_newwindow", 2],
|
||||
@@ -17,13 +17,13 @@ add_task(function* () {
|
||||
}, resolve);
|
||||
});
|
||||
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
await BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: TEST_PAGE
|
||||
}, function*(browser) {
|
||||
}, async function(browser) {
|
||||
let openedPromise = BrowserTestUtils.waitForNewWindow();
|
||||
BrowserTestUtils.synthesizeMouse("a", 0, 0, {}, browser);
|
||||
let win = yield openedPromise;
|
||||
let win = await openedPromise;
|
||||
|
||||
let chromeFlags = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
|
||||
@@ -5,7 +5,7 @@ const {utils: Cu} = Components;
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
let webNav = Services.appShell.createWindowlessBrowser(false);
|
||||
|
||||
let loadContext = webNav.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
@@ -40,7 +40,7 @@ add_task(function*() {
|
||||
webNav.loadURI("data:text/html,", webNav.LOAD_FLAGS_NONE, null, null, null);
|
||||
|
||||
// Return to the event loop so the load can begin.
|
||||
yield new Promise(do_execute_soon);
|
||||
await new Promise(do_execute_soon);
|
||||
|
||||
// This causes a failed assertion rather than an exception on debug
|
||||
// builds.
|
||||
|
||||
@@ -80,84 +80,84 @@ function add_task_if_omta_enabled(test) {
|
||||
// We need to wait for all paints before running tests to avoid contaminations
|
||||
// from styling of this document itself.
|
||||
waitForAllPaints(function() {
|
||||
add_task(function* restyling_for_main_thread_animations() {
|
||||
add_task(async function restyling_for_main_thread_animations() {
|
||||
var div = addDiv(null, { style: 'animation: background-color 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(!animation.isRunningOnCompositor);
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 5,
|
||||
'CSS animations running on the main-thread should update style ' +
|
||||
'on the main thread');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_for_compositor_animations() {
|
||||
add_task_if_omta_enabled(async function no_restyling_for_compositor_animations() {
|
||||
var div = addDiv(null, { style: 'animation: opacity 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor);
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'CSS animations running on the compositor should not update style ' +
|
||||
'on the main thread');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_for_compositor_transitions() {
|
||||
add_task_if_omta_enabled(async function no_restyling_for_compositor_transitions() {
|
||||
var div = addDiv(null, { style: 'transition: opacity 100s; opacity: 0' });
|
||||
getComputedStyle(div).opacity;
|
||||
div.style.opacity = 1;
|
||||
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor);
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'CSS transitions running on the compositor should not update style ' +
|
||||
'on the main thread');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_when_animation_duration_is_changed() {
|
||||
add_task_if_omta_enabled(async function no_restyling_when_animation_duration_is_changed() {
|
||||
var div = addDiv(null, { style: 'animation: opacity 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor);
|
||||
|
||||
div.animationDuration = '200s';
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Animations running on the compositor should not update style ' +
|
||||
'on the main thread');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* only_one_restyling_after_finish_is_called() {
|
||||
add_task_if_omta_enabled(async function only_one_restyling_after_finish_is_called() {
|
||||
var div = addDiv(null, { style: 'animation: opacity 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor);
|
||||
|
||||
animation.finish();
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 1,
|
||||
'Animations running on the compositor should only update style ' +
|
||||
'once after finish() is called');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_mouse_movement_on_finished_transition() {
|
||||
add_task(async function no_restyling_mouse_movement_on_finished_transition() {
|
||||
var div = addDiv(null, { style: 'transition: opacity 1ms; opacity: 0' });
|
||||
getComputedStyle(div).opacity;
|
||||
div.style.opacity = 1;
|
||||
@@ -165,11 +165,11 @@ waitForAllPaints(function() {
|
||||
var animation = div.getAnimations()[0];
|
||||
var initialRect = div.getBoundingClientRect();
|
||||
|
||||
yield animation.finished;
|
||||
await animation.finished;
|
||||
|
||||
var mouseX = initialRect.left + initialRect.width / 2;
|
||||
var mouseY = initialRect.top + initialRect.height / 2;
|
||||
var markers = yield observeStyling(5, function() {
|
||||
var markers = await observeStyling(5, function() {
|
||||
// We can't use synthesizeMouse here since synthesizeMouse causes
|
||||
// layout flush.
|
||||
synthesizeMouseAtPoint(mouseX++, mouseY++,
|
||||
@@ -179,20 +179,20 @@ waitForAllPaints(function() {
|
||||
is(markers.length, 0,
|
||||
'Bug 1219236: Finished transitions should never cause restyles ' +
|
||||
'when mouse is moved on the animations');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_mouse_movement_on_finished_animation() {
|
||||
add_task(async function no_restyling_mouse_movement_on_finished_animation() {
|
||||
var div = addDiv(null, { style: 'animation: opacity 1ms' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
var initialRect = div.getBoundingClientRect();
|
||||
|
||||
yield animation.finished;
|
||||
await animation.finished;
|
||||
|
||||
var mouseX = initialRect.left + initialRect.width / 2;
|
||||
var mouseY = initialRect.top + initialRect.height / 2;
|
||||
var markers = yield observeStyling(5, function() {
|
||||
var markers = await observeStyling(5, function() {
|
||||
// We can't use synthesizeMouse here since synthesizeMouse causes
|
||||
// layout flush.
|
||||
synthesizeMouseAtPoint(mouseX++, mouseY++,
|
||||
@@ -202,10 +202,10 @@ waitForAllPaints(function() {
|
||||
is(markers.length, 0,
|
||||
'Bug 1219236: Finished animations should never cause restyles ' +
|
||||
'when mouse is moved on the animations');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_compositor_animations_out_of_view_element() {
|
||||
add_task_if_omta_enabled(async function no_restyling_compositor_animations_out_of_view_element() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -214,18 +214,18 @@ waitForAllPaints(function() {
|
||||
{ style: 'animation: opacity 100s; transform: translateY(-400px);' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(!animation.isRunningOnCompositor);
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Animations running on the compositor in an out-of-view element ' +
|
||||
'should never cause restyles');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_main_thread_animations_out_of_view_element() {
|
||||
add_task(async function no_restyling_main_thread_animations_out_of_view_element() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -234,16 +234,16 @@ waitForAllPaints(function() {
|
||||
{ style: 'animation: background-color 100s; transform: translateY(-400px);' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
var markers = yield observeStyling(5);
|
||||
await animation.ready;
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Animations running on the main-thread in an out-of-view element ' +
|
||||
'should never cause restyles');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_compositor_animations_in_scrolled_out_element() {
|
||||
add_task_if_omta_enabled(async function no_restyling_compositor_animations_in_scrolled_out_element() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -262,18 +262,18 @@ waitForAllPaints(function() {
|
||||
parentElement.appendChild(div);
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Animations running on the compositor for elements ' +
|
||||
'which are scrolled out should never cause restyles');
|
||||
|
||||
yield ensureElementRemoval(parentElement);
|
||||
await ensureElementRemoval(parentElement);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_main_thread_animations_in_scrolled_out_element() {
|
||||
add_task(async function no_restyling_main_thread_animations_in_scrolled_out_element() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -293,17 +293,17 @@ waitForAllPaints(function() {
|
||||
parentElement.appendChild(div);
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
var markers = yield observeStyling(5);
|
||||
await animation.ready;
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Animations running on the main-thread for elements ' +
|
||||
'which are scrolled out should never cause restyles');
|
||||
|
||||
yield ensureElementRemoval(parentElement);
|
||||
await ensureElementRemoval(parentElement);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_main_thread_animations_in_nested_scrolled_out_element() {
|
||||
add_task(async function no_restyling_main_thread_animations_in_nested_scrolled_out_element() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -326,33 +326,33 @@ waitForAllPaints(function() {
|
||||
parentElement.appendChild(div);
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
var markers = yield observeStyling(5);
|
||||
await animation.ready;
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Animations running on the main-thread which are in nested elements ' +
|
||||
'which are scrolled out should never cause restyles');
|
||||
|
||||
yield ensureElementRemoval(grandParent);
|
||||
await ensureElementRemoval(grandParent);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_compositor_animations_in_visiblily_hidden_element() {
|
||||
add_task_if_omta_enabled(async function no_restyling_compositor_animations_in_visiblily_hidden_element() {
|
||||
var div = addDiv(null,
|
||||
{ style: 'animation: opacity 100s; visibility: hidden' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(!animation.isRunningOnCompositor);
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
todo_is(markers.length, 0,
|
||||
'Bug 1237454: Animations running on the compositor in ' +
|
||||
'visibility hidden element should never cause restyles');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* restyling_main_thread_animations_moved_in_view_by_scrolling() {
|
||||
add_task(async function restyling_main_thread_animations_moved_in_view_by_scrolling() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -376,9 +376,9 @@ waitForAllPaints(function() {
|
||||
var centerX = parentRect.left + parentRect.width / 2;
|
||||
var centerY = parentRect.top + parentRect.height / 2;
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(1, function() {
|
||||
var markers = await observeStyling(1, function() {
|
||||
// We can't use synthesizeWheel here since synthesizeWheel causes
|
||||
// layout flush.
|
||||
synthesizeWheelAtPoint(centerX, centerY,
|
||||
@@ -391,10 +391,10 @@ waitForAllPaints(function() {
|
||||
'elements should update restyling soon after the element moved in ' +
|
||||
'view by scrolling');
|
||||
|
||||
yield ensureElementRemoval(parentElement);
|
||||
await ensureElementRemoval(parentElement);
|
||||
});
|
||||
|
||||
add_task(function* restyling_main_thread_animations_moved_in_view_by_scrolling() {
|
||||
add_task(async function restyling_main_thread_animations_moved_in_view_by_scrolling() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -413,9 +413,9 @@ waitForAllPaints(function() {
|
||||
var centerX = parentRect.left + parentRect.width / 2;
|
||||
var centerY = parentRect.top + parentRect.height / 2;
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(1, function() {
|
||||
var markers = await observeStyling(1, function() {
|
||||
// We can't use synthesizeWheel here since synthesizeWheel causes
|
||||
// layout flush.
|
||||
synthesizeWheelAtPoint(centerX, centerY,
|
||||
@@ -429,10 +429,10 @@ waitForAllPaints(function() {
|
||||
'out elements should update restyle soon after the element moved ' +
|
||||
'in view by scrolling');
|
||||
|
||||
yield ensureElementRemoval(grandParent);
|
||||
await ensureElementRemoval(grandParent);
|
||||
});
|
||||
|
||||
add_task(function* restyling_main_thread_animations_move_out_of_view_by_scrolling() {
|
||||
add_task(async function restyling_main_thread_animations_move_out_of_view_by_scrolling() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -459,7 +459,7 @@ waitForAllPaints(function() {
|
||||
var centerX = parentRect.left + parentRect.width / 2;
|
||||
var centerY = parentRect.top + parentRect.height / 2;
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
// We can't use synthesizeWheel here since synthesizeWheel causes
|
||||
// layout flush.
|
||||
@@ -467,17 +467,17 @@ waitForAllPaints(function() {
|
||||
{ deltaMode: WheelEvent.DOM_DELTA_PIXEL,
|
||||
deltaY: 200 });
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
// FIXME: We should reduce a redundant restyle here.
|
||||
ok(markers.length >= 0,
|
||||
'Animations running on the main-thread which are in scrolled out ' +
|
||||
'elements should throttle restyling');
|
||||
|
||||
yield ensureElementRemoval(parentElement);
|
||||
await ensureElementRemoval(parentElement);
|
||||
});
|
||||
|
||||
add_task(function* restyling_main_thread_animations_moved_in_view_by_resizing() {
|
||||
add_task(async function restyling_main_thread_animations_moved_in_view_by_resizing() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -489,9 +489,9 @@ waitForAllPaints(function() {
|
||||
parentElement.appendChild(div);
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(1, function() {
|
||||
var markers = await observeStyling(1, function() {
|
||||
parentElement.style.height = '100px';
|
||||
});
|
||||
|
||||
@@ -500,78 +500,78 @@ waitForAllPaints(function() {
|
||||
'elements should update restyling soon after the element moved in ' +
|
||||
'view by resizing');
|
||||
|
||||
yield ensureElementRemoval(parentElement);
|
||||
await ensureElementRemoval(parentElement);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_main_thread_animations_in_visiblily_hidden_element() {
|
||||
add_task(async function no_restyling_main_thread_animations_in_visiblily_hidden_element() {
|
||||
var div = addDiv(null,
|
||||
{ style: 'animation: background-color 100s; visibility: hidden' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
var markers = yield observeStyling(5);
|
||||
await animation.ready;
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
todo_is(markers.length, 0,
|
||||
'Bug 1237454: Animations running on the main-thread in ' +
|
||||
'visibility hidden element should never cause restyles');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_compositor_animations_after_pause_is_called() {
|
||||
add_task_if_omta_enabled(async function no_restyling_compositor_animations_after_pause_is_called() {
|
||||
var div = addDiv(null, { style: 'animation: opacity 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor);
|
||||
|
||||
animation.pause();
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Bug 1232563: Paused animations running on the compositor should ' +
|
||||
'never cause restyles once after pause() is called');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_main_thread_animations_after_pause_is_called() {
|
||||
add_task(async function no_restyling_main_thread_animations_after_pause_is_called() {
|
||||
var div = addDiv(null, { style: 'animation: background-color 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
animation.pause();
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Bug 1232563: Paused animations running on the main-thread should ' +
|
||||
'never cause restyles after pause() is called');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* only_one_restyling_when_current_time_is_set_to_middle_of_duration() {
|
||||
add_task_if_omta_enabled(async function only_one_restyling_when_current_time_is_set_to_middle_of_duration() {
|
||||
var div = addDiv(null, { style: 'animation: opacity 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
animation.currentTime = 50 * MS_PER_SEC;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 1,
|
||||
'Bug 1235478: Animations running on the compositor should only once ' +
|
||||
'update style when currentTime is set to middle of duration time');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* change_duration_and_currenttime() {
|
||||
add_task_if_omta_enabled(async function change_duration_and_currenttime() {
|
||||
var div = addDiv(null);
|
||||
var animation = div.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor);
|
||||
|
||||
// Set currentTime to a time longer than duration.
|
||||
@@ -582,25 +582,25 @@ waitForAllPaints(function() {
|
||||
|
||||
// Extend the duration.
|
||||
animation.effect.timing.duration = 800 * MS_PER_SEC;
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 1,
|
||||
'Animations running on the compositor should update style ' +
|
||||
'when timing.duration is made longer than the current time');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* script_animation_on_display_none_element() {
|
||||
add_task(async function script_animation_on_display_none_element() {
|
||||
var div = addDiv(null);
|
||||
var animation = div.animate({ backgroundColor: [ 'red', 'blue' ] },
|
||||
100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
div.style.display = 'none';
|
||||
|
||||
// We need to wait a frame to apply display:none style.
|
||||
yield waitForFrame();
|
||||
await waitForFrame();
|
||||
|
||||
is(animation.playState, 'running',
|
||||
'Script animations keep running even when the target element has ' +
|
||||
@@ -610,33 +610,33 @@ waitForAllPaints(function() {
|
||||
'Script animations on "display:none" element should not run on the ' +
|
||||
'compositor');
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Script animations on "display: none" element should not update styles');
|
||||
|
||||
div.style.display = '';
|
||||
|
||||
// We need to wait a frame to unapply display:none style.
|
||||
yield waitForFrame();
|
||||
await waitForFrame();
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 5,
|
||||
'Script animations restored from "display: none" state should update ' +
|
||||
'styles');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* compositable_script_animation_on_display_none_element() {
|
||||
add_task_if_omta_enabled(async function compositable_script_animation_on_display_none_element() {
|
||||
var div = addDiv(null);
|
||||
var animation = div.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
div.style.display = 'none';
|
||||
|
||||
// We need to wait a frame to apply display:none style.
|
||||
yield waitForFrame();
|
||||
await waitForFrame();
|
||||
|
||||
is(animation.playState, 'running',
|
||||
'Opacity script animations keep running even when the target element ' +
|
||||
@@ -646,7 +646,7 @@ waitForAllPaints(function() {
|
||||
'Opacity script animations on "display:none" element should not ' +
|
||||
'run on the compositor');
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Opacity script animations on "display: none" element should not ' +
|
||||
'update styles');
|
||||
@@ -654,78 +654,78 @@ waitForAllPaints(function() {
|
||||
div.style.display = '';
|
||||
|
||||
// We need to wait a frame to unapply display:none style.
|
||||
yield waitForFrame();
|
||||
await waitForFrame();
|
||||
|
||||
ok(animation.isRunningOnCompositor,
|
||||
'Opacity script animations restored from "display: none" should be ' +
|
||||
'run on the compositor');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* restyling_for_empty_keyframes() {
|
||||
add_task(async function restyling_for_empty_keyframes() {
|
||||
var div = addDiv(null);
|
||||
var animation = div.animate({ }, 100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
var markers = yield observeStyling(5);
|
||||
await animation.ready;
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Animations with no keyframes should not cause restyles');
|
||||
|
||||
animation.effect.setKeyframes({ backgroundColor: ['red', 'blue'] });
|
||||
markers = yield observeStyling(5);
|
||||
markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 5,
|
||||
'Setting valid keyframes should cause regular animation restyles to ' +
|
||||
'occur');
|
||||
|
||||
animation.effect.setKeyframes({ });
|
||||
markers = yield observeStyling(5);
|
||||
markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 1,
|
||||
'Setting an empty set of keyframes should trigger a single restyle ' +
|
||||
'to remove the previous animated style');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(function* no_restyling_when_animation_style_when_re_setting_same_animation_property() {
|
||||
add_task_if_omta_enabled(async function no_restyling_when_animation_style_when_re_setting_same_animation_property() {
|
||||
var div = addDiv(null, { style: 'animation: opacity 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor);
|
||||
// Apply the same animation style
|
||||
div.style.animation = 'opacity 100s';
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Applying same animation style ' +
|
||||
'should never cause restyles');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* necessary_update_should_be_invoked() {
|
||||
add_task(async function necessary_update_should_be_invoked() {
|
||||
var div = addDiv(null, { style: 'animation: background-color 100s' });
|
||||
var animation = div.getAnimations()[0];
|
||||
yield animation.ready;
|
||||
yield waitForAnimationFrames(5);
|
||||
await animation.ready;
|
||||
await waitForAnimationFrames(5);
|
||||
// Apply another animation style
|
||||
div.style.animation = 'background-color 110s';
|
||||
var animation = div.getAnimations()[0];
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 5,
|
||||
'Applying animation style with different duration ' +
|
||||
'should cause restyles on every frame.');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(
|
||||
function* changing_cascading_result_for_main_thread_animation() {
|
||||
async function changing_cascading_result_for_main_thread_animation() {
|
||||
var div = addDiv(null, { style: 'background-color: blue' });
|
||||
var animation = div.animate({ opacity: [0, 1],
|
||||
backgroundColor: ['green', 'red'] },
|
||||
100 * MS_PER_SEC);
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(animation.isRunningOnCompositor,
|
||||
'The opacity animation is running on the compositor');
|
||||
// Make the background-color style as !important to cause an update
|
||||
@@ -733,31 +733,31 @@ waitForAllPaints(function() {
|
||||
// Bug 1300982: The background-color animation should be no longer
|
||||
// running on the main thread.
|
||||
div.style.setProperty('background-color', '1', 'important');
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
todo_is(markers.length, 0,
|
||||
'Changing cascading result for the property running on the main ' +
|
||||
'thread does not cause synchronization layer of opacity animation ' +
|
||||
'running on the compositor');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
}
|
||||
);
|
||||
|
||||
add_task(function* restyling_for_animation_on_orphaned_element() {
|
||||
add_task(async function restyling_for_animation_on_orphaned_element() {
|
||||
var div = addDiv(null);
|
||||
var animation = div.animate({ marginLeft: [ '0px', '100px' ] },
|
||||
100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
div.remove();
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Animation on orphaned element should not cause restyles');
|
||||
|
||||
document.body.appendChild(div);
|
||||
|
||||
markers = yield observeStyling(1);
|
||||
markers = await observeStyling(1);
|
||||
// We are observing restyles in rAF callback which is processed before
|
||||
// restyling process in each frame, so in the first frame there should be
|
||||
// no observed restyle since we don't process restyle while the element
|
||||
@@ -765,22 +765,22 @@ waitForAllPaints(function() {
|
||||
is(markers.length, 0,
|
||||
'We observe no restyle in the first frame right after re-atatching ' +
|
||||
'to the document');
|
||||
markers = yield observeStyling(5);
|
||||
markers = await observeStyling(5);
|
||||
is(markers.length, 5,
|
||||
'Animation on re-attached to the document begins to update style');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task_if_omta_enabled(
|
||||
// Tests that if we remove an element from the document whose animation
|
||||
// cascade needs recalculating, that it is correctly updated when it is
|
||||
// re-attached to the document.
|
||||
function* restyling_for_opacity_animation_on_re_attached_element() {
|
||||
async function restyling_for_opacity_animation_on_re_attached_element() {
|
||||
var div = addDiv(null, { style: 'opacity: 1 ! important' });
|
||||
var animation = div.animate({ opacity: [0, 1] }, 100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
ok(!animation.isRunningOnCompositor,
|
||||
'The opacity animation overridden by an !important rule is NOT ' +
|
||||
'running on the compositor');
|
||||
@@ -790,7 +790,7 @@ waitForAllPaints(function() {
|
||||
|
||||
div.remove();
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'Opacity animation on orphaned element should not cause restyles');
|
||||
|
||||
@@ -798,7 +798,7 @@ waitForAllPaints(function() {
|
||||
|
||||
// Need a frame to give the animation a chance to be sent to the
|
||||
// compositor.
|
||||
yield waitForFrame();
|
||||
await waitForFrame();
|
||||
|
||||
ok(animation.isRunningOnCompositor,
|
||||
'The opacity animation which is no longer overridden by the ' +
|
||||
@@ -806,12 +806,12 @@ waitForAllPaints(function() {
|
||||
'!important rule had been dropped before the target element was ' +
|
||||
'removed');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
}
|
||||
);
|
||||
|
||||
// Tests that additive animations don't throttle at all.
|
||||
add_task(function* no_throttling_animations_out_of_view_element() {
|
||||
add_task(async function no_throttling_animations_out_of_view_element() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling') ||
|
||||
!SpecialPowers.getBoolPref('dom.animations-api.core.enabled')) {
|
||||
return;
|
||||
@@ -821,18 +821,18 @@ waitForAllPaints(function() {
|
||||
var animation =
|
||||
div.animate([{ visibility: 'visible' }], 100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 5,
|
||||
'Discrete animation has has no keyframe whose offset is 0 or 1 in an ' +
|
||||
'out-of-view element should not be throttled');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
// Counter part of the above test.
|
||||
add_task(function* no_restyling_discrete_animations_out_of_view_element() {
|
||||
add_task(async function no_restyling_discrete_animations_out_of_view_element() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling') ||
|
||||
!SpecialPowers.getBoolPref('dom.animations-api.core.enabled')) {
|
||||
return;
|
||||
@@ -842,33 +842,33 @@ waitForAllPaints(function() {
|
||||
var animation =
|
||||
div.animate({ visibility: ['visible', 'hidden'] }, 100 * MS_PER_SEC);
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Discrete animation running on the main-thread in an out-of-view ' +
|
||||
'element should never cause restyles');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function* no_restyling_while_computed_timing_is_not_changed() {
|
||||
add_task(async function no_restyling_while_computed_timing_is_not_changed() {
|
||||
var div = addDiv(null);
|
||||
var animation = div.animate({ backgroundColor: [ 'red', 'blue' ] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'step-end' });
|
||||
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
|
||||
is(markers.length, 0,
|
||||
'Animation running on the main-thread while computed timing is not ' +
|
||||
'changed should never cause restyles');
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function *no_throttling_animations_in_view_svg() {
|
||||
add_task(async function no_throttling_animations_in_view_svg() {
|
||||
/*
|
||||
On Android throttled animations are left behind on the main thread in some
|
||||
frames, We will fix this in bug 1247800.
|
||||
@@ -888,17 +888,17 @@ waitForAllPaints(function() {
|
||||
height: '10',
|
||||
fill: 'red' });
|
||||
var animation = rect.animate({ fill: ['blue', 'lime'] }, 100 * MS_PER_SEC);
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 5,
|
||||
'CSS animations on an in-view svg element with post-transform should ' +
|
||||
'not be throttled.');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function *throttling_animations_out_of_view_svg() {
|
||||
add_task(async function throttling_animations_out_of_view_svg() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -921,17 +921,17 @@ waitForAllPaints(function() {
|
||||
fill: 'red' });
|
||||
|
||||
var animation = rect.animate({ fill: ['blue', 'lime'] }, 100 * MS_PER_SEC);
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'CSS animations on an out-of-view svg element with post-transform ' +
|
||||
'should be throttled.');
|
||||
|
||||
yield ensureElementRemoval(div);
|
||||
await ensureElementRemoval(div);
|
||||
});
|
||||
|
||||
add_task(function *no_throttling_animations_in_view_css_transform() {
|
||||
add_task(async function no_throttling_animations_in_view_css_transform() {
|
||||
/*
|
||||
On Android throttled animations are left behind on the main thread in some
|
||||
frames, We will fix this in bug 1247800.
|
||||
@@ -948,17 +948,17 @@ waitForAllPaints(function() {
|
||||
scrollDiv.appendChild(targetDiv);
|
||||
|
||||
var animation = targetDiv.getAnimations()[0];
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 5,
|
||||
'CSS animation on an in-view element with pre-transform should not ' +
|
||||
'be throttled.');
|
||||
|
||||
yield ensureElementRemoval(scrollDiv);
|
||||
await ensureElementRemoval(scrollDiv);
|
||||
});
|
||||
|
||||
add_task(function *throttling_animations_out_of_view_css_transform() {
|
||||
add_task(async function throttling_animations_out_of_view_css_transform() {
|
||||
if (!SpecialPowers.getBoolPref('dom.animations.offscreen-throttling')) {
|
||||
return;
|
||||
}
|
||||
@@ -979,14 +979,14 @@ waitForAllPaints(function() {
|
||||
scrollDiv.appendChild(targetDiv);
|
||||
|
||||
var animation = targetDiv.getAnimations()[0];
|
||||
yield animation.ready;
|
||||
await animation.ready;
|
||||
|
||||
var markers = yield observeStyling(5);
|
||||
var markers = await observeStyling(5);
|
||||
is(markers.length, 0,
|
||||
'CSS animation on an out-of-view element with pre-transform should be ' +
|
||||
'throttled.');
|
||||
|
||||
yield ensureElementRemoval(scrollDiv);
|
||||
await ensureElementRemoval(scrollDiv);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const gHttpTestRoot = "http://example.com/browser/dom/base/test/";
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
var statusTexts = [];
|
||||
var xhr = new XMLHttpRequest();
|
||||
var observer = {
|
||||
@@ -16,7 +16,7 @@ add_task(function* () {
|
||||
};
|
||||
|
||||
Services.obs.addObserver(observer, "http-on-examine-response");
|
||||
yield new Promise((resolve) => {
|
||||
await new Promise((resolve) => {
|
||||
xhr.addEventListener("load", function() {
|
||||
statusTexts.push(this.statusText);
|
||||
is(statusTexts[0], "", "Empty statusText value for HTTP 302");
|
||||
|
||||
@@ -57,23 +57,23 @@ function prepareForVisibilityEvents(browser, expectedOrder) {
|
||||
* swapping browser frameloaders (which occurs when moving a tab
|
||||
* into a different window).
|
||||
*/
|
||||
add_task(function* test_swap_frameloader_pagevisibility_events() {
|
||||
add_task(async function test_swap_frameloader_pagevisibility_events() {
|
||||
// Load a new tab that we'll tear out...
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, PAGE);
|
||||
gBrowser.selectedTab = tab;
|
||||
let firstBrowser = tab.linkedBrowser;
|
||||
yield BrowserTestUtils.browserLoaded(firstBrowser);
|
||||
await BrowserTestUtils.browserLoaded(firstBrowser);
|
||||
|
||||
// Swap the browser out to a new window
|
||||
let newWindow = gBrowser.replaceTabWithWindow(tab);
|
||||
|
||||
// We have to wait for the window to load so we can get the selected browser
|
||||
// to listen to.
|
||||
yield BrowserTestUtils.waitForEvent(newWindow, "load");
|
||||
await BrowserTestUtils.waitForEvent(newWindow, "load");
|
||||
let newWindowBrowser = newWindow.gBrowser.selectedBrowser;
|
||||
|
||||
// Wait for the expected pagehide and pageshow events on the initial browser
|
||||
yield prepareForVisibilityEvents(newWindowBrowser, ["pagehide", "pageshow"]);
|
||||
await prepareForVisibilityEvents(newWindowBrowser, ["pagehide", "pageshow"]);
|
||||
|
||||
// Now let's send the browser back to the original window
|
||||
|
||||
@@ -89,7 +89,7 @@ add_task(function* test_swap_frameloader_pagevisibility_events() {
|
||||
// find a way of sending down a frame script to the newly opened windows
|
||||
// and tabs fast enough to attach the event handlers before they were
|
||||
// fired.
|
||||
yield new Promise((resolve) => {
|
||||
await new Promise((resolve) => {
|
||||
emptyBrowser.addEventListener("pageshow", function() {
|
||||
resolve();
|
||||
}, {once: true});
|
||||
@@ -102,7 +102,7 @@ add_task(function* test_swap_frameloader_pagevisibility_events() {
|
||||
|
||||
gBrowser.swapBrowsersAndCloseOther(newTab, newWindow.gBrowser.selectedTab);
|
||||
|
||||
yield emptyBrowserPromise;
|
||||
await emptyBrowserPromise;
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
@@ -15,96 +15,96 @@
|
||||
|
||||
const BASE_URL = "http://mochi.test:8888/browser/dom/base/test/";
|
||||
|
||||
add_task(function*() {
|
||||
yield* testLinkClick(false, false);
|
||||
yield* testLinkClick(false, true);
|
||||
yield* testLinkClick(true, false);
|
||||
yield* testLinkClick(true, true);
|
||||
add_task(async function() {
|
||||
await testLinkClick(false, false);
|
||||
await testLinkClick(false, true);
|
||||
await testLinkClick(true, false);
|
||||
await testLinkClick(true, true);
|
||||
});
|
||||
|
||||
function* testLinkClick(withFrame, loadDivertedInBackground) {
|
||||
yield SpecialPowers.pushPrefEnv({"set": [["browser.tabs.loadDivertedInBackground", loadDivertedInBackground]]});
|
||||
async function testLinkClick(withFrame, loadDivertedInBackground) {
|
||||
await SpecialPowers.pushPrefEnv({"set": [["browser.tabs.loadDivertedInBackground", loadDivertedInBackground]]});
|
||||
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser,
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser,
|
||||
BASE_URL + (withFrame ? "file_bug1303838_with_iframe.html" : "file_bug1303838.html"));
|
||||
is(gBrowser.tabs.length, 2, "check tabs.length");
|
||||
is(gBrowser.selectedTab, tab, "check selectedTab");
|
||||
|
||||
info("Test normal links with loadDivertedInBackground=" + loadDivertedInBackground + ", withFrame=" + withFrame);
|
||||
|
||||
let [testTab] = yield clickLink(withFrame, "#link-1", tab.linkedBrowser);
|
||||
let [testTab] = await clickLink(withFrame, "#link-1", tab.linkedBrowser);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#link-2", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#link-2", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#link-3", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#link-3", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#link-4", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground, 2);
|
||||
await clickLink(withFrame, "#link-4", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground, 2);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
info("Test anchor links with loadDivertedInBackground=" + loadDivertedInBackground + ", withFrame=" + withFrame);
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#anchor-link-1", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#anchor-link-1", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#anchor-link-2", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#anchor-link-2", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#anchor-link-3", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#anchor-link-3", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
info("Test iframe links with loadDivertedInBackground=" + loadDivertedInBackground + ", withFrame=" + withFrame);
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#frame-link-1", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#frame-link-1", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#frame-link-2", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#frame-link-2", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
if (!loadDivertedInBackground) {
|
||||
yield BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
}
|
||||
yield clickLink(withFrame, "#frame-link-3", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
await clickLink(withFrame, "#frame-link-3", tab.linkedBrowser, testTab.linkedBrowser, !loadDivertedInBackground);
|
||||
is(gBrowser.tabs.length, 3, "check tabs.length");
|
||||
is(gBrowser.selectedTab, loadDivertedInBackground ? tab : testTab, "check selectedTab");
|
||||
|
||||
yield BrowserTestUtils.removeTab(testTab);
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
await BrowserTestUtils.removeTab(testTab);
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
function clickLink(isFrame, linkId, browser, testBrowser, awaitTabSwitch = false, locationChangeNum = 1) {
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=593387#c17
|
||||
*/
|
||||
|
||||
add_task(function* test() {
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser,
|
||||
add_task(async function test() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser,
|
||||
url: "chrome://global/content/mozilla.xhtml" },
|
||||
function* (newBrowser) {
|
||||
async function(newBrowser) {
|
||||
// NB: We load the chrome:// page in the parent process.
|
||||
yield testXFOFrameInChrome(newBrowser);
|
||||
await testXFOFrameInChrome(newBrowser);
|
||||
|
||||
// Run next test (try the same with a content top-level context)
|
||||
yield BrowserTestUtils.loadURI(newBrowser, "http://example.com/");
|
||||
yield BrowserTestUtils.browserLoaded(newBrowser);
|
||||
await BrowserTestUtils.loadURI(newBrowser, "http://example.com/");
|
||||
await BrowserTestUtils.browserLoaded(newBrowser);
|
||||
|
||||
yield ContentTask.spawn(newBrowser, null, testXFOFrameInContent);
|
||||
await ContentTask.spawn(newBrowser, null, testXFOFrameInContent);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -7,23 +7,23 @@ const CONTENT_CREATED = "ipc:content-created";
|
||||
async function spawnNewAndTest(recur, pids) {
|
||||
let processCreated = TestUtils.topicObserved(CONTENT_CREATED);
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank", forceNewProcess: true },
|
||||
function* (browser) {
|
||||
async function(browser) {
|
||||
// Make sure our new browser is in its own process. The processCreated
|
||||
// promise should have already resolved by this point.
|
||||
yield processCreated;
|
||||
await processCreated;
|
||||
let newPid = browser.frameLoader.tabParent.osPid;
|
||||
ok(!pids.has(newPid), "new tab is in its own process");
|
||||
pids.add(newPid);
|
||||
|
||||
if (recur) {
|
||||
yield spawnNewAndTest(recur - 1, pids);
|
||||
await spawnNewAndTest(recur - 1, pids);
|
||||
} else {
|
||||
let observer = () => {
|
||||
ok(false, "shouldn't have created a new process");
|
||||
};
|
||||
Services.obs.addObserver(observer, CONTENT_CREATED);
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function(browser) {
|
||||
// If this new tab caused us to create a new process, the ok(false)
|
||||
// should have already happened. Therefore, if we get here, we've
|
||||
// passed. Simply remove the observer.
|
||||
|
||||
@@ -7,11 +7,11 @@ const URIs = [
|
||||
"http://example.com/browser/dom/base/test/empty.html"
|
||||
];
|
||||
|
||||
function* runTest(input, url) {
|
||||
async function runTest(input, url) {
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, url);
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
|
||||
yield BrowserTestUtils.browserLoaded(browser);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
let stream = Cc['@mozilla.org/io/string-input-stream;1']
|
||||
.createInstance(Ci.nsIStringInputStream);
|
||||
@@ -23,7 +23,7 @@ function* runTest(input, url) {
|
||||
|
||||
is(data.inputStream.available(), input.length, "The length of the inputStream matches: " + input.length);
|
||||
|
||||
let dataBack = yield ContentTask.spawn(browser, data, function(data) {
|
||||
let dataBack = await ContentTask.spawn(browser, data, function(data) {
|
||||
let dataBack = {
|
||||
inputStream: data.inputStream,
|
||||
check: true,
|
||||
@@ -40,17 +40,17 @@ function* runTest(input, url) {
|
||||
ok(data.inputStream instanceof Ci.nsIInputStream, "The original object was an inputStream");
|
||||
ok(dataBack.inputStream instanceof Ci.nsIInputStream, "We have an inputStream back from the content.");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
add_task(function* test() {
|
||||
add_task(async function test() {
|
||||
let a = "a";
|
||||
for (let i = 0; i < 25; ++i) {
|
||||
a+=a;
|
||||
}
|
||||
|
||||
for (let i = 0; i < URIs.length; ++i) {
|
||||
yield runTest("Hello world", URIs[i]);
|
||||
yield runTest(a, URIs[i]);
|
||||
await runTest("Hello world", URIs[i]);
|
||||
await runTest(a, URIs[i]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -31,12 +31,12 @@ function initTestScript() {
|
||||
}
|
||||
var initTestScriptURL = "data:,(" + initTestScript.toString() + ")()";
|
||||
|
||||
var checkProcess = Task.async(function*(mm) {
|
||||
let { target } = yield promiseMessage(mm, "ProcessTest:Loaded");
|
||||
var checkProcess = async function(mm) {
|
||||
let { target } = await promiseMessage(mm, "ProcessTest:Loaded");
|
||||
target.sendAsyncMessage("ProcessTest:Reply");
|
||||
yield promiseMessage(target, "ProcessTest:Finished");
|
||||
await promiseMessage(target, "ProcessTest:Finished");
|
||||
ok(true, "Saw process finished");
|
||||
});
|
||||
};
|
||||
|
||||
function promiseMessage(messageManager, message) {
|
||||
return new Promise(resolve => {
|
||||
@@ -49,30 +49,30 @@ function promiseMessage(messageManager, message) {
|
||||
})
|
||||
}
|
||||
|
||||
add_task(function*(){
|
||||
add_task(async function(){
|
||||
// We want to count processes in this test, so let's disable the pre-allocated process manager.
|
||||
yield SpecialPowers.pushPrefEnv({"set": [
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.ipc.processPrelaunch.enabled", false],
|
||||
]});
|
||||
})
|
||||
|
||||
add_task(function*(){
|
||||
add_task(async function(){
|
||||
// This test is only relevant in e10s.
|
||||
if (!gMultiProcessBrowser)
|
||||
return;
|
||||
|
||||
ppmm.releaseCachedProcesses();
|
||||
|
||||
yield SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 5]]})
|
||||
yield SpecialPowers.pushPrefEnv({"set": [["dom.ipc.keepProcessesAlive.web", 5]]})
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 5]]})
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.keepProcessesAlive.web", 5]]})
|
||||
|
||||
let tabs = [];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
tabs[i] = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
tabs[i] = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
|
||||
}
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
yield BrowserTestUtils.removeTab(tabs[i]);
|
||||
await BrowserTestUtils.removeTab(tabs[i]);
|
||||
}
|
||||
|
||||
ppmm.releaseCachedProcesses();
|
||||
@@ -80,17 +80,17 @@ add_task(function*(){
|
||||
})
|
||||
|
||||
// Test that loading a process script loads in all existing processes
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
let checks = [];
|
||||
for (let i = 0; i < ppmm.childCount; i++)
|
||||
checks.push(checkProcess(ppmm.getChildAt(i)));
|
||||
|
||||
ppmm.loadProcessScript(processScriptURL, false);
|
||||
yield Promise.all(checks);
|
||||
await Promise.all(checks);
|
||||
});
|
||||
|
||||
// Test that loading a process script loads in new processes
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
// This test is only relevant in e10s
|
||||
if (!gMultiProcessBrowser)
|
||||
return;
|
||||
@@ -99,7 +99,7 @@ add_task(function*() {
|
||||
|
||||
// Load something in the main process
|
||||
gBrowser.selectedBrowser.loadURI("about:robots");
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
let init = ppmm.initialProcessData;
|
||||
init.test123 = "hello";
|
||||
@@ -117,18 +117,18 @@ add_task(function*() {
|
||||
ppmm.loadProcessScript(processScriptURL, true);
|
||||
|
||||
// The main process should respond
|
||||
yield check;
|
||||
await check;
|
||||
|
||||
check = checkProcess(ppmm);
|
||||
// Reset the default browser to start a new child process
|
||||
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
|
||||
gBrowser.selectedBrowser.loadURI("about:blank");
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
is(ppmm.childCount, 3, "Should be back to three processes at this point");
|
||||
|
||||
// The new process should have responded
|
||||
yield check;
|
||||
await check;
|
||||
|
||||
ppmm.removeDelayedProcessScript(processScriptURL);
|
||||
|
||||
@@ -136,7 +136,7 @@ add_task(function*() {
|
||||
childMM = ppmm.getChildAt(2);
|
||||
|
||||
childMM.loadProcessScript(initTestScriptURL, false);
|
||||
let msg = yield promiseMessage(childMM, "ProcessTest:InitGood");
|
||||
let msg = await promiseMessage(childMM, "ProcessTest:InitGood");
|
||||
is(msg.data, "bye", "initial process data was correct");
|
||||
} else {
|
||||
info("Unable to finish test entirely");
|
||||
|
||||
@@ -12,7 +12,7 @@ const { openWindow } = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
|
||||
const Test = routine => () => {
|
||||
waitForExplicitFinish();
|
||||
Task.spawn(routine)
|
||||
(routine)()
|
||||
.then(finish, error => {
|
||||
ok(false, error);
|
||||
finish();
|
||||
@@ -76,7 +76,7 @@ const uri3 = "data:text/html;charset=utf-8,<h1>3</h1>";
|
||||
|
||||
const uri4 = "chrome://browser/content/license.html";
|
||||
|
||||
const test = Test(function*() {
|
||||
const test = Test(async function() {
|
||||
let documentInteractive = receive("content-document-interactive", isData, d => {
|
||||
// This test is executed synchronously when the event is received.
|
||||
is(d.readyState, "interactive", "document is interactive");
|
||||
@@ -89,17 +89,17 @@ const test = Test(function*() {
|
||||
const tab1 = openTab(uri1);
|
||||
const browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
let interactiveDocument1 = yield documentInteractive;
|
||||
let interactiveDocument1 = await documentInteractive;
|
||||
|
||||
let loadedDocument1 = yield documentLoaded;
|
||||
let loadedDocument1 = await documentLoaded;
|
||||
is(loadedDocument1.readyState, "complete", "document is loaded");
|
||||
is(interactiveDocument1, loadedDocument1, "interactive document is loaded");
|
||||
|
||||
let shownPage = yield pageShown;
|
||||
let shownPage = await pageShown;
|
||||
is(interactiveDocument1, shownPage, "loaded document is shown");
|
||||
|
||||
// Wait until history entry is created before loading new uri.
|
||||
yield receive("sessionstore-state-write-complete");
|
||||
await receive("sessionstore-state-write-complete");
|
||||
|
||||
info("load uri#2");
|
||||
|
||||
@@ -114,16 +114,16 @@ const test = Test(function*() {
|
||||
|
||||
browser1.loadURI(uri2);
|
||||
|
||||
let hiddenPage = yield pageHidden;
|
||||
let hiddenPage = await pageHidden;
|
||||
is(interactiveDocument1, hiddenPage, "loaded document is hidden");
|
||||
|
||||
let interactiveDocument2 = yield documentInteractive;
|
||||
let interactiveDocument2 = await documentInteractive;
|
||||
|
||||
let loadedDocument2 = yield documentLoaded;
|
||||
let loadedDocument2 = await documentLoaded;
|
||||
is(loadedDocument2.readyState, "complete", "document is loaded");
|
||||
is(interactiveDocument2, loadedDocument2, "interactive document is loaded");
|
||||
|
||||
shownPage = yield pageShown;
|
||||
shownPage = await pageShown;
|
||||
is(interactiveDocument2, shownPage, "loaded document is shown");
|
||||
|
||||
info("go back to uri#1");
|
||||
@@ -138,10 +138,10 @@ const test = Test(function*() {
|
||||
pageShown = receive("content-page-shown", isData);
|
||||
pageHidden = receive("content-page-hidden", isData);
|
||||
|
||||
hiddenPage = yield pageHidden;
|
||||
hiddenPage = await pageHidden;
|
||||
is(interactiveDocument2, hiddenPage, "new document is hidden");
|
||||
|
||||
shownPage = yield pageShown;
|
||||
shownPage = await pageShown;
|
||||
is(interactiveDocument1, shownPage, "previous document is shown");
|
||||
|
||||
info("load uri#3");
|
||||
@@ -150,13 +150,13 @@ const test = Test(function*() {
|
||||
|
||||
pageShown = receive("content-page-shown", isData);
|
||||
|
||||
let interactiveDocument3 = yield documentInteractive;
|
||||
let interactiveDocument3 = await documentInteractive;
|
||||
|
||||
let loadedDocument3 = yield documentLoaded;
|
||||
let loadedDocument3 = await documentLoaded;
|
||||
is(loadedDocument3.readyState, "complete", "document is loaded");
|
||||
is(interactiveDocument3, loadedDocument3, "interactive document is loaded");
|
||||
|
||||
shownPage = yield pageShown;
|
||||
shownPage = await pageShown;
|
||||
is(interactiveDocument3, shownPage, "previous document is shown");
|
||||
|
||||
gBrowser.removeTab(tab1);
|
||||
@@ -172,18 +172,18 @@ const test = Test(function*() {
|
||||
documentLoaded = receive("chrome-document-loaded");
|
||||
pageShown = receive("chrome-page-shown");
|
||||
|
||||
const interactiveDocument4 = yield documentInteractive;
|
||||
const interactiveDocument4 = await documentInteractive;
|
||||
|
||||
let loadedDocument4 = yield documentLoaded;
|
||||
let loadedDocument4 = await documentLoaded;
|
||||
is(loadedDocument4.readyState, "complete", "document is loaded");
|
||||
is(interactiveDocument4, loadedDocument4, "interactive document is loaded");
|
||||
|
||||
shownPage = yield pageShown;
|
||||
shownPage = await pageShown;
|
||||
is(interactiveDocument4, shownPage, "loaded chrome document is shown");
|
||||
|
||||
pageHidden = receive("chrome-page-hidden");
|
||||
gBrowser.removeTab(tab2);
|
||||
|
||||
hiddenPage = yield pageHidden;
|
||||
hiddenPage = await pageHidden;
|
||||
is(interactiveDocument4, hiddenPage, "chrome document hidden");
|
||||
});
|
||||
|
||||
@@ -26,20 +26,20 @@ const kDelay = 10;
|
||||
|
||||
Services.scriptloader.loadSubScript(kPluginJS, this);
|
||||
|
||||
function* runTest(url) {
|
||||
async function runTest(url) {
|
||||
let currentTab = gBrowser.selectedTab;
|
||||
let newTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, kBaseURI);
|
||||
let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, kBaseURI);
|
||||
let newBrowser = gBrowser.getBrowserForTab(newTab);
|
||||
|
||||
// Wait for the UI to indicate that audio is being played back.
|
||||
let promise = BrowserTestUtils.waitForAttribute("soundplaying", newTab, "true");
|
||||
newBrowser.loadURI(url);
|
||||
yield promise;
|
||||
await promise;
|
||||
|
||||
// Put the tab in the background.
|
||||
yield BrowserTestUtils.switchTab(gBrowser, currentTab);
|
||||
await BrowserTestUtils.switchTab(gBrowser, currentTab);
|
||||
|
||||
let timeout = yield ContentTask.spawn(newBrowser, kDelay, function(delay) {
|
||||
let timeout = await ContentTask.spawn(newBrowser, kDelay, function(delay) {
|
||||
return new Promise(resolve => {
|
||||
let before = new Date();
|
||||
content.window.setTimeout(function() {
|
||||
@@ -51,17 +51,17 @@ function* runTest(url) {
|
||||
ok(timeout <= kMinTimeoutBackground, `Got the correct timeout (${timeout})`);
|
||||
|
||||
// All done.
|
||||
yield BrowserTestUtils.removeTab(newTab);
|
||||
await BrowserTestUtils.removeTab(newTab);
|
||||
}
|
||||
|
||||
add_task(function* setup() {
|
||||
yield SpecialPowers.pushPrefEnv({"set": [
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.min_background_timeout_value", kMinTimeoutBackground],
|
||||
]});
|
||||
});
|
||||
|
||||
add_task(function* test() {
|
||||
add_task(async function test() {
|
||||
for (var url of testURLs) {
|
||||
yield runTest(url);
|
||||
await runTest(url);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ const gHttpTestRoot = "http://example.com/browser/dom/base/test/";
|
||||
*/
|
||||
var gOldContentCanRecord = false;
|
||||
var gOldParentCanRecord = false;
|
||||
add_task(function* test_initialize() {
|
||||
add_task(async function test_initialize() {
|
||||
let Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
|
||||
gOldParentCanRecord = Telemetry.canRecordExtended
|
||||
Telemetry.canRecordExtended = true;
|
||||
@@ -20,9 +20,9 @@ add_task(function* test_initialize() {
|
||||
// Because canRecordExtended is a per-process variable, we need to make sure
|
||||
// that all of the pages load in the same content process. Limit the number
|
||||
// of content processes to at most 1 (or 0 if e10s is off entirely).
|
||||
yield SpecialPowers.pushPrefEnv({ set: [[ "dom.ipc.processCount", 1 ]] });
|
||||
await SpecialPowers.pushPrefEnv({ set: [[ "dom.ipc.processCount", 1 ]] });
|
||||
|
||||
gOldContentCanRecord = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
|
||||
gOldContentCanRecord = await ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
|
||||
let telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
|
||||
let old = telemetry.canRecordExtended;
|
||||
telemetry.canRecordExtended = true;
|
||||
@@ -31,55 +31,55 @@ add_task(function* test_initialize() {
|
||||
info("canRecord for content: " + gOldContentCanRecord);
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
// Check that use counters are incremented by SVGs loaded directly in iframes.
|
||||
yield check_use_counter_iframe("file_use_counter_svg_getElementById.svg",
|
||||
await check_use_counter_iframe("file_use_counter_svg_getElementById.svg",
|
||||
"SVGSVGELEMENT_GETELEMENTBYID");
|
||||
yield check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
await check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
"SVGSVGELEMENT_CURRENTSCALE_getter");
|
||||
yield check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
await check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
"SVGSVGELEMENT_CURRENTSCALE_setter");
|
||||
|
||||
// Check that even loads from the imglib cache update use counters. The
|
||||
// images should still be there, because we just loaded them in the last
|
||||
// set of tests. But we won't get updated counts for the document
|
||||
// counters, because we won't be re-parsing the SVG documents.
|
||||
yield check_use_counter_iframe("file_use_counter_svg_getElementById.svg",
|
||||
await check_use_counter_iframe("file_use_counter_svg_getElementById.svg",
|
||||
"SVGSVGELEMENT_GETELEMENTBYID", false);
|
||||
yield check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
await check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
"SVGSVGELEMENT_CURRENTSCALE_getter", false);
|
||||
yield check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
await check_use_counter_iframe("file_use_counter_svg_currentScale.svg",
|
||||
"SVGSVGELEMENT_CURRENTSCALE_setter", false);
|
||||
|
||||
// Check that use counters are incremented by SVGs loaded as images.
|
||||
// Note that SVG images are not permitted to execute script, so we can only
|
||||
// check for properties here.
|
||||
yield check_use_counter_img("file_use_counter_svg_getElementById.svg",
|
||||
await check_use_counter_img("file_use_counter_svg_getElementById.svg",
|
||||
"PROPERTY_FILL");
|
||||
yield check_use_counter_img("file_use_counter_svg_currentScale.svg",
|
||||
await check_use_counter_img("file_use_counter_svg_currentScale.svg",
|
||||
"PROPERTY_FILL");
|
||||
|
||||
// Check that use counters are incremented by directly loading SVGs
|
||||
// that reference patterns defined in another SVG file.
|
||||
yield check_use_counter_direct("file_use_counter_svg_fill_pattern.svg",
|
||||
await check_use_counter_direct("file_use_counter_svg_fill_pattern.svg",
|
||||
"PROPERTY_FILLOPACITY", /*xfail=*/true);
|
||||
|
||||
// Check that use counters are incremented by directly loading SVGs
|
||||
// that reference patterns defined in the same file or in data: URLs.
|
||||
yield check_use_counter_direct("file_use_counter_svg_fill_pattern_internal.svg",
|
||||
await check_use_counter_direct("file_use_counter_svg_fill_pattern_internal.svg",
|
||||
"PROPERTY_FILLOPACITY");
|
||||
// data: URLs don't correctly propagate to their referring document yet.
|
||||
//yield check_use_counter_direct("file_use_counter_svg_fill_pattern_data.svg",
|
||||
// "PROPERTY_FILL_OPACITY");
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
|
||||
Telemetry.canRecordExtended = gOldParentCanRecord;
|
||||
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, { oldCanRecord: gOldContentCanRecord }, function* (arg) {
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, { oldCanRecord: gOldContentCanRecord }, async function(arg) {
|
||||
Cu.import("resource://gre/modules/PromiseUtils.jsm");
|
||||
yield new Promise(resolve => {
|
||||
await new Promise(resolve => {
|
||||
let telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
|
||||
telemetry.canRecordExtended = arg.oldCanRecord;
|
||||
resolve();
|
||||
@@ -95,9 +95,9 @@ function waitForDestroyedDocuments() {
|
||||
}
|
||||
|
||||
function waitForPageLoad(browser) {
|
||||
return ContentTask.spawn(browser, null, function*() {
|
||||
return ContentTask.spawn(browser, null, async function() {
|
||||
Cu.import("resource://gre/modules/PromiseUtils.jsm");
|
||||
yield new Promise(resolve => {
|
||||
await new Promise(resolve => {
|
||||
let listener = () => {
|
||||
removeEventListener("load", listener, true);
|
||||
resolve();
|
||||
@@ -202,7 +202,7 @@ var check_use_counter_img = async function(file, use_counter_middlefix) {
|
||||
await waitForPageLoad(gBrowser.selectedBrowser);
|
||||
|
||||
// Inject our desired file into the img of the newly-loaded page.
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function*(opts) {
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, async function(opts) {
|
||||
Cu.import("resource://gre/modules/PromiseUtils.jsm");
|
||||
let deferred = PromiseUtils.defer();
|
||||
|
||||
@@ -265,9 +265,9 @@ var check_use_counter_direct = async function(file, use_counter_middlefix, xfail
|
||||
await grabHistogramsFromContent(use_counter_middlefix);
|
||||
|
||||
gBrowser.selectedBrowser.loadURI(gHttpTestRoot + file);
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
|
||||
Cu.import("resource://gre/modules/PromiseUtils.jsm");
|
||||
yield new Promise(resolve => {
|
||||
await new Promise(resolve => {
|
||||
let listener = () => {
|
||||
removeEventListener("load", listener, true);
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1310768
|
||||
Cu.import("resource://testing-common/TestUtils.jsm");
|
||||
Cu.import("resource://testing-common/ContentTask.jsm");
|
||||
Cu.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
ContentTask.setTestScope(window.opener.wrappedJSObject);
|
||||
|
||||
let imports = ['SimpleTest', 'SpecialPowers', 'ok', 'is', 'info'];
|
||||
@@ -581,7 +580,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1310768
|
||||
'test:content-pagehide', msg => msg.data && (msg.data.title == prevTitle)));
|
||||
promises.push(BrowserTestUtils.waitForMessage(browser.messageManager,
|
||||
'test:content-pageshow', msg => msg.data && (msg.data.title == nextTitle)));
|
||||
promises.push(Task.spawn(navFn));
|
||||
promises.push((navFn)());
|
||||
|
||||
// For swapping remote browsers, we'll also receive Content:LocationChange
|
||||
if (browserToSwap && browser.isRemoteBrowser) {
|
||||
|
||||
@@ -70,7 +70,7 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
});
|
||||
}
|
||||
|
||||
function* addFrame(type, remote, height) {
|
||||
async function addFrame(type, remote, height) {
|
||||
let frame = document.createElementNS(NS[type], TAG[type]);
|
||||
frame.setAttribute("remote", remote);
|
||||
if (remote && type == "xul") {
|
||||
@@ -88,27 +88,27 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
frame.setAttribute("src", src);
|
||||
document.documentElement.appendChild(frame);
|
||||
let mm = frame.frameLoader.messageManager;
|
||||
yield once(mm, "test:load");
|
||||
await once(mm, "test:load");
|
||||
return frame;
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
yield SpecialPowers.pushPrefEnv(
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["dom.mozBrowserFramesEnabled", true],
|
||||
["network.disable.ipc.security", true]] });
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
for (let scenario of SCENARIOS) {
|
||||
let [ typeA, typeB, remote ] = scenario;
|
||||
remote = !!remote;
|
||||
let heightA = HEIGHTS[0];
|
||||
info(`Adding frame A, type ${typeA}, remote ${remote}, height ${heightA}`);
|
||||
let frameA = yield addFrame(typeA, remote, heightA);
|
||||
let frameA = await addFrame(typeA, remote, heightA);
|
||||
|
||||
let heightB = HEIGHTS[1];
|
||||
info(`Adding frame B, type ${typeB}, remote ${remote}, height ${heightB}`);
|
||||
let frameB = yield addFrame(typeB, remote, heightB);
|
||||
let frameB = await addFrame(typeB, remote, heightB);
|
||||
|
||||
let frameScriptFactory = function(name) {
|
||||
return `function() {
|
||||
@@ -144,23 +144,23 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
|
||||
info("Ping message manager for frame A");
|
||||
mmA.sendAsyncMessage("ping");
|
||||
let [ { data: pongA } ] = yield inflightA;
|
||||
let [ { data: pongA } ] = await inflightA;
|
||||
is(pongA, "A", "Frame A message manager gets reply A before swap");
|
||||
|
||||
info("Ping message manager for frame B");
|
||||
mmB.sendAsyncMessage("ping");
|
||||
let [ { data: pongB } ] = yield inflightB;
|
||||
let [ { data: pongB } ] = await inflightB;
|
||||
is(pongB, "B", "Frame B message manager gets reply B before swap");
|
||||
}
|
||||
|
||||
// Check height before swap
|
||||
{
|
||||
if (frameA.getContentDimensions) {
|
||||
let { height } = yield frameA.getContentDimensions();
|
||||
let { height } = await frameA.getContentDimensions();
|
||||
is(height, heightA, "Frame A's content height is 200px before swap");
|
||||
}
|
||||
if (frameB.getContentDimensions) {
|
||||
let { height } = yield frameB.getContentDimensions();
|
||||
let { height } = await frameB.getContentDimensions();
|
||||
is(height, heightB, "Frame B's content height is 400px before swap");
|
||||
}
|
||||
}
|
||||
@@ -178,23 +178,23 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
|
||||
info("Ping message manager for frame A");
|
||||
mmA.sendAsyncMessage("ping");
|
||||
let [ { data: pongA } ] = yield inflightA;
|
||||
let [ { data: pongA } ] = await inflightA;
|
||||
is(pongA, "B", "Frame A message manager acquired before swap gets reply B after swap");
|
||||
|
||||
info("Ping message manager for frame B");
|
||||
mmB.sendAsyncMessage("ping");
|
||||
let [ { data: pongB } ] = yield inflightB;
|
||||
let [ { data: pongB } ] = await inflightB;
|
||||
is(pongB, "A", "Frame B message manager acquired before swap gets reply A after swap");
|
||||
}
|
||||
|
||||
// Check height after swap
|
||||
{
|
||||
if (frameA.getContentDimensions) {
|
||||
let { height } = yield frameA.getContentDimensions();
|
||||
let { height } = await frameA.getContentDimensions();
|
||||
is(height, heightB, "Frame A's content height is 400px after swap");
|
||||
}
|
||||
if (frameB.getContentDimensions) {
|
||||
let { height } = yield frameB.getContentDimensions();
|
||||
let { height } = await frameB.getContentDimensions();
|
||||
is(height, heightA, "Frame B's content height is 200px after swap");
|
||||
}
|
||||
}
|
||||
@@ -209,12 +209,12 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
|
||||
info("Ping message manager for frame A");
|
||||
mmA.sendAsyncMessage("ping");
|
||||
let [ { data: pongA } ] = yield inflightA;
|
||||
let [ { data: pongA } ] = await inflightA;
|
||||
is(pongA, "B", "Frame A message manager acquired after swap gets reply B after swap");
|
||||
|
||||
info("Ping message manager for frame B");
|
||||
mmB.sendAsyncMessage("ping");
|
||||
let [ { data: pongB } ] = yield inflightB;
|
||||
let [ { data: pongB } ] = await inflightB;
|
||||
is(pongB, "A", "Frame B message manager acquired after swap gets reply A after swap");
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
|
||||
info("Check browser API for frame A");
|
||||
mmA.sendAsyncMessage("check-browser-api");
|
||||
let [ { data: apiA } ] = yield inflightA;
|
||||
let [ { data: apiA } ] = await inflightA;
|
||||
if (frameA.hasAttribute("mozbrowser")) {
|
||||
ok(apiA.exists && apiA.running, "Frame A browser API exists and is running");
|
||||
} else {
|
||||
@@ -237,7 +237,7 @@ Test swapFrameLoaders with different frame types and remoteness
|
||||
|
||||
info("Check browser API for frame B");
|
||||
mmB.sendAsyncMessage("check-browser-api");
|
||||
let [ { data: apiB } ] = yield inflightB;
|
||||
let [ { data: apiB } ] = await inflightB;
|
||||
if (frameB.hasAttribute("mozbrowser")) {
|
||||
ok(apiB.exists && apiB.running, "Frame B browser API exists and is running");
|
||||
} else {
|
||||
|
||||
@@ -47,7 +47,7 @@ function once(target, eventName, useCapture = false) {
|
||||
});
|
||||
}
|
||||
|
||||
function* loadFrame(attributes = {}) {
|
||||
async function loadFrame(attributes = {}) {
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("src", FRAME_URL);
|
||||
for (let key in attributes) {
|
||||
@@ -55,6 +55,6 @@ function* loadFrame(attributes = {}) {
|
||||
}
|
||||
let loaded = once(iframe, [ "load", "mozbrowserloadend" ]);
|
||||
document.body.appendChild(iframe);
|
||||
yield loaded;
|
||||
await loaded;
|
||||
return iframe;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<script>
|
||||
Components.utils.import("resource://testing-common/TestUtils.jsm");
|
||||
|
||||
function* runTest(url, initialHTML, finalHTML) {
|
||||
async function runTest(url, initialHTML, finalHTML) {
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.src = url;
|
||||
|
||||
@@ -39,7 +39,7 @@ function* runTest(url, initialHTML, finalHTML) {
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
// Wait for document-element-inserted to fire.
|
||||
let doc = yield promise;
|
||||
let doc = await promise;
|
||||
let win = doc.defaultView.wrappedJSObject;
|
||||
let root = doc.documentElement;
|
||||
|
||||
@@ -48,14 +48,14 @@ function* runTest(url, initialHTML, finalHTML) {
|
||||
is(root.outerHTML, initialHTML, "Should have initial HTML after document-element-inserted returns");
|
||||
is(win.scriptRan, undefined, "Script node should still not have run");
|
||||
|
||||
yield blockerPromise;
|
||||
await blockerPromise;
|
||||
|
||||
// Just after the promise that's blocking the parser fires, we shouldn't have
|
||||
// returned to the main event loop, so we should still have the initial HTML.
|
||||
is(root.outerHTML, initialHTML, "Should still have initial HTML");
|
||||
is(win.scriptRan, undefined, "Script node should still not have run");
|
||||
|
||||
yield new Promise(resolve => win.addEventListener("DOMContentLoaded", resolve, {once: true}));
|
||||
await new Promise(resolve => win.addEventListener("DOMContentLoaded", resolve, {once: true}));
|
||||
|
||||
// Parsing should have resumed, and we should have finished loading the document.
|
||||
is(root.outerHTML, finalHTML, "Should have final HTML");
|
||||
@@ -64,25 +64,25 @@ function* runTest(url, initialHTML, finalHTML) {
|
||||
iframe.remove();
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
yield runTest("http://mochi.test:8888/chrome/dom/base/test/file_inline_script.html",
|
||||
add_task(async function() {
|
||||
await runTest("http://mochi.test:8888/chrome/dom/base/test/file_inline_script.html",
|
||||
'<html lang="en"></html>',
|
||||
'<html lang="en"><head>\n <script>window.scriptRan = true;<\/script>\n <meta charset="utf-8">\n <title></title>\n</head>\n<body>\n <p>Hello Mochitest</p>\n\n\n</body></html>');
|
||||
|
||||
yield runTest("http://mochi.test:8888/chrome/dom/base/test/file_inline_script.xhtml",
|
||||
await runTest("http://mochi.test:8888/chrome/dom/base/test/file_inline_script.xhtml",
|
||||
'<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"></html>',
|
||||
'<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">\n<head>\n <script>window.scriptRan = true;<\/script>\n <title></title>\n</head>\n<body>\n <p>Hello Mochitest</p>\n</body>\n</html>');
|
||||
|
||||
yield runTest("http://mochi.test:8888/chrome/dom/base/test/file_external_script.html",
|
||||
await runTest("http://mochi.test:8888/chrome/dom/base/test/file_external_script.html",
|
||||
'<html lang="en"></html>',
|
||||
'<html lang="en"><head>\n <script src="file_script.js"><\/script>\n <meta charset="utf-8">\n <title></title>\n</head>\n<body>\n <p>Hello Mochitest</p>\n\n\n</body></html>');
|
||||
|
||||
yield runTest("http://mochi.test:8888/chrome/dom/base/test/file_external_script.xhtml",
|
||||
await runTest("http://mochi.test:8888/chrome/dom/base/test/file_external_script.xhtml",
|
||||
'<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"></html>',
|
||||
'<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">\n<head>\n <script src="file_script.js"><\/script>\n <title></title>\n</head>\n<body>\n <p>Hello Mochitest</p>\n</body>\n</html>');
|
||||
});
|
||||
|
||||
add_task(function* test_cleanup() {
|
||||
add_task(async function test_cleanup() {
|
||||
const TOPIC = "blocking-promise-destroyed";
|
||||
|
||||
const finalizationWitness = Components.classes["@mozilla.org/toolkit/finalizationwitness;1"]
|
||||
@@ -109,7 +109,7 @@ add_task(function* test_cleanup() {
|
||||
});
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
yield insertedPromise;
|
||||
await insertedPromise;
|
||||
|
||||
// Clear the promise reference, destroy the document, and force GC/CC. This should
|
||||
// trigger any potential leaks or cleanup issues.
|
||||
@@ -122,7 +122,7 @@ add_task(function* test_cleanup() {
|
||||
Components.utils.forceGC();
|
||||
|
||||
// Make sure the blocker promise has been collected.
|
||||
let [, data] = yield destroyedPromise;
|
||||
let [, data] = await destroyedPromise;
|
||||
is(data, url, "Should have correct finalizer URL");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,17 +19,17 @@ https://bugzilla.mozilla.org/1281963
|
||||
// __setPref(key, value)__.
|
||||
// Set a pref value asynchronously, returning a promise that resolves
|
||||
// when it succeeds.
|
||||
let setPref = function* (key, value) {
|
||||
let setPref = function(key, value) {
|
||||
return SpecialPowers.pushPrefEnv({"set": [[key, value]]});
|
||||
};
|
||||
|
||||
// Run a test to see that we don't expose the supported mimeTypes
|
||||
// or installed plugins when "privacy.resistFingerprinting" is active.
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let exampleMimeType = undefined,
|
||||
examplePlugin = undefined;
|
||||
// Disable fingerprinting resistance.
|
||||
yield setPref("privacy.resistFingerprinting", false);
|
||||
await setPref("privacy.resistFingerprinting", false);
|
||||
// Depending on the testing platform, we may have at least
|
||||
// one mimeType and plugin available.
|
||||
exampleMimeType = navigator.mimeTypes[0];
|
||||
@@ -47,7 +47,7 @@ add_task(function* () {
|
||||
}
|
||||
|
||||
// Now test with fingerprinting resistance enabled
|
||||
yield setPref("privacy.resistFingerprinting", true);
|
||||
await setPref("privacy.resistFingerprinting", true);
|
||||
if (exampleMimeType) {
|
||||
is(navigator.mimeTypes[exampleMimeType.type], undefined, "Don't reveal mime type");
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
<script class="testbody" type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
add_task(function*() {
|
||||
yield new Promise((r) => {
|
||||
add_task(async function() {
|
||||
await new Promise((r) => {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'file_explicit_user_agent.sjs', true);
|
||||
xhr.onreadystatechange = function() {
|
||||
@@ -30,7 +30,7 @@
|
||||
xhr.send(null);
|
||||
});
|
||||
|
||||
yield new Promise((r) => {
|
||||
await new Promise((r) => {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'file_explicit_user_agent.sjs', true);
|
||||
xhr.setRequestHeader('User-Agent', 'custom-ua/10.0');
|
||||
@@ -44,7 +44,7 @@
|
||||
xhr.send(null);
|
||||
});
|
||||
|
||||
var response = yield fetch('file_explicit_user_agent.sjs', {
|
||||
var response = await fetch('file_explicit_user_agent.sjs', {
|
||||
method: 'GET'
|
||||
});
|
||||
is(response.headers.get("Result-User-Agent"), navigator.userAgent,
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
var headers = new Headers();
|
||||
headers.set('User-Agent', 'custom-ua/20.0');
|
||||
var response2 = yield fetch('file_explicit_user_agent.sjs', {
|
||||
var response2 = await fetch('file_explicit_user_agent.sjs', {
|
||||
method: 'GET',
|
||||
headers: headers,
|
||||
});
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
add_task(function*() {
|
||||
yield SpecialPowers.pushPrefEnv(
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["dom.mozBrowserFramesEnabled", true],
|
||||
["network.disable.ipc.security", true]] });
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
// Create <iframe mozbrowser>
|
||||
let frame = yield loadFrame({
|
||||
let frame = await loadFrame({
|
||||
mozbrowser: "true",
|
||||
// FIXME: Bug 1270790
|
||||
remote: true
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
add_task(function*() {
|
||||
yield SpecialPowers.pushPrefEnv(
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["dom.mozBrowserFramesEnabled", true],
|
||||
["network.disable.ipc.security", true]] });
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
// Create <iframe mozbrowser>
|
||||
let frame = yield loadFrame({
|
||||
let frame = await loadFrame({
|
||||
mozbrowser: "true"
|
||||
});
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
<iframe id="target-iframe"></iframe>
|
||||
<script type="application/javascript">
|
||||
|
||||
add_task(function*() {
|
||||
yield SpecialPowers.pushPrefEnv(
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv(
|
||||
{ "set": [["network.disable.ipc.security", true]] });
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
let iframe = document.querySelector("#target-iframe");
|
||||
|
||||
let win = SpecialPowers.wrap(iframe).contentWindow;
|
||||
@@ -26,7 +26,7 @@ add_task(function*() {
|
||||
// Add private browsing ID to docShell origin and load document.
|
||||
docShell.setOriginAttributes({privateBrowsingId: 1});
|
||||
|
||||
yield new Promise(resolve => {
|
||||
await new Promise(resolve => {
|
||||
iframe.addEventListener("load", resolve, true);
|
||||
|
||||
iframe.src = SimpleTest.getTestFileURL("file_receiveMessage.html");
|
||||
@@ -45,10 +45,10 @@ add_task(function*() {
|
||||
|
||||
// Post to the content window via SpecialPowers' system principal scope.
|
||||
win.postMessage("Hello. o/", "http://mochi.test:8888");
|
||||
yield new Promise(resolve => setTimeout(resolve, 0));
|
||||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
|
||||
SimpleTest.endMonitorConsole();
|
||||
yield consolePromise;
|
||||
await consolePromise;
|
||||
|
||||
// Check that the window received and handled the message.
|
||||
is(win.document.body.textContent, "|Hello. o/",
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
const URL = "http://mochi.test:8888/browser/dom/broadcastchannel/tests/blank.html";
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
var win1 = OpenBrowserWindow({private: true});
|
||||
var win1Promise = new win1.Promise(resolve => {
|
||||
win1.addEventListener("load", function() {
|
||||
resolve();
|
||||
}, {once: true});
|
||||
});
|
||||
yield win1Promise;
|
||||
await win1Promise;
|
||||
|
||||
var win2 = OpenBrowserWindow({private: false});
|
||||
var win2Promise = new win2.Promise(resolve => {
|
||||
@@ -18,14 +18,14 @@ add_task(function*() {
|
||||
resolve();
|
||||
}, {once: true});
|
||||
});
|
||||
yield win2Promise;
|
||||
await win2Promise;
|
||||
|
||||
var tab1 = win1.gBrowser.addTab(URL);
|
||||
yield BrowserTestUtils.browserLoaded(win1.gBrowser.getBrowserForTab(tab1));
|
||||
await BrowserTestUtils.browserLoaded(win1.gBrowser.getBrowserForTab(tab1));
|
||||
var browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
var tab2 = win2.gBrowser.addTab(URL);
|
||||
yield BrowserTestUtils.browserLoaded(win2.gBrowser.getBrowserForTab(tab2));
|
||||
await BrowserTestUtils.browserLoaded(win2.gBrowser.getBrowserForTab(tab2));
|
||||
var browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
var p1 = ContentTask.spawn(browser1, null, function(opts) {
|
||||
@@ -42,7 +42,7 @@ add_task(function*() {
|
||||
});
|
||||
});
|
||||
|
||||
yield ContentTask.spawn(browser1, null, function(opts) {
|
||||
await ContentTask.spawn(browser1, null, function(opts) {
|
||||
return new content.window.Promise(resolve => {
|
||||
var bc = new content.window.BroadcastChannel('foobar');
|
||||
bc.postMessage('hello world from private browsing');
|
||||
@@ -50,7 +50,7 @@ add_task(function*() {
|
||||
});
|
||||
});
|
||||
|
||||
yield ContentTask.spawn(browser2, null, function(opts) {
|
||||
await ContentTask.spawn(browser2, null, function(opts) {
|
||||
return new content.window.Promise(resolve => {
|
||||
var bc = new content.window.BroadcastChannel('foobar');
|
||||
bc.postMessage('hello world from non private browsing');
|
||||
@@ -58,15 +58,15 @@ add_task(function*() {
|
||||
});
|
||||
});
|
||||
|
||||
var what1 = yield p1;
|
||||
var what1 = await p1;
|
||||
ok(what1, 'hello world from private browsing', 'No messages received from the other window.');
|
||||
|
||||
var what2 = yield p2;
|
||||
var what2 = await p2;
|
||||
ok(what1, 'hello world from non private browsing', 'No messages received from the other window.');
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.closeWindow(win1);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.closeWindow(win1);
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
yield BrowserTestUtils.closeWindow(win2);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.closeWindow(win2);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,6 @@ var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/BrowserElementPromptService.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ManifestFinder",
|
||||
"resource://gre/modules/ManifestFinder.jsm");
|
||||
@@ -1308,13 +1307,13 @@ BrowserElementChild.prototype = {
|
||||
docShell.contentViewer.fullZoom = data.json.zoom;
|
||||
},
|
||||
|
||||
_recvGetWebManifest: Task.async(function* (data) {
|
||||
async _recvGetWebManifest(data) {
|
||||
debug(`Received GetWebManifest message: (${data.json.id})`);
|
||||
let manifest = null;
|
||||
let hasManifest = ManifestFinder.contentHasManifestLink(content);
|
||||
if (hasManifest) {
|
||||
try {
|
||||
manifest = yield ManifestObtainer.contentObtainManifest(content);
|
||||
manifest = await ManifestObtainer.contentObtainManifest(content);
|
||||
} catch (e) {
|
||||
sendAsyncMsg('got-web-manifest', {
|
||||
id: data.json.id,
|
||||
@@ -1327,7 +1326,7 @@ BrowserElementChild.prototype = {
|
||||
id: data.json.id,
|
||||
successRv: manifest
|
||||
});
|
||||
}),
|
||||
},
|
||||
|
||||
_initFinder: function() {
|
||||
if (!this._finder) {
|
||||
|
||||
@@ -9,24 +9,24 @@ browserElementTestHelpers.setEnabledPref(true);
|
||||
|
||||
// request to load a manifest from a page that doesn't have a manifest.
|
||||
// The expected result to be null.
|
||||
var test1 = async(function* () {
|
||||
var manifest = yield requestManifest('file_empty.html');
|
||||
var test1 = async(async function() {
|
||||
var manifest = await requestManifest('file_empty.html');
|
||||
is(manifest, null, 'it should be null.');
|
||||
});
|
||||
|
||||
// request to load a manifest from a page that has a manifest.
|
||||
// The expected manifest to have a property name whose value is 'pass'.
|
||||
var test2 = async(function* () {
|
||||
var manifest = yield requestManifest('file_web_manifest.html');
|
||||
var test2 = async(async function() {
|
||||
var manifest = await requestManifest('file_web_manifest.html');
|
||||
is(manifest && manifest.name, 'pass', 'it should return a manifest with name pass.');
|
||||
});
|
||||
|
||||
// Cause an exception by attempting to fetch a file URL,
|
||||
// expect onerror to be called.
|
||||
var test3 = async(function* () {
|
||||
var test3 = async(async function() {
|
||||
var gotError = false;
|
||||
try {
|
||||
yield requestManifest('file_illegal_web_manifest.html');
|
||||
await requestManifest('file_illegal_web_manifest.html');
|
||||
} catch (err) {
|
||||
gotError = true;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
yield spin();
|
||||
add_task(async function() {
|
||||
await spin();
|
||||
var draggable = document.getElementById('image');
|
||||
var over = document.getElementById('over');
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
synthesizeDrop(draggable, over, null, null);
|
||||
|
||||
// Wait for the getAsString callbacks to complete
|
||||
yield spin();
|
||||
await spin();
|
||||
is(getAsStringCalled, 2, "getAsString should be called twice");
|
||||
|
||||
// Sanity-check to make sure that the events were actually run
|
||||
|
||||
@@ -7,11 +7,11 @@ var {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
|
||||
const BASE_URI = "http://mochi.test:8888/browser/dom/file/ipc/tests/empty.html";
|
||||
|
||||
// More than 1mb memory blob childA-parent-childB.
|
||||
add_task(function* test_CtoPtoC_big() {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
add_task(async function test_CtoPtoC_big() {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
let blob = yield ContentTask.spawn(browser1, null, function() {
|
||||
let blob = await ContentTask.spawn(browser1, null, function() {
|
||||
let blob = new Blob([new Array(1024*1024).join('123456789ABCDEF')]);
|
||||
return blob;
|
||||
});
|
||||
@@ -19,10 +19,10 @@ add_task(function* test_CtoPtoC_big() {
|
||||
ok(blob, "CtoPtoC-big: We have a blob!");
|
||||
is(blob.size, new Array(1024*1024).join('123456789ABCDEF').length, "CtoPtoC-big: The size matches");
|
||||
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
let status = yield ContentTask.spawn(browser2, blob, function(blob) {
|
||||
let status = await ContentTask.spawn(browser2, blob, function(blob) {
|
||||
return new Promise(resolve => {
|
||||
let fr = new content.FileReader();
|
||||
fr.readAsText(blob);
|
||||
@@ -34,16 +34,16 @@ add_task(function* test_CtoPtoC_big() {
|
||||
|
||||
ok(status, "CtoPtoC-big: Data match!");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
// Less than 1mb memory blob childA-parent-childB.
|
||||
add_task(function* test_CtoPtoC_small() {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
add_task(async function test_CtoPtoC_small() {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
let blob = yield ContentTask.spawn(browser1, null, function() {
|
||||
let blob = await ContentTask.spawn(browser1, null, function() {
|
||||
let blob = new Blob(["hello world!"]);
|
||||
return blob;
|
||||
});
|
||||
@@ -51,10 +51,10 @@ add_task(function* test_CtoPtoC_small() {
|
||||
ok(blob, "CtoPtoC-small: We have a blob!");
|
||||
is(blob.size, "hello world!".length, "CtoPtoC-small: The size matches");
|
||||
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
let status = yield ContentTask.spawn(browser2, blob, function(blob) {
|
||||
let status = await ContentTask.spawn(browser2, blob, function(blob) {
|
||||
return new Promise(resolve => {
|
||||
let fr = new content.FileReader();
|
||||
fr.readAsText(blob);
|
||||
@@ -66,26 +66,26 @@ add_task(function* test_CtoPtoC_small() {
|
||||
|
||||
ok(status, "CtoPtoC-small: Data match!");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
// More than 1mb memory blob childA-parent-childB: BroadcastChannel
|
||||
add_task(function* test_CtoPtoC_bc_big() {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
add_task(async function test_CtoPtoC_bc_big() {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
yield ContentTask.spawn(browser1, null, function() {
|
||||
await ContentTask.spawn(browser1, null, function() {
|
||||
var bc = new content.BroadcastChannel('test');
|
||||
bc.onmessage = function() {
|
||||
bc.postMessage(new Blob([new Array(1024*1024).join('123456789ABCDEF')]));
|
||||
}
|
||||
});
|
||||
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
let status = yield ContentTask.spawn(browser2, null, function() {
|
||||
let status = await ContentTask.spawn(browser2, null, function() {
|
||||
return new Promise(resolve => {
|
||||
var bc = new content.BroadcastChannel('test');
|
||||
bc.onmessage = function(e) {
|
||||
@@ -102,26 +102,26 @@ add_task(function* test_CtoPtoC_bc_big() {
|
||||
|
||||
ok(status, "CtoPtoC-broadcastChannel-big: Data match!");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
// Less than 1mb memory blob childA-parent-childB: BroadcastChannel
|
||||
add_task(function* test_CtoPtoC_bc_small() {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
add_task(async function test_CtoPtoC_bc_small() {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
yield ContentTask.spawn(browser1, null, function() {
|
||||
await ContentTask.spawn(browser1, null, function() {
|
||||
var bc = new content.BroadcastChannel('test');
|
||||
bc.onmessage = function() {
|
||||
bc.postMessage(new Blob(["hello world!"]));
|
||||
}
|
||||
});
|
||||
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
let status = yield ContentTask.spawn(browser2, null, function() {
|
||||
let status = await ContentTask.spawn(browser2, null, function() {
|
||||
return new Promise(resolve => {
|
||||
var bc = new content.BroadcastChannel('test');
|
||||
bc.onmessage = function(e) {
|
||||
@@ -138,23 +138,23 @@ add_task(function* test_CtoPtoC_bc_small() {
|
||||
|
||||
ok(status, "CtoPtoC-broadcastChannel-small: Data match!");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
// blob URL childA-parent-childB
|
||||
add_task(function* test_CtoPtoC_bc_small() {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
add_task(async function test_CtoPtoC_bc_small() {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
let blobURL = yield ContentTask.spawn(browser1, null, function() {
|
||||
let blobURL = await ContentTask.spawn(browser1, null, function() {
|
||||
return content.URL.createObjectURL(new content.Blob(["hello world!"]));
|
||||
});
|
||||
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
let status = yield ContentTask.spawn(browser2, blobURL, function(blobURL) {
|
||||
let status = await ContentTask.spawn(browser2, blobURL, function(blobURL) {
|
||||
return new Promise(resolve => {
|
||||
var xhr = new content.XMLHttpRequest();
|
||||
xhr.open("GET", blobURL);
|
||||
@@ -168,16 +168,16 @@ add_task(function* test_CtoPtoC_bc_small() {
|
||||
|
||||
ok(status, "CtoPtoC-blobURL: Data match!");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
// Multipart Blob childA-parent-childB.
|
||||
add_task(function* test_CtoPtoC_multipart() {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
add_task(async function test_CtoPtoC_multipart() {
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser1 = gBrowser.getBrowserForTab(tab1);
|
||||
|
||||
let blob = yield ContentTask.spawn(browser1, null, function() {
|
||||
let blob = await ContentTask.spawn(browser1, null, function() {
|
||||
return new Blob(["!"]);
|
||||
});
|
||||
|
||||
@@ -186,10 +186,10 @@ add_task(function* test_CtoPtoC_multipart() {
|
||||
|
||||
let newBlob = new Blob(["world", blob]);
|
||||
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI);
|
||||
let browser2 = gBrowser.getBrowserForTab(tab2);
|
||||
|
||||
let status = yield ContentTask.spawn(browser2, newBlob, function(blob) {
|
||||
let status = await ContentTask.spawn(browser2, newBlob, function(blob) {
|
||||
return new Promise(resolve => {
|
||||
let fr = new content.FileReader();
|
||||
fr.readAsText(new Blob(["hello ", blob]));
|
||||
@@ -201,6 +201,6 @@ add_task(function* test_CtoPtoC_multipart() {
|
||||
|
||||
ok(status, "CtoPtoC-multipart: Data match!");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Tests that the DOMDocElementInserted event is visible on the frame
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
let tab = BrowserTestUtils.addTab(gBrowser);
|
||||
let uri = "data:text/html;charset=utf-8,<html/>"
|
||||
|
||||
@@ -17,7 +17,7 @@ add_task(function*() {
|
||||
});
|
||||
|
||||
tab.linkedBrowser.loadURI(uri);
|
||||
let loadedURI = yield eventPromise;
|
||||
let loadedURI = await eventPromise;
|
||||
is(loadedURI, uri, "Should have seen the event for the right URI");
|
||||
|
||||
gBrowser.removeTab(tab);
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
const kPage = "http://example.org/browser/" +
|
||||
"dom/html/test/file_content_contextmenu.html";
|
||||
|
||||
add_task(function* () {
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: kPage
|
||||
}, function*(aBrowser) {
|
||||
}, async function(aBrowser) {
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
ok(contextMenu, "Got context menu");
|
||||
|
||||
@@ -17,7 +17,7 @@ add_task(function* () {
|
||||
EventUtils.synthesizeMouse(aBrowser, window.innerWidth / 3,
|
||||
window.innerHeight / 3,
|
||||
{type: "contextmenu", button: 2}, window);
|
||||
yield popupShownPromise;
|
||||
await popupShownPromise;
|
||||
is(contextMenu.state, "open", "Should have opened context menu");
|
||||
|
||||
let pageMenuSep = document.getElementById("page-menu-separator");
|
||||
@@ -31,8 +31,8 @@ add_task(function* () {
|
||||
let testMenuItem = testMenuSep.previousSibling;
|
||||
is(testMenuItem.label, "Test Context Menu Click", "Got context menu item");
|
||||
|
||||
let promiseCtxMenuClick = ContentTask.spawn(aBrowser, null, function*() {
|
||||
yield new Promise(resolve => {
|
||||
let promiseCtxMenuClick = ContentTask.spawn(aBrowser, null, async function() {
|
||||
await new Promise(resolve => {
|
||||
let Ci = Components.interfaces;
|
||||
let windowUtils = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
@@ -45,6 +45,6 @@ add_task(function* () {
|
||||
});
|
||||
});
|
||||
EventUtils.synthesizeMouseAtCenter(testMenuItem, {}, window);
|
||||
yield promiseCtxMenuClick;
|
||||
await promiseCtxMenuClick;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,10 +62,10 @@ function captureUnexpectedFullscreenChange() {
|
||||
ok(false, "Caught an unexpected fullscreen change");
|
||||
}
|
||||
|
||||
function* temporaryRemoveUnexpectedFullscreenChangeCapture(callback) {
|
||||
async function temporaryRemoveUnexpectedFullscreenChangeCapture(callback) {
|
||||
gMessageManager.removeMessageListener(
|
||||
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
|
||||
yield* callback();
|
||||
await callback();
|
||||
gMessageManager.addMessageListener(
|
||||
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
|
||||
}
|
||||
@@ -74,10 +74,10 @@ function captureUnexpectedKeyEvent(type) {
|
||||
ok(false, `Caught an unexpected ${type} event`);
|
||||
}
|
||||
|
||||
function* temporaryRemoveUnexpectedKeyEventCapture(callback) {
|
||||
async function temporaryRemoveUnexpectedKeyEventCapture(callback) {
|
||||
gMessageManager.removeMessageListener(
|
||||
"Test:KeyReceived", captureUnexpectedKeyEvent);
|
||||
yield* callback();
|
||||
await callback();
|
||||
gMessageManager.addMessageListener(
|
||||
"Test:KeyReceived", captureUnexpectedKeyEvent);
|
||||
}
|
||||
@@ -102,8 +102,8 @@ function receiveExpectedKeyEvents(keyCode) {
|
||||
const kPage = "http://example.org/browser/" +
|
||||
"dom/html/test/file_fullscreen-api-keys.html";
|
||||
|
||||
add_task(function* () {
|
||||
yield pushPrefs(
|
||||
add_task(async function() {
|
||||
await pushPrefs(
|
||||
["full-screen-api.transition-duration.enter", "0 0"],
|
||||
["full-screen-api.transition-duration.leave", "0 0"]);
|
||||
|
||||
@@ -111,7 +111,7 @@ add_task(function* () {
|
||||
let browser = tab.linkedBrowser;
|
||||
gBrowser.selectedTab = tab;
|
||||
registerCleanupFunction(() => gBrowser.removeTab(tab));
|
||||
yield waitForDocLoadComplete();
|
||||
await waitForDocLoadComplete();
|
||||
|
||||
gMessageManager = browser.messageManager;
|
||||
gMessageManager.loadFrameScript(
|
||||
@@ -119,7 +119,7 @@ add_task(function* () {
|
||||
|
||||
// Wait for the document being actived, so that
|
||||
// fullscreen request won't be denied.
|
||||
yield promiseOneMessage("Test:Activated");
|
||||
await promiseOneMessage("Test:Activated");
|
||||
|
||||
// Register listener to capture unexpected events
|
||||
gMessageManager.addMessageListener(
|
||||
@@ -138,29 +138,29 @@ add_task(function* () {
|
||||
info(`Test keycode ${code} (${keyCode})`);
|
||||
|
||||
info("Enter fullscreen");
|
||||
yield* temporaryRemoveUnexpectedFullscreenChangeCapture(function* () {
|
||||
await temporaryRemoveUnexpectedFullscreenChangeCapture(async function() {
|
||||
gMessageManager.sendAsyncMessage("Test:RequestFullscreen");
|
||||
let state = yield promiseOneMessage("Test:FullscreenChanged");
|
||||
let state = await promiseOneMessage("Test:FullscreenChanged");
|
||||
ok(state, "The content should have entered fullscreen");
|
||||
ok(document.fullscreenElement,
|
||||
"The chrome should also be in fullscreen");
|
||||
});
|
||||
|
||||
info("Dispatch untrusted key events from content");
|
||||
yield* temporaryRemoveUnexpectedKeyEventCapture(function* () {
|
||||
await temporaryRemoveUnexpectedKeyEventCapture(async function() {
|
||||
let promiseExpectedKeyEvents = receiveExpectedKeyEvents(keyCode);
|
||||
gMessageManager.sendAsyncMessage("Test:DispatchUntrustedKeyEvents", code);
|
||||
yield promiseExpectedKeyEvents;
|
||||
await promiseExpectedKeyEvents;
|
||||
});
|
||||
|
||||
info("Send trusted key events");
|
||||
yield* temporaryRemoveUnexpectedFullscreenChangeCapture(function* () {
|
||||
yield* temporaryRemoveUnexpectedKeyEventCapture(function* () {
|
||||
await temporaryRemoveUnexpectedFullscreenChangeCapture(async function() {
|
||||
await temporaryRemoveUnexpectedKeyEventCapture(async function() {
|
||||
let promiseExpectedKeyEvents = suppressed ?
|
||||
Promise.resolve() : receiveExpectedKeyEvents(keyCode);
|
||||
EventUtils.synthesizeKey(code, {});
|
||||
yield promiseExpectedKeyEvents;
|
||||
let state = yield promiseOneMessage("Test:FullscreenChanged");
|
||||
await promiseExpectedKeyEvents;
|
||||
let state = await promiseOneMessage("Test:FullscreenChanged");
|
||||
ok(!state, "The content should have exited fullscreen");
|
||||
ok(!document.fullscreenElement,
|
||||
"The chrome should also have exited fullscreen");
|
||||
|
||||
@@ -43,8 +43,8 @@ function captureUnexpectedFullscreenChange() {
|
||||
|
||||
const kPage = "http://example.org/browser/dom/html/test/dummy_page.html";
|
||||
|
||||
add_task(function* () {
|
||||
yield pushPrefs(
|
||||
add_task(async function() {
|
||||
await pushPrefs(
|
||||
["full-screen-api.transition-duration.enter", "0 0"],
|
||||
["full-screen-api.transition-duration.leave", "0 0"]);
|
||||
|
||||
@@ -52,7 +52,7 @@ add_task(function* () {
|
||||
registerCleanupFunction(() => gBrowser.removeTab(tab));
|
||||
let browser = tab.linkedBrowser;
|
||||
gBrowser.selectedTab = tab;
|
||||
yield waitForDocLoadComplete();
|
||||
await waitForDocLoadComplete();
|
||||
|
||||
gMessageManager = browser.messageManager;
|
||||
gMessageManager.loadFrameScript(
|
||||
@@ -60,7 +60,7 @@ add_task(function* () {
|
||||
|
||||
// Wait for the document being activated, so that
|
||||
// fullscreen request won't be denied.
|
||||
yield promiseOneMessage("Test:Activated");
|
||||
await promiseOneMessage("Test:Activated");
|
||||
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
ok(contextMenu, "Got context menu");
|
||||
@@ -68,7 +68,7 @@ add_task(function* () {
|
||||
let state;
|
||||
info("Enter DOM fullscreen");
|
||||
gMessageManager.sendAsyncMessage("Test:RequestFullscreen");
|
||||
state = yield promiseOneMessage("Test:FullscreenChanged");
|
||||
state = await promiseOneMessage("Test:FullscreenChanged");
|
||||
ok(state, "The content should have entered fullscreen");
|
||||
ok(document.fullscreenElement, "The chrome should also be in fullscreen");
|
||||
gMessageManager.addMessageListener(
|
||||
@@ -79,20 +79,20 @@ add_task(function* () {
|
||||
let popupShownPromise = promiseWaitForEvent(window, "popupshown");
|
||||
EventUtils.synthesizeMouse(browser, screen.width / 2, screen.height / 2,
|
||||
{type: "contextmenu", button: 2}, window);
|
||||
yield popupShownPromise;
|
||||
await popupShownPromise;
|
||||
is(contextMenu.state, "open", "Should have opened context menu");
|
||||
|
||||
info("Send the first escape");
|
||||
let popupHidePromise = promiseWaitForEvent(window, "popuphidden");
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
yield popupHidePromise;
|
||||
await popupHidePromise;
|
||||
is(contextMenu.state, "closed", "Should have closed context menu");
|
||||
|
||||
// Wait a small time to confirm that the first ESC key
|
||||
// does not exit fullscreen.
|
||||
yield new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
gMessageManager.sendAsyncMessage("Test:QueryFullscreenState");
|
||||
state = yield promiseOneMessage("Test:FullscreenState");
|
||||
state = await promiseOneMessage("Test:FullscreenState");
|
||||
ok(state, "The content should still be in fullscreen");
|
||||
ok(document.fullscreenElement, "The chrome should still be in fullscreen");
|
||||
|
||||
@@ -101,7 +101,7 @@ add_task(function* () {
|
||||
"Test:FullscreenChanged", captureUnexpectedFullscreenChange);
|
||||
let fullscreenExitPromise = promiseOneMessage("Test:FullscreenChanged");
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
state = yield fullscreenExitPromise;
|
||||
state = await fullscreenExitPromise;
|
||||
ok(!state, "The content should have exited fullscreen");
|
||||
ok(!document.fullscreenElement, "The chrome should have exited fullscreen");
|
||||
});
|
||||
|
||||
@@ -155,13 +155,13 @@ function testAutocomplete(aField, aType, aEnabled) {
|
||||
// getAutocompleteInfo() should be able to parse all tokens as defined
|
||||
// in the spec regardless of whether dom.forms.autocomplete.experimental pref
|
||||
// is on or off.
|
||||
add_task(function* testAutocompletePreferenceEnabled() {
|
||||
yield SpecialPowers.pushPrefEnv({"set": [["dom.forms.autocomplete.experimental", true]]}, testInputTypes);
|
||||
add_task(async function testAutocompletePreferenceEnabled() {
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.forms.autocomplete.experimental", true]]}, testInputTypes);
|
||||
testAutocompleteInfoValue(true);
|
||||
});
|
||||
|
||||
add_task(function* testAutocompletePreferenceDisabled() {
|
||||
yield SpecialPowers.pushPrefEnv({"set": [["dom.forms.autocomplete.experimental", false]]}, testInputTypes);
|
||||
add_task(async function testAutocompletePreferenceDisabled() {
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.forms.autocomplete.experimental", false]]}, testInputTypes);
|
||||
testAutocompleteInfoValue(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -20,24 +20,23 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
addLoadEvent(function () {
|
||||
Task.spawn(function* run_tests() {
|
||||
(async function run_tests() {
|
||||
while (tests.length) {
|
||||
let test = tests.shift();
|
||||
info("-- running " + test.name);
|
||||
yield* test();
|
||||
await test();
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
})();
|
||||
});
|
||||
|
||||
let tests = [
|
||||
|
||||
// Ensure that sending pings is enabled.
|
||||
function* setup() {
|
||||
function setup() {
|
||||
Services.prefs.setBoolPref("browser.send_pings", true);
|
||||
Services.prefs.setIntPref("browser.send_pings.max_per_link", -1);
|
||||
Services.prefs.setBoolPref("security.mixed_content.block_active_content", false);
|
||||
@@ -57,7 +56,7 @@ let tests = [
|
||||
// HTTP header with, as its value, the address of the document containing the
|
||||
// hyperlink, and a Ping-To HTTP header with, as its value, the target URL.
|
||||
// The request must not include a Referer (sic) HTTP header.
|
||||
function* same_origin() {
|
||||
async function same_origin() {
|
||||
let from = "/ping-from/" + Math.random();
|
||||
let to = "/ping-to/" + Math.random();
|
||||
let ping = "/ping/" + Math.random();
|
||||
@@ -82,10 +81,10 @@ let tests = [
|
||||
navigate(base + from);
|
||||
|
||||
// Wait until the target and ping url have loaded.
|
||||
yield Promise.all([promiseHref, promisePing]);
|
||||
await Promise.all([promiseHref, promisePing]);
|
||||
|
||||
// Cleanup.
|
||||
yield stopServer(server);
|
||||
await stopServer(server);
|
||||
},
|
||||
|
||||
// If the origins are different, but the document containing the hyperlink
|
||||
@@ -94,7 +93,7 @@ let tests = [
|
||||
// address of the document containing the hyperlink, a Ping-From HTTP header
|
||||
// with the same value, and a Ping-To HTTP header with, as its value, target
|
||||
// URL.
|
||||
function* diff_origin() {
|
||||
async function diff_origin() {
|
||||
let from = "/ping-from/" + Math.random();
|
||||
let to = "/ping-to/" + Math.random();
|
||||
let ping = "/ping/" + Math.random();
|
||||
@@ -125,11 +124,11 @@ let tests = [
|
||||
navigate(base + from);
|
||||
|
||||
// Wait until the target and ping url have loaded.
|
||||
yield Promise.all([promiseHref, promisePing]);
|
||||
await Promise.all([promiseHref, promisePing]);
|
||||
|
||||
// Cleanup.
|
||||
yield stopServer(server);
|
||||
yield stopServer(server2);
|
||||
await stopServer(server);
|
||||
await stopServer(server2);
|
||||
},
|
||||
|
||||
// If the origins are different and the document containing the hyperlink
|
||||
@@ -137,7 +136,7 @@ let tests = [
|
||||
// must include a Ping-To HTTP header with, as its value, target URL. The
|
||||
// request must neither include a Referer (sic) HTTP header nor include a
|
||||
// Ping-From HTTP header.
|
||||
function* diff_origin_secure_referrer() {
|
||||
async function diff_origin_secure_referrer() {
|
||||
let ping = "/ping/" + Math.random();
|
||||
let server = new HttpServer();
|
||||
|
||||
@@ -155,15 +154,15 @@ let tests = [
|
||||
server.identity.primaryPort + ping);
|
||||
|
||||
// Wait until the ping has been sent.
|
||||
yield promisePing;
|
||||
await promisePing;
|
||||
|
||||
// Cleanup.
|
||||
yield stopServer(server);
|
||||
await stopServer(server);
|
||||
},
|
||||
|
||||
// Test that the <a ping> attribute is properly tokenized using ASCII white
|
||||
// space characters as separators.
|
||||
function* tokenize_white_space() {
|
||||
async function tokenize_white_space() {
|
||||
let from = "/ping-from/" + Math.random();
|
||||
let to = "/ping-to/" + Math.random();
|
||||
|
||||
@@ -197,10 +196,10 @@ let tests = [
|
||||
navigate(base + from);
|
||||
|
||||
// Wait until the target and ping url have loaded.
|
||||
yield Promise.all([promiseHref, ...pingPathHandlers]);
|
||||
await Promise.all([promiseHref, ...pingPathHandlers]);
|
||||
|
||||
// Cleanup.
|
||||
yield stopServer(server);
|
||||
await stopServer(server);
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -63,45 +63,45 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1166138
|
||||
}
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
yield startPromise;
|
||||
add_task(async function() {
|
||||
await startPromise;
|
||||
var image = document.querySelector('img');
|
||||
is(image.currentSrc, img2x, "initial scale must be 2x");
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['layout.css.devPixelsPerPx', 1]]});
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(image.currentSrc, img1x, "pre-existing img tag to 1x");
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['layout.css.devPixelsPerPx', 2]]});
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(image.currentSrc, img2x, "pre-existing img tag to 2x");
|
||||
|
||||
// Try removing & re-adding the image
|
||||
document.body.removeChild(image);
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['layout.css.devPixelsPerPx', 1]]});
|
||||
yield spin(false); // No load should occur because the element is unbound
|
||||
await spin(false); // No load should occur because the element is unbound
|
||||
|
||||
document.body.appendChild(image);
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(image.currentSrc, img1x, "remove and re-add tag after changing to 1x");
|
||||
|
||||
document.body.removeChild(image);
|
||||
SpecialPowers.pushPrefEnv({'set': [['layout.css.devPixelsPerPx', 2]]});
|
||||
yield spin(false); // No load should occur because the element is unbound
|
||||
await spin(false); // No load should occur because the element is unbound
|
||||
|
||||
document.body.appendChild(image);
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(image.currentSrc, img2x, "remove and re-add tag after changing to 2x");
|
||||
|
||||
// get rid of the srcset attribute! It should become the default
|
||||
image.removeAttribute('srcset');
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(image.currentSrc, imgdef, "remove srcset attribute");
|
||||
|
||||
// Setting srcset again should return it to the correct value
|
||||
image.setAttribute('srcset', "file_bug1166138_1x.png 1x, file_bug1166138_2x.png 2x");
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(image.currentSrc, img2x, "restore srcset attribute");
|
||||
|
||||
// Create a new image
|
||||
@@ -111,14 +111,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1166138
|
||||
image.removeEventListener('load', onLoad);
|
||||
|
||||
document.body.appendChild(newImage);
|
||||
yield spin(false); // no load event should fire - as the image has no attributes
|
||||
await spin(false); // no load event should fire - as the image has no attributes
|
||||
is(newImage.currentSrc, "", "New element with no attributes");
|
||||
newImage.setAttribute('srcset', "file_bug1166138_1x.png 1x, file_bug1166138_2x.png 2x");
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(newImage.currentSrc, img2x, "Adding srcset attribute");
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['layout.css.devPixelsPerPx', 1]]});
|
||||
yield spin(true);
|
||||
await spin(true);
|
||||
is(newImage.currentSrc, img1x, "new image after switching to 1x");
|
||||
is(image.currentSrc, img1x, "old image after switching to 1x");
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ const testPageURL = "http://mochi.test:8888/browser/" +
|
||||
const notificationID = "indexedDB-permissions-prompt";
|
||||
|
||||
function promiseMessage(aMessage, browser) {
|
||||
return ContentTask.spawn(browser.selectedBrowser, aMessage, function* (aMessage) {
|
||||
yield new Promise((resolve, reject) => {
|
||||
return ContentTask.spawn(browser.selectedBrowser, aMessage, async function(aMessage) {
|
||||
await new Promise((resolve, reject) => {
|
||||
content.addEventListener("message", function(event) {
|
||||
is(event.data, aMessage, "received " + aMessage);
|
||||
if (event.data == aMessage)
|
||||
@@ -21,7 +21,7 @@ function promiseMessage(aMessage, browser) {
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* test1() {
|
||||
add_task(async function test1() {
|
||||
removePermission(testPageURL, "indexedDB");
|
||||
|
||||
info("creating tab");
|
||||
@@ -29,7 +29,7 @@ add_task(function* test1() {
|
||||
|
||||
info("loading test page: " + testPageURL);
|
||||
gBrowser.selectedBrowser.loadURI(testPageURL);
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
registerPopupEventHandler("popupshowing", function() {
|
||||
ok(true, "prompt showing");
|
||||
@@ -42,7 +42,7 @@ add_task(function* test1() {
|
||||
ok(true, "prompt hidden");
|
||||
});
|
||||
|
||||
yield promiseMessage("InvalidStateError", gBrowser);
|
||||
await promiseMessage("InvalidStateError", gBrowser);
|
||||
|
||||
is(getPermission(testPageURL, "indexedDB"),
|
||||
Components.interfaces.nsIPermissionManager.DENY_ACTION,
|
||||
@@ -50,16 +50,16 @@ add_task(function* test1() {
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test2() {
|
||||
add_task(async function test2() {
|
||||
info("creating private window");
|
||||
let win = yield BrowserTestUtils.openNewBrowserWindow({ private: true });
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
|
||||
|
||||
info("creating private tab");
|
||||
win.gBrowser.selectedTab = win.gBrowser.addTab();
|
||||
|
||||
info("loading test page: " + testPageURL);
|
||||
win.gBrowser.selectedBrowser.loadURI(testPageURL);
|
||||
yield BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
|
||||
|
||||
registerPopupEventHandler("popupshowing", function() {
|
||||
ok(false, "prompt showing");
|
||||
@@ -70,7 +70,7 @@ add_task(function* test2() {
|
||||
registerPopupEventHandler("popuphidden", function() {
|
||||
ok(false, "prompt hidden");
|
||||
});
|
||||
yield promiseMessage("InvalidStateError", win.gBrowser);
|
||||
await promiseMessage("InvalidStateError", win.gBrowser);
|
||||
|
||||
is(getPermission(testPageURL, "indexedDB"),
|
||||
Components.interfaces.nsIPermissionManager.DENY_ACTION,
|
||||
@@ -80,13 +80,13 @@ add_task(function* test2() {
|
||||
win.close();
|
||||
});
|
||||
|
||||
add_task(function* test3() {
|
||||
add_task(async function test3() {
|
||||
info("creating tab");
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
|
||||
info("loading test page: " + testPageURL);
|
||||
gBrowser.selectedBrowser.loadURI(testPageURL);
|
||||
yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
registerPopupEventHandler("popupshowing", function() {
|
||||
ok(false, "Shouldn't show a popup this time");
|
||||
@@ -98,7 +98,7 @@ add_task(function* test3() {
|
||||
ok(false, "Shouldn't show a popup this time");
|
||||
});
|
||||
|
||||
yield promiseMessage("InvalidStateError", gBrowser);
|
||||
await promiseMessage("InvalidStateError", gBrowser);
|
||||
|
||||
is(getPermission(testPageURL, "indexedDB"),
|
||||
Components.interfaces.nsIPermissionManager.DENY_ACTION,
|
||||
|
||||
@@ -68,8 +68,8 @@ function setFinishedCallback(callback, win)
|
||||
if (!win) {
|
||||
win = window;
|
||||
}
|
||||
ContentTask.spawn(win.gBrowser.selectedBrowser, null, function*() {
|
||||
return yield new Promise(resolve => {
|
||||
ContentTask.spawn(win.gBrowser.selectedBrowser, null, async function() {
|
||||
return await new Promise(resolve => {
|
||||
content.wrappedJSObject.testFinishedCallback = (result, exception) => {
|
||||
info("got finished callback");
|
||||
resolve({result, exception});
|
||||
|
||||
@@ -17,7 +17,6 @@ const {
|
||||
utils: Cu,
|
||||
} = Components;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ManifestObtainer",
|
||||
"resource://gre/modules/ManifestObtainer.jsm");
|
||||
@@ -64,16 +63,16 @@ const MessageHandler = {
|
||||
* @param {Object} aMsg The IPC message, which is destructured to just
|
||||
* get the id.
|
||||
*/
|
||||
obtainManifest: Task.async(function* ({data: {id}}) {
|
||||
async obtainManifest({data: {id}}) {
|
||||
const response = makeMsgResponse(id);
|
||||
try {
|
||||
response.result = yield ManifestObtainer.contentObtainManifest(content);
|
||||
response.result = await ManifestObtainer.contentObtainManifest(content);
|
||||
response.success = true;
|
||||
} catch (err) {
|
||||
response.result = serializeError(err);
|
||||
}
|
||||
sendAsyncMessage("DOM:ManifestObtainer:Obtain", response);
|
||||
}),
|
||||
},
|
||||
|
||||
fireAppInstalledEvent({data: {id}}){
|
||||
const ev = new Event("appinstalled");
|
||||
@@ -92,17 +91,17 @@ const MessageHandler = {
|
||||
* Given a manifest and an expected icon size, ask ManifestIcons
|
||||
* to fetch the appropriate icon and send along result
|
||||
*/
|
||||
fetchIcon: Task.async(function* ({data: {id, manifest, iconSize}}) {
|
||||
async fetchIcon({data: {id, manifest, iconSize}}) {
|
||||
const response = makeMsgResponse(id);
|
||||
try {
|
||||
response.result =
|
||||
yield ManifestIcons.contentFetchIcon(content, manifest, iconSize);
|
||||
await ManifestIcons.contentFetchIcon(content, manifest, iconSize);
|
||||
response.success = true;
|
||||
} catch (err) {
|
||||
response.result = serializeError(err);
|
||||
}
|
||||
sendAsyncMessage("DOM:WebManifest:fetchIcon", response);
|
||||
}),
|
||||
},
|
||||
|
||||
};
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,7 @@ function deactivateDomainPolicy() {
|
||||
}
|
||||
}
|
||||
|
||||
function* test_domainPolicy() {
|
||||
async function test_domainPolicy() {
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise", "resource://gre/modules/Promise.jsm");
|
||||
let deferred = Promise.defer();
|
||||
@@ -21,7 +21,7 @@ function* test_domainPolicy() {
|
||||
["browser.pagethumbnails.capturing_disabled", false],
|
||||
["dom.mozBrowserFramesEnabled", false]]},
|
||||
() => { return deferred.resolve()});
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
|
||||
// Create tab
|
||||
let tab;
|
||||
@@ -113,21 +113,21 @@ function* test_domainPolicy() {
|
||||
|
||||
info("Creating child process first, activating domainPolicy after");
|
||||
currentTask = initProcess();
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
activateDomainPolicy();
|
||||
var bl = policy.blacklist;
|
||||
bl.add(Services.io.newURI('http://example.com'));
|
||||
currentTask = runTest(testDomain("http://example.com"));
|
||||
checkAndCleanup(yield currentTask);
|
||||
checkAndCleanup(await currentTask);
|
||||
|
||||
info("Activating domainPolicy first, creating child process after");
|
||||
activateDomainPolicy();
|
||||
var bl = policy.blacklist;
|
||||
bl.add(Services.io.newURI('http://example.com'));
|
||||
currentTask = initProcess();
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
currentTask = runTest(testDomain("http://example.com"));
|
||||
checkAndCleanup(yield currentTask);
|
||||
checkAndCleanup(await currentTask);
|
||||
|
||||
function testList(expectEnabled, list) {
|
||||
ipcArgs.expectEnabled = expectEnabled;
|
||||
@@ -183,51 +183,51 @@ function* test_domainPolicy() {
|
||||
info("Activating domainPolicy first, creating child process after");
|
||||
activate(true, testPolicy.exceptions, testPolicy.superExceptions);
|
||||
currentTask = initProcess();
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
let results = [];
|
||||
currentTask = runTest(testList(true, testPolicy.notExempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
currentTask = runTest(testList(false, testPolicy.exempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
checkAndCleanup(results);
|
||||
|
||||
info("Creating child process first, activating domainPolicy after");
|
||||
currentTask = initProcess();
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
activate(true, testPolicy.exceptions, testPolicy.superExceptions);
|
||||
results = [];
|
||||
currentTask = runTest(testList(true, testPolicy.notExempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
currentTask = runTest(testList(false, testPolicy.exempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
checkAndCleanup(results);
|
||||
|
||||
info("Testing Whitelist-style Domain Policy");
|
||||
deferred = Promise.defer();
|
||||
currentTask = deferred.promise;
|
||||
SpecialPowers.pushPrefEnv({set:[["javascript.enabled", false]]}, () => { return deferred.resolve()});
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
|
||||
info("Activating domainPolicy first, creating child process after");
|
||||
activate(false, testPolicy.exceptions, testPolicy.superExceptions);
|
||||
currentTask = initProcess();
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
results = [];
|
||||
currentTask = runTest(testList(false, testPolicy.notExempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
currentTask = runTest(testList(true, testPolicy.exempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
checkAndCleanup(results);
|
||||
|
||||
info("Creating child process first, activating domainPolicy after");
|
||||
currentTask = initProcess();
|
||||
yield currentTask;
|
||||
await currentTask;
|
||||
activate(false, testPolicy.exceptions, testPolicy.superExceptions);
|
||||
results = [];
|
||||
currentTask = runTest(testList(false, testPolicy.notExempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
currentTask = runTest(testList(true, testPolicy.exempt));
|
||||
results = results.concat(yield currentTask);
|
||||
results = results.concat(await currentTask);
|
||||
checkAndCleanup(results);
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const DUMMY_PAGE_DATA_URI = `data:text/html,
|
||||
* Tests the MEMORY_DISTRIBUTION_AMONG_CONTENT probe by opening a few tabs, then triggering
|
||||
* the memory probes and waiting for the "gather-memory-telemetry-finished" notification.
|
||||
*/
|
||||
add_task(function* test_memory_distribution() {
|
||||
add_task(async function test_memory_distribution() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
if (SpecialPowers.getIntPref("dom.ipc.processCount", 1) < 2) {
|
||||
@@ -26,15 +26,15 @@ add_task(function* test_memory_distribution() {
|
||||
return;
|
||||
}
|
||||
|
||||
yield SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
|
||||
await SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
|
||||
Services.telemetry.canRecordExtended = true;
|
||||
|
||||
let histogram = Services.telemetry.getKeyedHistogramById("MEMORY_DISTRIBUTION_AMONG_CONTENT");
|
||||
histogram.clear();
|
||||
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE_DATA_URI);
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE_DATA_URI);
|
||||
let tab3 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE_DATA_URI);
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE_DATA_URI);
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE_DATA_URI);
|
||||
let tab3 = await BrowserTestUtils.openNewForegroundTab(gBrowser, DUMMY_PAGE_DATA_URI);
|
||||
|
||||
let finishedGathering = new Promise(resolve => {
|
||||
let obs = function () {
|
||||
@@ -46,7 +46,7 @@ add_task(function* test_memory_distribution() {
|
||||
|
||||
session.TelemetrySession.getPayload();
|
||||
|
||||
yield finishedGathering;
|
||||
await finishedGathering;
|
||||
|
||||
let s = histogram.snapshot();
|
||||
ok("0 - 10 tabs" in s, "We should have some samples by now in this bucket.")
|
||||
@@ -64,8 +64,8 @@ add_task(function* test_memory_distribution() {
|
||||
|
||||
histogram.clear();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab3);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab3);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
finish();
|
||||
});
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
var session = Cu.import("resource://gre/modules/TelemetrySession.jsm", {});
|
||||
|
||||
add_task(function* test_memory_distribution() {
|
||||
add_task(async function test_memory_distribution() {
|
||||
if (Services.prefs.getIntPref("dom.ipc.processCount", 1) < 2) {
|
||||
ok(true, "Skip this test if e10s-multi is disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
yield SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
|
||||
await SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.enabled", true]]});
|
||||
let canRecordExtended = Services.telemetry.canRecordExtended;
|
||||
Services.telemetry.canRecordExtended = true;
|
||||
registerCleanupFunction(() => Services.telemetry.canRecordExtended = canRecordExtended);
|
||||
@@ -19,19 +19,19 @@ add_task(function* test_memory_distribution() {
|
||||
histogram.clear();
|
||||
|
||||
// Open a remote page in a new tab to trigger the WebNavigation:LoadURI.
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
|
||||
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
|
||||
ok(tab1.linkedBrowser.isRemoteBrowser, "|tab1| should have a remote browser.");
|
||||
|
||||
// Open a new tab with about:robots, so it ends up in the parent process with a non-remote browser.
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
|
||||
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
|
||||
ok(!tab2.linkedBrowser.isRemoteBrowser, "|tab2| should have a non-remote browser.");
|
||||
// Navigate the tab, so it will change remotness and it triggers the SessionStore:restoreTabContent case.
|
||||
yield BrowserTestUtils.loadURI(tab2.linkedBrowser, "http://example.com");
|
||||
await BrowserTestUtils.loadURI(tab2.linkedBrowser, "http://example.com");
|
||||
ok(tab2.linkedBrowser.isRemoteBrowser, "|tab2| should have a remote browser by now.");
|
||||
|
||||
// There is no good way to make sure that the parent received the histogram entries from the child processes.
|
||||
// Let's stick to the ugly, spinning the event loop until we have a good approach (Bug 1357509).
|
||||
yield BrowserTestUtils.waitForCondition(() => {
|
||||
await BrowserTestUtils.waitForCondition(() => {
|
||||
let s = histogram.snapshot();
|
||||
return "WebNavigation:LoadURI" in s && "SessionStore:restoreTabContent" in s;
|
||||
});
|
||||
@@ -47,6 +47,6 @@ add_task(function* test_memory_distribution() {
|
||||
|
||||
histogram.clear();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
await BrowserTestUtils.removeTab(tab2);
|
||||
await BrowserTestUtils.removeTab(tab1);
|
||||
});
|
||||
|
||||
@@ -7,7 +7,6 @@ const {
|
||||
utils: Cu
|
||||
} = Components;
|
||||
Cu.import("resource://gre/modules/PromiseMessage.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
this.ManifestFinder = {// jshint ignore:line
|
||||
/**
|
||||
@@ -29,17 +28,15 @@ this.ManifestFinder = {// jshint ignore:line
|
||||
* @param aBrowser The XUL browser to check.
|
||||
* @return {Promise}
|
||||
*/
|
||||
browserHasManifestLink: Task.async(
|
||||
function* (aBrowser) {
|
||||
async browserHasManifestLink(aBrowser) {
|
||||
if (!isXULBrowser(aBrowser)) {
|
||||
throw new TypeError("Invalid input.");
|
||||
}
|
||||
const msgKey = "DOM:WebManifest:hasManifestLink";
|
||||
const mm = aBrowser.messageManager;
|
||||
const reply = yield PromiseMessage.send(mm, msgKey);
|
||||
const reply = await PromiseMessage.send(mm, msgKey);
|
||||
return reply.data.result;
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
function isXULBrowser(aBrowser) {
|
||||
|
||||
@@ -30,7 +30,6 @@ const {
|
||||
classes: Cc,
|
||||
interfaces: Ci
|
||||
} = Components;
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/PromiseMessage.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/ManifestProcessor.jsm");
|
||||
@@ -44,37 +43,36 @@ this.ManifestObtainer = { // jshint ignore:line
|
||||
* @param {XULBrowser} The browser to check for the manifest.
|
||||
* @return {Promise<Object>} The processed manifest.
|
||||
*/
|
||||
browserObtainManifest: Task.async(function* (aBrowser) {
|
||||
async browserObtainManifest(aBrowser) {
|
||||
const msgKey = "DOM:ManifestObtainer:Obtain";
|
||||
if (!isXULBrowser(aBrowser)) {
|
||||
throw new TypeError("Invalid input. Expected XUL browser.");
|
||||
}
|
||||
const mm = aBrowser.messageManager;
|
||||
const {data: {success, result}} = yield PromiseMessage.send(mm, msgKey);
|
||||
const {data: {success, result}} = await PromiseMessage.send(mm, msgKey);
|
||||
if (!success) {
|
||||
const error = toError(result);
|
||||
throw error;
|
||||
}
|
||||
return result;
|
||||
}),
|
||||
},
|
||||
/**
|
||||
* Public interface for obtaining a web manifest from a XUL browser.
|
||||
* @param {Window} The content Window from which to extract the manifest.
|
||||
* @return {Promise<Object>} The processed manifest.
|
||||
*/
|
||||
contentObtainManifest: Task.async(function* (aContent) {
|
||||
async contentObtainManifest(aContent) {
|
||||
if (!aContent || isXULBrowser(aContent)) {
|
||||
throw new TypeError("Invalid input. Expected a DOM Window.");
|
||||
}
|
||||
let manifest;
|
||||
try {
|
||||
manifest = yield fetchManifest(aContent);
|
||||
manifest = await fetchManifest(aContent);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
return manifest;
|
||||
}
|
||||
)};
|
||||
}};
|
||||
|
||||
function toError(aErrorClone) {
|
||||
let error;
|
||||
@@ -105,14 +103,14 @@ function isXULBrowser(aBrowser) {
|
||||
* @param {Window} aContentWindow The content window.
|
||||
* @return {Promise<Object>} The processed manifest.
|
||||
*/
|
||||
const processResponse = Task.async(function* (aResp, aContentWindow) {
|
||||
const processResponse = async function(aResp, aContentWindow) {
|
||||
const badStatus = aResp.status < 200 || aResp.status >= 300;
|
||||
if (aResp.type === "error" || badStatus) {
|
||||
const msg =
|
||||
`Fetch error: ${aResp.status} - ${aResp.statusText} at ${aResp.url}`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
const text = yield aResp.text();
|
||||
const text = await aResp.text();
|
||||
const args = {
|
||||
jsonText: text,
|
||||
manifestURL: aResp.url,
|
||||
@@ -120,14 +118,14 @@ const processResponse = Task.async(function* (aResp, aContentWindow) {
|
||||
};
|
||||
const manifest = ManifestProcessor.process(args);
|
||||
return manifest;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Asynchronously fetches a web manifest.
|
||||
* @param {Window} a The content Window from where to extract the manifest.
|
||||
* @return {Promise<Object>}
|
||||
*/
|
||||
const fetchManifest = Task.async(function* (aWindow) {
|
||||
const fetchManifest = async function(aWindow) {
|
||||
if (!aWindow || aWindow.top !== aWindow) {
|
||||
let msg = "Window must be a top-level browsing context.";
|
||||
throw new Error(msg);
|
||||
@@ -149,12 +147,12 @@ const fetchManifest = Task.async(function* (aWindow) {
|
||||
request.overrideContentPolicyType(Ci.nsIContentPolicy.TYPE_WEB_MANIFEST);
|
||||
let response;
|
||||
try {
|
||||
response = yield aWindow.fetch(request);
|
||||
response = await aWindow.fetch(request);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
const manifest = yield processResponse(response, aWindow);
|
||||
const manifest = await processResponse(response, aWindow);
|
||||
return manifest;
|
||||
});
|
||||
};
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["ManifestObtainer"]; // jshint ignore:line
|
||||
|
||||
@@ -47,17 +47,17 @@ function makeTestURL({ body }) {
|
||||
/**
|
||||
* Test basic API error conditions
|
||||
*/
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
const expected = "Invalid types should throw a TypeError.";
|
||||
for (let invalidValue of [undefined, null, 1, {}, "test"]) {
|
||||
try {
|
||||
yield ManifestFinder.contentManifestLink(invalidValue);
|
||||
await ManifestFinder.contentManifestLink(invalidValue);
|
||||
ok(false, expected);
|
||||
} catch (e) {
|
||||
is(e.name, "TypeError", expected);
|
||||
}
|
||||
try {
|
||||
yield ManifestFinder.browserManifestLink(invalidValue);
|
||||
await ManifestFinder.browserManifestLink(invalidValue);
|
||||
ok(false, expected);
|
||||
} catch (e) {
|
||||
is(e.name, "TypeError", expected);
|
||||
@@ -65,7 +65,7 @@ add_task(function*() {
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
const runningTests = tests
|
||||
.map(
|
||||
test => ({
|
||||
@@ -75,10 +75,10 @@ add_task(function*() {
|
||||
})
|
||||
)
|
||||
.map(
|
||||
tabOptions => BrowserTestUtils.withNewTab(tabOptions, function*(browser) {
|
||||
const result = yield ManifestFinder.browserHasManifestLink(browser);
|
||||
tabOptions => BrowserTestUtils.withNewTab(tabOptions, async function(browser) {
|
||||
const result = await ManifestFinder.browserHasManifestLink(browser);
|
||||
tabOptions.test.run(result);
|
||||
})
|
||||
);
|
||||
yield Promise.all(runningTests);
|
||||
await Promise.all(runningTests);
|
||||
});
|
||||
|
||||
@@ -41,16 +41,16 @@ function getIconColor(icon) {
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
const tabOptions = {gBrowser, url: makeTestURL(manifest)};
|
||||
yield BrowserTestUtils.withNewTab(tabOptions, function*(browser) {
|
||||
const manifest = yield ManifestObtainer.browserObtainManifest(browser);
|
||||
let icon = yield ManifestIcons.browserFetchIcon(browser, manifest, 25);
|
||||
let color = yield ContentTask.spawn(browser, icon, getIconColor);
|
||||
await BrowserTestUtils.withNewTab(tabOptions, async function(browser) {
|
||||
const manifest = await ManifestObtainer.browserObtainManifest(browser);
|
||||
let icon = await ManifestIcons.browserFetchIcon(browser, manifest, 25);
|
||||
let color = await ContentTask.spawn(browser, icon, getIconColor);
|
||||
is(color[0], 255, 'Fetched red icon');
|
||||
|
||||
icon = yield ManifestIcons.browserFetchIcon(browser, manifest, 500);
|
||||
color = yield ContentTask.spawn(browser, icon, getIconColor);
|
||||
icon = await ManifestIcons.browserFetchIcon(browser, manifest, 500);
|
||||
color = await ContentTask.spawn(browser, icon, getIconColor);
|
||||
is(color[2], 255, 'Fetched blue icon');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ function makeTestURL({ body }) {
|
||||
return url.href;
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
const promises = tests
|
||||
.map(test => ({
|
||||
gBrowser,
|
||||
@@ -100,12 +100,12 @@ add_task(function*() {
|
||||
return collector;
|
||||
}, []);
|
||||
|
||||
const results = yield Promise.all(promises);
|
||||
const results = await Promise.all(promises);
|
||||
|
||||
function testObtainingManifest(aTest) {
|
||||
return function*(aBrowser) {
|
||||
return async function(aBrowser) {
|
||||
try {
|
||||
const manifest = yield ManifestObtainer.browserObtainManifest(aBrowser);
|
||||
const manifest = await ManifestObtainer.browserObtainManifest(aBrowser);
|
||||
aTest.run(manifest);
|
||||
} catch (e) {
|
||||
aTest.run(e);
|
||||
@@ -119,7 +119,7 @@ add_task(function*() {
|
||||
* Open a bunch of tabs and load manifests
|
||||
* in each tab. They should all return pass.
|
||||
*/
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
const defaultPath = '/browser/dom/manifest/test/manifestLoader.html';
|
||||
const tabURLs = [
|
||||
`http://example.com:80${defaultPath}`,
|
||||
@@ -156,12 +156,12 @@ add_task(function*() {
|
||||
for (url of tabURLs) BrowserTestUtils.addTab(gBrowser, url).linkedBrowser
|
||||
];
|
||||
// Once all the pages have loaded, run a bunch of tests in "parallel".
|
||||
yield Promise.all((
|
||||
await Promise.all((
|
||||
for (browser of browsers) BrowserTestUtils.browserLoaded(browser)
|
||||
));
|
||||
// Flood random browsers with requests. Once promises settle, check that
|
||||
// responses all pass.
|
||||
const results = yield Promise.all((
|
||||
const results = await Promise.all((
|
||||
for (browser of randBrowsers(browsers, 50)) ManifestObtainer.browserObtainManifest(browser)
|
||||
));
|
||||
const pass = results.every(manifest => manifest.name === 'pass');
|
||||
|
||||
@@ -18,24 +18,24 @@ function makeTestURL(manifest) {
|
||||
return url.href;
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
|
||||
const tabOptions = {gBrowser, url: makeTestURL(manifest)};
|
||||
|
||||
yield BrowserTestUtils.withNewTab(tabOptions, function*(browser) {
|
||||
await BrowserTestUtils.withNewTab(tabOptions, async function(browser) {
|
||||
|
||||
let manifest = yield Manifests.getManifest(browser, manifestUrl);
|
||||
let manifest = await Manifests.getManifest(browser, manifestUrl);
|
||||
is(manifest.installed, false, "We havent installed this manifest yet");
|
||||
|
||||
yield manifest.install(browser);
|
||||
await manifest.install(browser);
|
||||
is(manifest.name, "hello World", "Manifest has correct name");
|
||||
is(manifest.installed, true, "Manifest is installed");
|
||||
is(manifest.url, manifestUrl, "has correct url");
|
||||
|
||||
manifest = yield Manifests.getManifest(browser, manifestUrl);
|
||||
manifest = await Manifests.getManifest(browser, manifestUrl);
|
||||
is(manifest.installed, true, "New instances are installed");
|
||||
|
||||
manifest = yield Manifests.getManifest(browser);
|
||||
manifest = await Manifests.getManifest(browser);
|
||||
is(manifest.installed, true, "Will find manifest without being given url");
|
||||
|
||||
let foundManifest = Manifests.findManifestUrl("http://example.org/browser/dom/");
|
||||
|
||||
@@ -19,16 +19,16 @@ function enableOnAppInstalledPref() {
|
||||
|
||||
// Send a message for the even to be fired.
|
||||
// This cause file_reg_install_event.html to be dynamically change.
|
||||
function* theTest(aBrowser) {
|
||||
async function theTest(aBrowser) {
|
||||
aBrowser.allowEvents = true;
|
||||
let waitForInstall = ContentTask.spawn(aBrowser, null, function*() {
|
||||
yield ContentTaskUtils.waitForEvent(content.window, "appinstalled");
|
||||
let waitForInstall = ContentTask.spawn(aBrowser, null, async function() {
|
||||
await ContentTaskUtils.waitForEvent(content.window, "appinstalled");
|
||||
});
|
||||
const { data: { success } } = yield PromiseMessage
|
||||
const { data: { success } } = await PromiseMessage
|
||||
.send(aBrowser.messageManager, "DOM:Manifest:FireAppInstalledEvent");
|
||||
ok(success, "message sent and received successfully.");
|
||||
try {
|
||||
yield waitForInstall;
|
||||
await waitForInstall;
|
||||
ok(true, "AppInstalled event fired");
|
||||
} catch (err) {
|
||||
ok(false, "AppInstalled event didn't fire: " + err.message);
|
||||
@@ -36,13 +36,13 @@ function* theTest(aBrowser) {
|
||||
}
|
||||
|
||||
// Open a tab and run the test
|
||||
add_task(function*() {
|
||||
yield enableOnAppInstalledPref();
|
||||
add_task(async function() {
|
||||
await enableOnAppInstalledPref();
|
||||
let tabOptions = {
|
||||
gBrowser: gBrowser,
|
||||
url: testURL.href,
|
||||
};
|
||||
yield BrowserTestUtils.withNewTab(
|
||||
await BrowserTestUtils.withNewTab(
|
||||
tabOptions,
|
||||
theTest
|
||||
);
|
||||
|
||||
@@ -184,7 +184,7 @@ function defer() {
|
||||
}
|
||||
|
||||
|
||||
function* test_basics() {
|
||||
async function test_basics() {
|
||||
// See bug 903830; in e10s mode we never get to find out the localPort if we
|
||||
// let it pick a free port by choosing 0. This is the same port the xpcshell
|
||||
// test was using.
|
||||
@@ -203,11 +203,11 @@ function* test_basics() {
|
||||
let clientQueue = listenForEventsOnSocket(clientSocket, 'client');
|
||||
|
||||
// (the client connects)
|
||||
is((yield clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
is((await clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
is(clientSocket.readyState, 'open', 'client readyState is open');
|
||||
|
||||
// (the server connected)
|
||||
let { socket: serverSocket, queue: serverQueue } = yield connectedPromise;
|
||||
let { socket: serverSocket, queue: serverQueue } = await connectedPromise;
|
||||
is(serverSocket.readyState, 'open', 'server readyState is open');
|
||||
|
||||
// -- Simple send / receive
|
||||
@@ -220,7 +220,7 @@ function* test_basics() {
|
||||
is(clientSocket.send(smallUint8Array.buffer, 0, smallUint8Array.length), true,
|
||||
'Client sending less than 64k, buffer should not be full.');
|
||||
|
||||
let serverReceived = yield serverQueue.waitForDataWithAtLeastLength(256);
|
||||
let serverReceived = await serverQueue.waitForDataWithAtLeastLength(256);
|
||||
assertUint8ArraysEqual(serverReceived, smallUint8Array,
|
||||
'Server received/client sent');
|
||||
|
||||
@@ -229,7 +229,7 @@ function* test_basics() {
|
||||
is(serverSocket.send(smallUint8Array.buffer, 0, smallUint8Array.length), true,
|
||||
'Server sending less than 64k, buffer should not be full.');
|
||||
|
||||
let clientReceived = yield clientQueue.waitForDataWithAtLeastLength(256);
|
||||
let clientReceived = await clientQueue.waitForDataWithAtLeastLength(256);
|
||||
assertUint8ArraysEqual(clientReceived, smallUint8Array,
|
||||
'Client received/server sent');
|
||||
|
||||
@@ -241,7 +241,7 @@ function* test_basics() {
|
||||
is(clientSocket.send(smallUint8Array.buffer, 7, smallUint8Array.length - 7),
|
||||
true, 'Client sending less than 64k, buffer should not be full.');
|
||||
|
||||
serverReceived = yield serverQueue.waitForDataWithAtLeastLength(256);
|
||||
serverReceived = await serverQueue.waitForDataWithAtLeastLength(256);
|
||||
assertUint8ArraysEqual(serverReceived, smallUint8Array,
|
||||
'Server received/client sent');
|
||||
|
||||
@@ -252,7 +252,7 @@ function* test_basics() {
|
||||
is(serverSocket.send(smallUint8Array.buffer, 7, smallUint8Array.length - 7),
|
||||
true, 'Server sending less than 64k, buffer should not be full.');
|
||||
|
||||
clientReceived = yield clientQueue.waitForDataWithAtLeastLength(256);
|
||||
clientReceived = await clientQueue.waitForDataWithAtLeastLength(256);
|
||||
assertUint8ArraysEqual(clientReceived, smallUint8Array,
|
||||
'Client received/server sent');
|
||||
|
||||
@@ -269,10 +269,10 @@ function* test_basics() {
|
||||
// - Send "big" data from the client to the server
|
||||
is(clientSocket.send(bigUint8Array.buffer, 0, bigUint8Array.length), false,
|
||||
'Client sending more than 64k should result in the buffer being full.');
|
||||
is((yield clientQueue.waitForEvent()).type, 'drain',
|
||||
is((await clientQueue.waitForEvent()).type, 'drain',
|
||||
'The drain event should fire after a large send that indicated full.');
|
||||
|
||||
serverReceived = yield serverQueue.waitForDataWithAtLeastLength(
|
||||
serverReceived = await serverQueue.waitForDataWithAtLeastLength(
|
||||
bigUint8Array.length);
|
||||
assertUint8ArraysEqual(serverReceived, bigUint8Array,
|
||||
'server received/client sent');
|
||||
@@ -280,10 +280,10 @@ function* test_basics() {
|
||||
// - Send "big" data from the server to the client
|
||||
is(serverSocket.send(bigUint8Array.buffer, 0, bigUint8Array.length), false,
|
||||
'Server sending more than 64k should result in the buffer being full.');
|
||||
is((yield serverQueue.waitForEvent()).type, 'drain',
|
||||
is((await serverQueue.waitForEvent()).type, 'drain',
|
||||
'The drain event should fire after a large send that indicated full.');
|
||||
|
||||
clientReceived = yield clientQueue.waitForDataWithAtLeastLength(
|
||||
clientReceived = await clientQueue.waitForDataWithAtLeastLength(
|
||||
bigUint8Array.length);
|
||||
assertUint8ArraysEqual(clientReceived, bigUint8Array,
|
||||
'client received/server sent');
|
||||
@@ -294,11 +294,11 @@ function* test_basics() {
|
||||
is(serverSocket.readyState, 'closing',
|
||||
'readyState should be closing immediately after calling close');
|
||||
|
||||
is((yield clientQueue.waitForEvent()).type, 'close',
|
||||
is((await clientQueue.waitForEvent()).type, 'close',
|
||||
'The client should get a close event when the server closes.');
|
||||
is(clientSocket.readyState, 'closed',
|
||||
'client readyState should be closed after close event');
|
||||
is((yield serverQueue.waitForEvent()).type, 'close',
|
||||
is((await serverQueue.waitForEvent()).type, 'close',
|
||||
'The server should get a close event when it closes itself.');
|
||||
is(serverSocket.readyState, 'closed',
|
||||
'server readyState should be closed after close event');
|
||||
@@ -308,9 +308,9 @@ function* test_basics() {
|
||||
clientSocket = createSocket('127.0.0.1', serverPort,
|
||||
{ binaryType: 'arraybuffer' });
|
||||
clientQueue = listenForEventsOnSocket(clientSocket, 'client');
|
||||
is((yield clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
is((await clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
|
||||
let connectedResult = yield connectedPromise;
|
||||
let connectedResult = await connectedPromise;
|
||||
// destructuring assignment is not yet ES6 compliant, must manually unpack
|
||||
serverSocket = connectedResult.socket;
|
||||
serverQueue = connectedResult.queue;
|
||||
@@ -320,11 +320,11 @@ function* test_basics() {
|
||||
is(clientSocket.readyState, 'closing',
|
||||
'client readyState should be losing immediately after calling close');
|
||||
|
||||
is((yield clientQueue.waitForEvent()).type, 'close',
|
||||
is((await clientQueue.waitForEvent()).type, 'close',
|
||||
'The client should get a close event when it closes itself.');
|
||||
is(clientSocket.readyState, 'closed',
|
||||
'client readyState should be closed after the close event is received');
|
||||
is((yield serverQueue.waitForEvent()).type, 'close',
|
||||
is((await serverQueue.waitForEvent()).type, 'close',
|
||||
'The server should get a close event when the client closes.');
|
||||
is(serverSocket.readyState, 'closed',
|
||||
'server readyState should be closed after the close event is received');
|
||||
@@ -335,9 +335,9 @@ function* test_basics() {
|
||||
clientSocket = createSocket('127.0.0.1', serverPort,
|
||||
{ binaryType: 'arraybuffer' });
|
||||
clientQueue = listenForEventsOnSocket(clientSocket, 'client');
|
||||
is((yield clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
is((await clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
|
||||
connectedResult = yield connectedPromise;
|
||||
connectedResult = await connectedPromise;
|
||||
// destructuring assignment is not yet ES6 compliant, must manually unpack
|
||||
serverSocket = connectedResult.socket;
|
||||
serverQueue = connectedResult.queue;
|
||||
@@ -348,19 +348,19 @@ function* test_basics() {
|
||||
'Client sending more than 64k should result in the buffer being full.');
|
||||
clientSocket.close();
|
||||
// The drain will still fire
|
||||
is((yield clientQueue.waitForEvent()).type, 'drain',
|
||||
is((await clientQueue.waitForEvent()).type, 'drain',
|
||||
'The drain event should fire after a large send that returned true.');
|
||||
// Then we'll get a close
|
||||
is((yield clientQueue.waitForEvent()).type, 'close',
|
||||
is((await clientQueue.waitForEvent()).type, 'close',
|
||||
'The close event should fire after the drain event.');
|
||||
|
||||
// The server will get its data
|
||||
serverReceived = yield serverQueue.waitForDataWithAtLeastLength(
|
||||
serverReceived = await serverQueue.waitForDataWithAtLeastLength(
|
||||
bigUint8Array.length);
|
||||
assertUint8ArraysEqual(serverReceived, bigUint8Array,
|
||||
'server received/client sent');
|
||||
// And a close.
|
||||
is((yield serverQueue.waitForEvent()).type, 'close',
|
||||
is((await serverQueue.waitForEvent()).type, 'close',
|
||||
'The drain event should fire after a large send that returned true.');
|
||||
|
||||
|
||||
@@ -369,9 +369,9 @@ function* test_basics() {
|
||||
clientSocket = createSocket('127.0.0.1', serverPort,
|
||||
{ binaryType: 'string' });
|
||||
clientQueue = listenForEventsOnSocket(clientSocket, 'client');
|
||||
is((yield clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
is((await clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
|
||||
connectedResult = yield connectedPromise;
|
||||
connectedResult = await connectedPromise;
|
||||
// destructuring assignment is not yet ES6 compliant, must manually unpack
|
||||
serverSocket = connectedResult.socket;
|
||||
serverQueue = connectedResult.queue;
|
||||
@@ -384,10 +384,10 @@ function* test_basics() {
|
||||
'Client sending a large non-string should only send a small string.');
|
||||
clientSocket.close();
|
||||
// The server will get its data
|
||||
serverReceived = yield serverQueue.waitForDataWithAtLeastLength(
|
||||
serverReceived = await serverQueue.waitForDataWithAtLeastLength(
|
||||
bigUint8Array.toString().length);
|
||||
// Then we'll get a close
|
||||
is((yield clientQueue.waitForEvent()).type, 'close',
|
||||
is((await clientQueue.waitForEvent()).type, 'close',
|
||||
'The close event should fire after the drain event.');
|
||||
|
||||
// -- Re-establish connection (Test for Close Immediately)
|
||||
@@ -395,9 +395,9 @@ function* test_basics() {
|
||||
clientSocket = createSocket('127.0.0.1', serverPort,
|
||||
{ binaryType: 'arraybuffer' });
|
||||
clientQueue = listenForEventsOnSocket(clientSocket, 'client');
|
||||
is((yield clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
is((await clientQueue.waitForEvent()).type, 'open', 'got open event');
|
||||
|
||||
connectedResult = yield connectedPromise;
|
||||
connectedResult = await connectedPromise;
|
||||
// destructuring assignment is not yet ES6 compliant, must manually unpack
|
||||
serverSocket = connectedResult.socket;
|
||||
serverQueue = connectedResult.queue;
|
||||
@@ -409,7 +409,7 @@ function* test_basics() {
|
||||
'Server sending more than 64k should result in the buffer being full.');
|
||||
clientSocket.closeImmediately();
|
||||
|
||||
serverReceived = yield serverQueue.waitForAnyDataAndClose();
|
||||
serverReceived = await serverQueue.waitForAnyDataAndClose();
|
||||
|
||||
is(serverReceived.length < (2 * bigUint8Array.length), true, 'Received array length less than sent array length');
|
||||
|
||||
@@ -424,7 +424,7 @@ function* test_basics() {
|
||||
clientSocket = createSocket('127.0.0.1', serverPort,
|
||||
{ binaryType: 'arraybuffer' });
|
||||
clientQueue = listenForEventsOnSocket(clientSocket, 'client');
|
||||
is((yield clientQueue.waitForEvent()).type, 'error', 'fail to connect');
|
||||
is((await clientQueue.waitForEvent()).type, 'error', 'fail to connect');
|
||||
is(clientSocket.readyState, 'closed',
|
||||
'client readyState should be closed after the failure to connect');
|
||||
}
|
||||
|
||||
@@ -52,34 +52,34 @@ function tabWithRequest(task, permission) {
|
||||
return BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: TEST_URL,
|
||||
}, function*(browser) {
|
||||
}, async function(browser) {
|
||||
let requestPromise = ContentTask.spawn(browser, {
|
||||
permission
|
||||
}, function*({permission}) {
|
||||
}, async function({permission}) {
|
||||
function requestCallback(perm) {
|
||||
is(perm, permission,
|
||||
"Should call the legacy callback with the permission state");
|
||||
}
|
||||
let perm = yield content.window.Notification
|
||||
let perm = await content.window.Notification
|
||||
.requestPermission(requestCallback);
|
||||
is(perm, permission,
|
||||
"Should resolve the promise with the permission state");
|
||||
});
|
||||
|
||||
yield BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
|
||||
yield task();
|
||||
yield requestPromise;
|
||||
await BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
|
||||
await task();
|
||||
await requestPromise;
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* setup() {
|
||||
add_task(async function setup() {
|
||||
SimpleTest.registerCleanupFunction(() => {
|
||||
Services.perms.remove(ORIGIN_URI, PERMISSION_NAME);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* test_requestPermission_granted() {
|
||||
yield tabWithRequest(function() {
|
||||
add_task(async function test_requestPermission_granted() {
|
||||
await tabWithRequest(function() {
|
||||
clickDoorhangerButton(PROMPT_ALLOW_BUTTON);
|
||||
}, "granted");
|
||||
|
||||
@@ -91,8 +91,8 @@ add_task(function* test_requestPermission_granted() {
|
||||
"Check permission in perm. manager");
|
||||
});
|
||||
|
||||
add_task(function* test_requestPermission_denied_temporarily() {
|
||||
yield tabWithRequest(function() {
|
||||
add_task(async function test_requestPermission_denied_temporarily() {
|
||||
await tabWithRequest(function() {
|
||||
clickDoorhangerButton(PROMPT_NOT_NOW_BUTTON);
|
||||
}, "default");
|
||||
|
||||
@@ -104,9 +104,9 @@ add_task(function* test_requestPermission_denied_temporarily() {
|
||||
"Check permission in perm. manager");
|
||||
});
|
||||
|
||||
add_task(function* test_requestPermission_denied_permanently() {
|
||||
yield tabWithRequest(function*() {
|
||||
yield clickDoorhangerButton(PROMPT_NEVER_BUTTON);
|
||||
add_task(async function test_requestPermission_denied_permanently() {
|
||||
await tabWithRequest(async function() {
|
||||
await clickDoorhangerButton(PROMPT_NEVER_BUTTON);
|
||||
}, "denied");
|
||||
|
||||
ok(!PopupNotifications.getNotification("web-notifications"),
|
||||
|
||||
@@ -5,10 +5,10 @@ const kTestPage = kTestRoot + "multiple_payment_request.html";
|
||||
|
||||
registerCleanupFunction(cleanup);
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
Services.prefs.setBoolPref("dom.payments.request.enabled", true);
|
||||
yield BrowserTestUtils.withNewTab(kTestPage,
|
||||
function*(browser) {
|
||||
await BrowserTestUtils.withNewTab(kTestPage,
|
||||
function(browser) {
|
||||
|
||||
const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService);
|
||||
ok(paymentSrv, "Fail to get PaymentRequestService.");
|
||||
|
||||
@@ -5,10 +5,10 @@ const kTestPage = kTestRoot + "simple_payment_request.html";
|
||||
|
||||
registerCleanupFunction(cleanup);
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
Services.prefs.setBoolPref("dom.payments.request.enabled", true);
|
||||
yield BrowserTestUtils.withNewTab(kTestPage,
|
||||
function*(browser) {
|
||||
await BrowserTestUtils.withNewTab(kTestPage,
|
||||
function(browser) {
|
||||
|
||||
const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService);
|
||||
ok(paymentSrv, "Fail to get PaymentRequestService.");
|
||||
|
||||
@@ -5,12 +5,12 @@ const kTestPage = kTestRoot + "simple_payment_request.html";
|
||||
|
||||
registerCleanupFunction(cleanup);
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
Services.prefs.setBoolPref("dom.payments.request.enabled", true);
|
||||
yield BrowserTestUtils.withNewTab(kTestPage,
|
||||
function*(browser) {
|
||||
yield BrowserTestUtils.withNewTab(kTestPage,
|
||||
function*(browser) {
|
||||
await BrowserTestUtils.withNewTab(kTestPage,
|
||||
async function(browser) {
|
||||
await BrowserTestUtils.withNewTab(kTestPage,
|
||||
function(browser) {
|
||||
const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService);
|
||||
ok(paymentSrv, "Fail to get PaymentRequestService.");
|
||||
|
||||
|
||||
@@ -31,22 +31,22 @@ function promiseWaitForEvent(object, eventName, capturing = false, chrome = fals
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
registerCleanupFunction(function () {
|
||||
window.focus();
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let pluginTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
let prefTab = BrowserTestUtils.addTab(gBrowser);
|
||||
|
||||
yield promiseTabLoad(pluginTab, gTestRoot + "plugin_test.html");
|
||||
yield promiseTabLoad(prefTab, "about:preferences");
|
||||
await promiseTabLoad(pluginTab, gTestRoot + "plugin_test.html");
|
||||
await promiseTabLoad(prefTab, "about:preferences");
|
||||
|
||||
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
Assert.ok(!!plugin, "plugin is loaded");
|
||||
@@ -54,7 +54,7 @@ add_task(function* () {
|
||||
|
||||
let ppromise = promiseWaitForEvent(window, "MozAfterPaint");
|
||||
gBrowser.selectedTab = prefTab;
|
||||
yield ppromise;
|
||||
await ppromise;
|
||||
|
||||
// We're going to switch tabs using actual mouse clicks, which helps
|
||||
// reproduce this bug.
|
||||
@@ -70,9 +70,9 @@ add_task(function* () {
|
||||
for (let iteration = 0; iteration < 5; iteration++) {
|
||||
ppromise = promiseWaitForEvent(window, "MozAfterPaint");
|
||||
EventUtils.synthesizeMouseAtCenter(tabStripContainer.childNodes[1], {}, window);
|
||||
yield ppromise;
|
||||
await ppromise;
|
||||
|
||||
yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
Assert.ok(XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(),
|
||||
@@ -81,9 +81,9 @@ add_task(function* () {
|
||||
|
||||
ppromise = promiseWaitForEvent(window, "MozAfterPaint");
|
||||
EventUtils.synthesizeMouseAtCenter(tabStripContainer.childNodes[2], {}, window);
|
||||
yield ppromise;
|
||||
await ppromise;
|
||||
|
||||
yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
Assert.ok(!XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(),
|
||||
|
||||
@@ -11,23 +11,23 @@ function checkPaintCount(aCount) {
|
||||
// A bad regression would either be 0, or 100+.
|
||||
const kMaxPaints = 10;
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let result, tabSwitchedPromise;
|
||||
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let testTab = gBrowser.selectedTab;
|
||||
let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
let homeTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home");
|
||||
let pluginTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
let homeTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !!plugin;
|
||||
});
|
||||
is(result, true, "plugin is loaded");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -35,7 +35,7 @@ add_task(function* () {
|
||||
is(result, true, "plugin is hidden");
|
||||
|
||||
// reset plugin paint count
|
||||
yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
XPCNativeWrapper.unwrap(plugin).resetPaintCount();
|
||||
@@ -44,12 +44,12 @@ add_task(function* () {
|
||||
// select plugin tab
|
||||
tabSwitchedPromise = waitTabSwitched();
|
||||
gBrowser.selectedTab = pluginTab;
|
||||
yield tabSwitchedPromise;
|
||||
await tabSwitchedPromise;
|
||||
|
||||
// wait a bit for spurious paints
|
||||
yield waitForMs(100);
|
||||
await waitForMs(100);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -57,7 +57,7 @@ add_task(function* () {
|
||||
is(result, true, "plugin is visible");
|
||||
|
||||
// check for good paint count
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).getPaintCount();
|
||||
@@ -67,27 +67,27 @@ add_task(function* () {
|
||||
// select home tab
|
||||
tabSwitchedPromise = waitTabSwitched();
|
||||
gBrowser.selectedTab = homeTab;
|
||||
yield tabSwitchedPromise;
|
||||
await tabSwitchedPromise;
|
||||
|
||||
// reset paint count
|
||||
yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
XPCNativeWrapper.unwrap(plugin).resetPaintCount();
|
||||
});
|
||||
|
||||
// wait a bit for spurious paints
|
||||
yield waitForMs(100);
|
||||
await waitForMs(100);
|
||||
|
||||
// check for no paint count
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).getPaintCount();
|
||||
});
|
||||
is(result, 0, "no paints, this is correct.");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -95,7 +95,7 @@ add_task(function* () {
|
||||
is(result, true, "plugin is hidden");
|
||||
|
||||
// reset paint count
|
||||
yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
XPCNativeWrapper.unwrap(plugin).resetPaintCount();
|
||||
@@ -104,10 +104,10 @@ add_task(function* () {
|
||||
// select plugin tab
|
||||
tabSwitchedPromise = waitTabSwitched();
|
||||
gBrowser.selectedTab = pluginTab;
|
||||
yield tabSwitchedPromise;
|
||||
await tabSwitchedPromise;
|
||||
|
||||
// check paint count
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).getPaintCount();
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
var rootDir = getRootDirectory(gTestPath);
|
||||
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
|
||||
|
||||
add_task(function*() {
|
||||
add_task(async function() {
|
||||
is(navigator.plugins.length, 0,
|
||||
"plugins should not be available to chrome-privilege pages");
|
||||
ok(!("application/x-test" in navigator.mimeTypes),
|
||||
"plugins should not be available to chrome-privilege pages");
|
||||
|
||||
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function*(browser) {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, async function(browser) {
|
||||
// about:blank triggered from a toplevel load should not inherit permissions
|
||||
yield ContentTask.spawn(browser, null, function*() {
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
is(content.window.navigator.plugins.length, 0,
|
||||
"plugins should not be available to null-principal about:blank");
|
||||
ok(!("application/x-test" in content.window.navigator.mimeTypes),
|
||||
@@ -18,9 +18,9 @@ add_task(function*() {
|
||||
|
||||
let promise = BrowserTestUtils.browserLoaded(browser);
|
||||
browser.loadURI(gTestRoot + "plugin_test.html");
|
||||
yield promise;
|
||||
await promise;
|
||||
|
||||
yield ContentTask.spawn(browser, null, function*() {
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
ok(content.window.navigator.plugins.length > 0,
|
||||
"plugins should be available to HTTP-loaded pages");
|
||||
ok("application/x-test" in content.window.navigator.mimeTypes,
|
||||
@@ -35,12 +35,12 @@ add_task(function*() {
|
||||
// navigate from the HTTP page to an about:blank page which ought to
|
||||
// inherit permissions
|
||||
promise = BrowserTestUtils.browserLoaded(browser);
|
||||
yield ContentTask.spawn(browser, null, function*() {
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
content.document.getElementById("aboutlink").click();
|
||||
});
|
||||
yield promise;
|
||||
await promise;
|
||||
|
||||
yield ContentTask.spawn(browser, null, function*() {
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
is(content.window.location.href, "about:blank", "sanity-check about:blank load");
|
||||
ok("application/x-test" in content.window.navigator.mimeTypes,
|
||||
"plugins should be available when a site triggers an about:blank load");
|
||||
@@ -51,9 +51,9 @@ add_task(function*() {
|
||||
promise = BrowserTestUtils.browserLoaded(browser);
|
||||
let converteduri = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry).convertChromeURL(Services.io.newURI(rootDir + "plugin_test.html"));
|
||||
browser.loadURI(converteduri.spec);
|
||||
yield promise;
|
||||
await promise;
|
||||
|
||||
yield ContentTask.spawn(browser, null, function*() {
|
||||
await ContentTask.spawn(browser, null, async function() {
|
||||
ok(!("application/x-test" in content.window.navigator.mimeTypes),
|
||||
"plugins should not be available to file: URI content");
|
||||
});
|
||||
|
||||
@@ -18,14 +18,14 @@ var apzEnabled = Preferences.get("layers.async-pan-zoom.enabled", false);
|
||||
var pluginHideEnabled = Preferences.get("gfx.e10s.hide-plugins-for-scroll", true);
|
||||
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
registerCleanupFunction(function () {
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["general.smoothScroll", true],
|
||||
["general.smoothScroll.other", true],
|
||||
@@ -41,7 +41,7 @@ add_task(function*() {
|
||||
* test plugin visibility when scrolling with scroll wheel and apz in a top level document.
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let result;
|
||||
|
||||
if (!apzEnabled) {
|
||||
@@ -57,16 +57,16 @@ add_task(function* () {
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let testTab = gBrowser.selectedTab;
|
||||
let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
let pluginTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !!plugin;
|
||||
});
|
||||
is(result, true, "plugin is loaded");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -81,18 +81,18 @@ add_task(function* () {
|
||||
nativeId, 0, -50, 0, 0, 0,
|
||||
gBrowser.selectedBrowser);
|
||||
|
||||
yield waitScrollStart(gBrowser.selectedBrowser);
|
||||
await waitScrollStart(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, false, "plugin is hidden");
|
||||
|
||||
yield waitScrollFinish(gBrowser.selectedBrowser);
|
||||
await waitScrollFinish(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -106,7 +106,7 @@ add_task(function* () {
|
||||
* test plugin visibility when scrolling with scroll wheel and apz in a sub document.
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let result;
|
||||
|
||||
if (!apzEnabled) {
|
||||
@@ -122,16 +122,16 @@ add_task(function* () {
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let testTab = gBrowser.selectedTab;
|
||||
let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_subframe_test.html");
|
||||
let pluginTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_subframe_test.html");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !!plugin;
|
||||
});
|
||||
is(result, true, "plugin is loaded");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -146,18 +146,18 @@ add_task(function* () {
|
||||
nativeId, 0, -50, 0, 0, 0,
|
||||
gBrowser.selectedBrowser);
|
||||
|
||||
yield waitScrollStart(gBrowser.selectedBrowser);
|
||||
await waitScrollStart(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, false, "plugin is hidden");
|
||||
|
||||
yield waitScrollFinish(gBrowser.selectedBrowser);
|
||||
await waitScrollFinish(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -173,7 +173,7 @@ add_task(function* () {
|
||||
* for this test.
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let result;
|
||||
|
||||
if (!pluginHideEnabled) {
|
||||
@@ -184,16 +184,16 @@ add_task(function* () {
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let testTab = gBrowser.selectedTab;
|
||||
let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
let pluginTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !!plugin;
|
||||
});
|
||||
is(result, true, "plugin is loaded");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -202,18 +202,18 @@ add_task(function* () {
|
||||
|
||||
EventUtils.synthesizeKey("VK_END", {});
|
||||
|
||||
yield waitScrollStart(gBrowser.selectedBrowser);
|
||||
await waitScrollStart(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, false, "plugin is hidden");
|
||||
|
||||
yield waitScrollFinish(gBrowser.selectedBrowser);
|
||||
await waitScrollFinish(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -222,9 +222,9 @@ add_task(function* () {
|
||||
|
||||
EventUtils.synthesizeKey("VK_HOME", {});
|
||||
|
||||
yield waitScrollFinish(gBrowser.selectedBrowser);
|
||||
await waitScrollFinish(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -238,7 +238,7 @@ add_task(function* () {
|
||||
* test visibility when scrolling with keyboard shortcuts for a sub document.
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let result;
|
||||
|
||||
if (!pluginHideEnabled) {
|
||||
@@ -249,16 +249,16 @@ add_task(function* () {
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let testTab = gBrowser.selectedTab;
|
||||
let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_subframe_test.html");
|
||||
let pluginTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_subframe_test.html");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !!plugin;
|
||||
});
|
||||
is(result, true, "plugin is loaded");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -267,18 +267,18 @@ add_task(function* () {
|
||||
|
||||
EventUtils.synthesizeKey("VK_END", {});
|
||||
|
||||
yield waitScrollStart(gBrowser.selectedBrowser);
|
||||
await waitScrollStart(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, false, "plugin is hidden");
|
||||
|
||||
yield waitScrollFinish(gBrowser.selectedBrowser);
|
||||
await waitScrollFinish(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -287,9 +287,9 @@ add_task(function* () {
|
||||
|
||||
EventUtils.synthesizeKey("VK_HOME", {});
|
||||
|
||||
yield waitScrollFinish(gBrowser.selectedBrowser);
|
||||
await waitScrollFinish(gBrowser.selectedBrowser);
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab.linkedBrowser, null, async function() {
|
||||
let doc = content.document.getElementById("subframe").contentDocument;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
|
||||
@@ -3,23 +3,23 @@ var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content
|
||||
// tests that we get plugin updates when we flip between tabs that
|
||||
// have the same plugin in the same position in the page.
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let result, tabSwitchedPromise;
|
||||
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
|
||||
|
||||
let testTab = gBrowser.selectedTab;
|
||||
let pluginTab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
let pluginTab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
let pluginTab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
let pluginTab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab1.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !!plugin;
|
||||
});
|
||||
is(result, true, "plugin1 is loaded");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab2.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return !!plugin;
|
||||
@@ -29,14 +29,14 @@ add_task(function* () {
|
||||
// plugin tab 2 should be selected
|
||||
is(gBrowser.selectedTab == pluginTab2, true, "plugin2 is selected");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab1.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, false, "plugin1 is hidden");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab2.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -46,16 +46,16 @@ add_task(function* () {
|
||||
// select plugin1 tab
|
||||
tabSwitchedPromise = waitTabSwitched();
|
||||
gBrowser.selectedTab = pluginTab1;
|
||||
yield tabSwitchedPromise;
|
||||
await tabSwitchedPromise;
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab1.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, true, "plugin1 is visible");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab2.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -65,16 +65,16 @@ add_task(function* () {
|
||||
// select plugin2 tab
|
||||
tabSwitchedPromise = waitTabSwitched();
|
||||
gBrowser.selectedTab = pluginTab2;
|
||||
yield tabSwitchedPromise;
|
||||
await tabSwitchedPromise;
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab1.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, false, "plugin1 is hidden");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab2.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
@@ -84,16 +84,16 @@ add_task(function* () {
|
||||
// select test tab
|
||||
tabSwitchedPromise = waitTabSwitched();
|
||||
gBrowser.selectedTab = testTab;
|
||||
yield tabSwitchedPromise;
|
||||
await tabSwitchedPromise;
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab1.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
});
|
||||
is(result, false, "plugin1 is hidden");
|
||||
|
||||
result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
|
||||
result = await ContentTask.spawn(pluginTab2.linkedBrowser, null, async function() {
|
||||
let doc = content.document;
|
||||
let plugin = doc.getElementById("testplugin");
|
||||
return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
* screen element - and therefore exit out of the fullscreen element.
|
||||
*/
|
||||
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/* Needed to be able to programatically (without user interaction) enter
|
||||
* fullscreen (has been deemed a security issue otherwise and therefore
|
||||
* disabled by default)
|
||||
*/
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
@@ -53,7 +53,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let fullScreenElement = document.getElementById('div1');
|
||||
let plugin = document.getElementById('iframe1')
|
||||
.contentDocument.getElementById('iframe2')
|
||||
@@ -61,10 +61,10 @@
|
||||
|
||||
let fullScreenChange = promiseFullScreenChange();
|
||||
fullScreenElement.mozRequestFullScreen();
|
||||
yield fullScreenChange;
|
||||
await fullScreenChange;
|
||||
ok(true, "Element is fullscreen");
|
||||
|
||||
yield crashPlugin(plugin)
|
||||
await crashPlugin(plugin)
|
||||
.then(() => {
|
||||
ok(true, "Plugin was crashed");
|
||||
})
|
||||
@@ -73,13 +73,13 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/**
|
||||
* We expect the fullscreen mode to change in this test. We'll wait
|
||||
* 5 seconds for any kind of fullscreen change to occur, and fail if it
|
||||
* doesn't.
|
||||
*/
|
||||
yield new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let timeoutId;
|
||||
let onFullScreenChange = () => {
|
||||
document.removeEventListener("fullscreenchange", onFullScreenChange);
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
* screen element - and therefore remain in the fullscreen element.
|
||||
*/
|
||||
let load = function testCrashChildPlugin_expectFullScreenElementToRemain() {
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/* Needed to be able to programatically (without user interaction) enter
|
||||
* fullscreen (has been deemed a security issue otherwise and therefore
|
||||
* disabled by default)
|
||||
*/
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
@@ -53,16 +53,16 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let fullScreenElement = document.getElementById('div1');
|
||||
let plugin = document.getElementById('plugin1');
|
||||
|
||||
let fullScreenChange = promiseFullScreenChange();
|
||||
fullScreenElement.mozRequestFullScreen();
|
||||
yield fullScreenChange;
|
||||
await fullScreenChange;
|
||||
ok(true, "Element is fullscreen");
|
||||
|
||||
yield crashPlugin(plugin)
|
||||
await crashPlugin(plugin)
|
||||
.then(() => {
|
||||
ok(true, "Plugin was crashed");
|
||||
})
|
||||
@@ -71,14 +71,14 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/**
|
||||
* We expect the fullscreen mode to _not_ change in this test. We'll wait
|
||||
* 5 seconds for any kind of fullscreen change to occur, and fail if it
|
||||
* does. Otherwise, we'll assume fullscreen didn't change and finish the
|
||||
* test.
|
||||
*/
|
||||
yield new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let timeoutId;
|
||||
let onFullScreenChange = () => {
|
||||
document.removeEventListener("fullscreenchange", onFullScreenChange);
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
* screen element - and therefore exit out of the fullscreen element.
|
||||
*/
|
||||
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/* Needed to be able to programatically (without user interaction) enter
|
||||
* fullscreen (has been deemed a security issue otherwise and therefore
|
||||
* disabled by default)
|
||||
*/
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
@@ -53,7 +53,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let fullScreenElement = document.getElementById('iframe1');
|
||||
let plugin = document.getElementById('iframe1')
|
||||
.contentDocument.getElementById('iframe2')
|
||||
@@ -61,10 +61,10 @@
|
||||
|
||||
let fullScreenChange = promiseFullScreenChange();
|
||||
fullScreenElement.mozRequestFullScreen();
|
||||
yield fullScreenChange;
|
||||
await fullScreenChange;
|
||||
ok(true, "Element is fullscreen");
|
||||
|
||||
yield crashPlugin(plugin)
|
||||
await crashPlugin(plugin)
|
||||
.then(() => {
|
||||
ok(true, "Plugin was crashed");
|
||||
})
|
||||
@@ -73,13 +73,13 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/**
|
||||
* We expect the fullscreen mode to change in this test. We'll wait
|
||||
* 5 seconds for any kind of fullscreen change to occur, and fail if it
|
||||
* doesn't.
|
||||
*/
|
||||
yield new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let timeoutId;
|
||||
let onFullScreenChange = () => {
|
||||
document.removeEventListener("fullscreenchange", onFullScreenChange);
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
* screen element - and therefore exit out of the fullscreen element.
|
||||
*/
|
||||
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/* Needed to be able to programatically (without user interaction) enter
|
||||
* fullscreen (has been deemed a security issue otherwise and therefore
|
||||
* disabled by default)
|
||||
*/
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
@@ -53,7 +53,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let fullScreenElement = document.getElementById('iframe1');
|
||||
let plugin = document.getElementById('iframe1')
|
||||
.contentDocument.getElementById('iframe2')
|
||||
@@ -61,10 +61,10 @@
|
||||
|
||||
let fullScreenChange = promiseFullScreenChange();
|
||||
fullScreenElement.mozRequestFullScreen();
|
||||
yield fullScreenChange;
|
||||
await fullScreenChange;
|
||||
ok(true, "Element is fullscreen");
|
||||
|
||||
yield crashPlugin(plugin)
|
||||
await crashPlugin(plugin)
|
||||
.then(() => {
|
||||
ok(true, "Plugin was crashed");
|
||||
})
|
||||
@@ -73,13 +73,13 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/**
|
||||
* We expect the fullscreen mode to change in this test. We'll wait
|
||||
* 5 seconds for any kind of fullscreen change to occur, and fail if it
|
||||
* doesn't.
|
||||
*/
|
||||
yield new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let timeoutId;
|
||||
let onFullScreenChange = () => {
|
||||
document.removeEventListener("fullscreenchange", onFullScreenChange);
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
* screen element - and therefore exit out of the fullscreen element.
|
||||
*/
|
||||
let load = function testCrashChildPlugin_expectFullScreenElementToBeCancelled() {
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/* Needed to be able to programatically (without user interaction) enter
|
||||
* fullscreen (has been deemed a security issue otherwise and therefore
|
||||
* disabled by default)
|
||||
*/
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
@@ -53,16 +53,16 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let fullScreenElement = document.getElementById('div1');
|
||||
let plugin = document.getElementById('plugin1');
|
||||
|
||||
let fullScreenChange = promiseFullScreenChange();
|
||||
fullScreenElement.mozRequestFullScreen();
|
||||
yield fullScreenChange;
|
||||
await fullScreenChange;
|
||||
ok(true, "Element is fullscreen");
|
||||
|
||||
yield crashPlugin(plugin)
|
||||
await crashPlugin(plugin)
|
||||
.then(() => {
|
||||
ok(true, "Plugin was crashed");
|
||||
})
|
||||
@@ -71,13 +71,13 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/**
|
||||
* We expect the fullscreen mode to change in this test. We'll wait
|
||||
* 5 seconds for any kind of fullscreen change to occur, and fail if it
|
||||
* doesn't.
|
||||
*/
|
||||
yield new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let timeoutId;
|
||||
let onFullScreenChange = () => {
|
||||
document.removeEventListener("fullscreenchange", onFullScreenChange);
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
* screen element - and therefore remain in the fullscreen element.
|
||||
*/
|
||||
let load = function testCrashChildPlugin_expectFullScreenElementToRemain() {
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/* Needed to be able to programatically (without user interaction) enter
|
||||
* fullscreen (has been deemed a security issue otherwise and therefore
|
||||
* disabled by default)
|
||||
*/
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
@@ -53,16 +53,16 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let fullScreenElement = document.getElementById('iframe1');
|
||||
let plugin = document.getElementById('plugin1');
|
||||
|
||||
let fullScreenChange = promiseFullScreenChange();
|
||||
fullScreenElement.mozRequestFullScreen();
|
||||
yield fullScreenChange;
|
||||
await fullScreenChange;
|
||||
ok(true, "Element is fullscreen");
|
||||
|
||||
yield crashPlugin(plugin)
|
||||
await crashPlugin(plugin)
|
||||
.then(() => {
|
||||
ok(true, "Plugin was crashed");
|
||||
})
|
||||
@@ -71,14 +71,14 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/**
|
||||
* We expect the fullscreen mode to _not_ change in this test. We'll wait
|
||||
* 5 seconds for any kind of fullscreen change to occur, and fail if it
|
||||
* does. Otherwise, we'll assume fullscreen didn't change and finish the
|
||||
* test.
|
||||
*/
|
||||
yield new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let timeoutId;
|
||||
let onFullScreenChange = () => {
|
||||
document.removeEventListener("fullscreenchange", onFullScreenChange);
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
* screen element - and therefore remain in the fullscreen element.
|
||||
*/
|
||||
let load = function testCrashChildPlugin_expectFullScreenElementToRemain() {
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/* Needed to be able to programatically (without user interaction) enter
|
||||
* fullscreen (has been deemed a security issue otherwise and therefore
|
||||
* disabled by default)
|
||||
*/
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["full-screen-api.allow-trusted-requests-only", false],
|
||||
["full-screen-api.unprefix.enabled", true],
|
||||
@@ -53,7 +53,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
let fullScreenElement = document.getElementById('iframeA')
|
||||
let plugin = document.getElementById('iframe1')
|
||||
.contentDocument.getElementById('iframe2')
|
||||
@@ -61,10 +61,10 @@
|
||||
|
||||
let fullScreenChange = promiseFullScreenChange();
|
||||
fullScreenElement.mozRequestFullScreen();
|
||||
yield fullScreenChange;
|
||||
await fullScreenChange;
|
||||
ok(true, "Element is fullscreen");
|
||||
|
||||
yield crashPlugin(plugin)
|
||||
await crashPlugin(plugin)
|
||||
.then(() => {
|
||||
ok(true, "Plugin was crashed");
|
||||
})
|
||||
@@ -73,14 +73,14 @@
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* () {
|
||||
add_task(async function() {
|
||||
/**
|
||||
* We expect the fullscreen mode to _not_ change in this test. We'll wait
|
||||
* 5 seconds for any kind of fullscreen change to occur, and fail if it
|
||||
* does. Otherwise, we'll assume fullscreen didn't change and finish the
|
||||
* test.
|
||||
*/
|
||||
yield new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
let timeoutId;
|
||||
let onFullScreenChange = () => {
|
||||
document.removeEventListener("fullscreenchange", onFullScreenChange);
|
||||
|
||||
@@ -22,7 +22,6 @@ SimpleTest.ignoreAllUncaughtExceptions();
|
||||
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
var crashReporter =
|
||||
Components.classes["@mozilla.org/toolkit/crash-reporter;1"]
|
||||
@@ -79,10 +78,10 @@ var testObserver = {
|
||||
crashReporter.serverURL = oldServerURL;
|
||||
|
||||
// Check and cleanup CrashManager.
|
||||
Task.spawn(function* () {
|
||||
(async function() {
|
||||
let cm = Services.crashmanager;
|
||||
yield cm.ensureCrashIsPresent(crashID);
|
||||
let store = yield cm._getStore();
|
||||
await cm.ensureCrashIsPresent(crashID);
|
||||
let store = await cm._getStore();
|
||||
is(store.crashesCount, 1, "Store should have only 1 item");
|
||||
|
||||
let crash = store.getCrash(crashID);
|
||||
@@ -99,7 +98,7 @@ var testObserver = {
|
||||
store.reset();
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
})();
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
@@ -142,14 +141,14 @@ function runTests() {
|
||||
|
||||
var pluginElement = document.getElementById("plugin1");
|
||||
try {
|
||||
Task.spawn(function* () {
|
||||
(async function() {
|
||||
// Clear data in CrashManager in case previous tests caused something
|
||||
// to be added.
|
||||
let store = yield Services.crashmanager._getStore();
|
||||
let store = await Services.crashmanager._getStore();
|
||||
store.reset();
|
||||
|
||||
pluginElement.crash();
|
||||
});
|
||||
})();
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ SimpleTest.ignoreAllUncaughtExceptions();
|
||||
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
@@ -87,10 +86,10 @@ var testObserver = {
|
||||
Services.prefs.setIntPref("dom.ipc.plugins.timeoutSecs", oldTimeoutPref);
|
||||
|
||||
// Check and cleanup CrashManager.
|
||||
Task.spawn(function* () {
|
||||
(async function() {
|
||||
let cm = Services.crashmanager;
|
||||
yield cm.ensureCrashIsPresent(crashID);
|
||||
let store = yield cm._getStore();
|
||||
await cm.ensureCrashIsPresent(crashID);
|
||||
let store = await cm._getStore();
|
||||
is(store.crashesCount, 1, "Store should have only 1 item");
|
||||
|
||||
let crash = store.getCrash(crashID);
|
||||
@@ -107,7 +106,7 @@ var testObserver = {
|
||||
store.reset();
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
})();
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
@@ -150,14 +149,14 @@ function runTests() {
|
||||
|
||||
var pluginElement = document.getElementById("plugin1");
|
||||
try {
|
||||
Task.spawn(function* () {
|
||||
(async function() {
|
||||
// Clear data in CrashManager in case previous tests caused something
|
||||
// to be added.
|
||||
let store = yield Services.crashmanager._getStore();
|
||||
let store = await Services.crashmanager._getStore();
|
||||
store.reset();
|
||||
|
||||
pluginElement.hang();
|
||||
});
|
||||
})();
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function* test_state() {
|
||||
add_task(async function test_state() {
|
||||
// Remove test so we will have only one "Test Plug-in" registered.
|
||||
// xpcshell tests have plugins in per-test profiles, so that's fine.
|
||||
let file = get_test_plugin();
|
||||
@@ -39,7 +39,7 @@ add_task(function* test_state() {
|
||||
Services.prefs.setIntPref("plugin.default.state", Ci.nsIPluginTag.STATE_CLICKTOPLAY);
|
||||
Services.prefs.setIntPref("plugin.defaultXpi.state", Ci.nsIPluginTag.STATE_ENABLED);
|
||||
|
||||
let success = yield installAddon("testaddon.xpi");
|
||||
let success = await installAddon("testaddon.xpi");
|
||||
Assert.ok(success, "Should have installed addon.");
|
||||
let addonDir = getAddonRoot(gProfileDir, ADDON_ID);
|
||||
|
||||
@@ -91,7 +91,7 @@ add_task(function* test_state() {
|
||||
Assert.ok(pluginDir.exists(), "Addon plugins path should exist: " + pluginDir.path);
|
||||
Assert.ok(pluginDir.isDirectory(), "Addon plugins path should be a directory: " + pluginDir.path);
|
||||
|
||||
let addon = yield getAddonByID(ADDON_ID);
|
||||
let addon = await getAddonByID(ADDON_ID);
|
||||
Assert.ok(!addon.appDisabled, "Addon should not be appDisabled");
|
||||
Assert.ok(addon.isActive, "Addon should be active");
|
||||
Assert.ok(addon.isCompatible, "Addon should be compatible");
|
||||
|
||||
@@ -12,12 +12,12 @@ Cu.import("resource://testing-common/PromiseTestUtils.jsm", this);
|
||||
// Prevent test failures due to the unhandled rejections in this test file.
|
||||
PromiseTestUtils.disableUncaughtRejectionObserverForSelfTest();
|
||||
|
||||
add_task(function* test_globals() {
|
||||
add_task(async function test_globals() {
|
||||
Assert.equal(Promise.defer || undefined, undefined, "We are testing DOM Promise.");
|
||||
Assert.notEqual(PromiseDebugging, undefined, "PromiseDebugging is available.");
|
||||
});
|
||||
|
||||
add_task(function* test_promiseID() {
|
||||
add_task(async function test_promiseID() {
|
||||
let p1 = new Promise(resolve => {});
|
||||
let p2 = new Promise(resolve => {});
|
||||
let p3 = p2.catch(null);
|
||||
@@ -35,7 +35,7 @@ add_task(function* test_promiseID() {
|
||||
"Successive calls to PromiseDebugging.getPromiseID return the same id for the same promise");
|
||||
});
|
||||
|
||||
add_task(function* test_observe_uncaught() {
|
||||
add_task(async function test_observe_uncaught() {
|
||||
// The names of Promise instances
|
||||
let names = new Map();
|
||||
|
||||
@@ -212,13 +212,13 @@ add_task(function* test_observe_uncaught() {
|
||||
}
|
||||
|
||||
do_print("Test setup, waiting for callbacks.");
|
||||
yield onLeftUncaught.blocker;
|
||||
await onLeftUncaught.blocker;
|
||||
|
||||
do_print("All calls to onLeftUncaught are complete.");
|
||||
if (onConsumed.expected.size != 0) {
|
||||
do_print("onConsumed is still waiting for the following Promise:");
|
||||
do_print(JSON.stringify(Array.from(onConsumed.expected.values(), (x) => names.get(x))));
|
||||
yield onConsumed.blocker;
|
||||
await onConsumed.blocker;
|
||||
}
|
||||
|
||||
do_print("All calls to onConsumed are complete.");
|
||||
@@ -229,7 +229,7 @@ add_task(function* test_observe_uncaught() {
|
||||
});
|
||||
|
||||
|
||||
add_task(function* test_uninstall_observer() {
|
||||
add_task(async function test_uninstall_observer() {
|
||||
let Observer = function() {
|
||||
this.blocker = new Promise(resolve => this.resolve = resolve);
|
||||
this.active = true;
|
||||
@@ -255,7 +255,7 @@ add_task(function* test_uninstall_observer() {
|
||||
do_print("Adding an observer.");
|
||||
let deactivate = new Observer();
|
||||
Promise.reject("I am an uncaught rejection.");
|
||||
yield deactivate.blocker;
|
||||
await deactivate.blocker;
|
||||
Assert.ok(true, "The observer has observed an uncaught Promise.");
|
||||
deactivate.active = false;
|
||||
do_print("Removing the observer, it should not observe any further uncaught Promise.");
|
||||
@@ -263,8 +263,8 @@ add_task(function* test_uninstall_observer() {
|
||||
do_print("Rejecting a Promise and waiting a little to give a chance to observers.");
|
||||
let wait = new Observer();
|
||||
Promise.reject("I am another uncaught rejection.");
|
||||
yield wait.blocker;
|
||||
yield new Promise(resolve => setTimeout(resolve, 100));
|
||||
await wait.blocker;
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
// Normally, `deactivate` should not be notified of the uncaught rejection.
|
||||
wait.active = false;
|
||||
});
|
||||
|
||||
@@ -19,8 +19,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
@@ -132,7 +130,7 @@ PushRecord.prototype = {
|
||||
* visited the site, or `-Infinity` if the site is not in the user's history.
|
||||
* The time is expressed in milliseconds since Epoch.
|
||||
*/
|
||||
getLastVisit: Task.async(function* () {
|
||||
async getLastVisit() {
|
||||
if (!this.quotaApplies() || this.isTabOpen()) {
|
||||
// If the registration isn't subject to quota, or the user already
|
||||
// has the site open, skip expensive database queries.
|
||||
@@ -140,7 +138,7 @@ PushRecord.prototype = {
|
||||
}
|
||||
|
||||
if (AppConstants.MOZ_ANDROID_HISTORY) {
|
||||
let result = yield EventDispatcher.instance.sendRequestForResult({
|
||||
let result = await EventDispatcher.instance.sendRequestForResult({
|
||||
type: "History:GetPrePathLastVisitedTimeMilliseconds",
|
||||
prePath: this.uri.prePath,
|
||||
});
|
||||
@@ -159,13 +157,13 @@ PushRecord.prototype = {
|
||||
Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY
|
||||
].join(",");
|
||||
|
||||
let db = yield PlacesUtils.promiseDBConnection();
|
||||
let db = await PlacesUtils.promiseDBConnection();
|
||||
// We're using a custom query instead of `nsINavHistoryQueryOptions`
|
||||
// because the latter doesn't expose a way to filter by transition type:
|
||||
// `setTransitions` performs a logical "and," but we want an "or." We
|
||||
// also avoid an unneeded left join with favicons, and an `ORDER BY`
|
||||
// clause that emits a suboptimal index warning.
|
||||
let rows = yield db.executeCached(
|
||||
let rows = await db.executeCached(
|
||||
`SELECT MAX(visit_date) AS lastVisit
|
||||
FROM moz_places p
|
||||
JOIN moz_historyvisits ON p.id = place_id
|
||||
@@ -187,7 +185,7 @@ PushRecord.prototype = {
|
||||
let lastVisit = rows[0].getResultByName("lastVisit");
|
||||
|
||||
return lastVisit / 1000;
|
||||
}),
|
||||
},
|
||||
|
||||
isTabOpen() {
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
|
||||
@@ -41,26 +41,26 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
};
|
||||
|
||||
var registration;
|
||||
add_task(function* start() {
|
||||
yield setupPrefsAndMockSocket(mockSocket);
|
||||
yield setPushPermission(true);
|
||||
add_task(async function start() {
|
||||
await setupPrefsAndMockSocket(mockSocket);
|
||||
await setPushPermission(true);
|
||||
|
||||
var url = "worker.js" + "?" + (Math.random());
|
||||
registration = yield navigator.serviceWorker.register(url, {scope: "."});
|
||||
yield waitForActive(registration);
|
||||
registration = await navigator.serviceWorker.register(url, {scope: "."});
|
||||
await waitForActive(registration);
|
||||
});
|
||||
|
||||
var controlledFrame;
|
||||
add_task(function* createControlledIFrame() {
|
||||
controlledFrame = yield injectControlledFrame();
|
||||
add_task(async function createControlledIFrame() {
|
||||
controlledFrame = await injectControlledFrame();
|
||||
});
|
||||
|
||||
var pushSubscription;
|
||||
add_task(function* subscribe() {
|
||||
pushSubscription = yield registration.pushManager.subscribe();
|
||||
add_task(async function subscribe() {
|
||||
pushSubscription = await registration.pushManager.subscribe();
|
||||
});
|
||||
|
||||
add_task(function* compareJSONSubscription() {
|
||||
add_task(async function compareJSONSubscription() {
|
||||
var json = pushSubscription.toJSON();
|
||||
is(json.endpoint, pushSubscription.endpoint, "Wrong endpoint");
|
||||
|
||||
@@ -73,8 +73,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* comparePublicKey() {
|
||||
var data = yield sendRequestToWorker({ type: "publicKey" });
|
||||
add_task(async function comparePublicKey() {
|
||||
var data = await sendRequestToWorker({ type: "publicKey" });
|
||||
var p256dhKey = new Uint8Array(pushSubscription.getKey("p256dh"));
|
||||
is(p256dhKey.length, 65, "Key share should be 65 octets");
|
||||
isDeeply(
|
||||
@@ -116,28 +116,28 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
]).then(([message]) => message);
|
||||
}
|
||||
|
||||
add_task(function* sendPushMessageFromPage() {
|
||||
add_task(async function sendPushMessageFromPage() {
|
||||
var typedArray = new Uint8Array([226, 130, 40, 240, 40, 140, 188]);
|
||||
var json = { hello: "world" };
|
||||
|
||||
var message = yield waitForMessage(pushSubscription, "Text message from page");
|
||||
var message = await waitForMessage(pushSubscription, "Text message from page");
|
||||
is(message.data.text, "Text message from page", "Wrong text message data");
|
||||
|
||||
message = yield waitForMessage(
|
||||
message = await waitForMessage(
|
||||
pushSubscription,
|
||||
typedArray
|
||||
);
|
||||
isDeeply(new Uint8Array(message.data.arrayBuffer), typedArray,
|
||||
"Wrong array buffer message data");
|
||||
|
||||
message = yield waitForMessage(
|
||||
message = await waitForMessage(
|
||||
pushSubscription,
|
||||
JSON.stringify(json)
|
||||
);
|
||||
ok(message.data.json.ok, "Unexpected error parsing JSON");
|
||||
isDeeply(message.data.json.value, json, "Wrong JSON message data");
|
||||
|
||||
message = yield waitForMessage(
|
||||
message = await waitForMessage(
|
||||
pushSubscription,
|
||||
""
|
||||
);
|
||||
@@ -146,12 +146,12 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
is(message.data.arrayBuffer.byteLength, 0, "Wrong buffer length for empty message");
|
||||
ok(!message.data.json.ok, "Expected JSON parse error for empty message");
|
||||
|
||||
message = yield waitForMessage(
|
||||
message = await waitForMessage(
|
||||
pushSubscription,
|
||||
new Uint8Array([0x48, 0x69, 0x21, 0x20, 0xf0, 0x9f, 0x91, 0x80])
|
||||
);
|
||||
is(message.data.text, "Hi! \ud83d\udc40", "Wrong text for message with emoji");
|
||||
var text = yield new Promise((resolve, reject) => {
|
||||
var text = await new Promise((resolve, reject) => {
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = event => {
|
||||
if (reader.error) {
|
||||
@@ -172,17 +172,17 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
channelID: channelID
|
||||
}));
|
||||
|
||||
var message = yield finishedPromise;
|
||||
var message = await finishedPromise;
|
||||
ok(!message.data, "Should exclude data for blank messages");
|
||||
});
|
||||
|
||||
add_task(function* unsubscribe() {
|
||||
add_task(async function unsubscribe() {
|
||||
controlledFrame.remove();
|
||||
yield pushSubscription.unsubscribe();
|
||||
await pushSubscription.unsubscribe();
|
||||
});
|
||||
|
||||
add_task(function* unregister() {
|
||||
yield registration.unregister();
|
||||
add_task(async function unregister() {
|
||||
await registration.unregister();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -31,8 +31,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
var reporters = new Map();
|
||||
|
||||
var registration;
|
||||
add_task(function* start() {
|
||||
yield setupPrefsAndReplaceService({
|
||||
add_task(async function start() {
|
||||
await setupPrefsAndReplaceService({
|
||||
reportDeliveryError(messageId, reason) {
|
||||
ok(reporters.has(messageId),
|
||||
'Unexpected error reported for message ' + messageId);
|
||||
@@ -41,16 +41,16 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
resolve(reason);
|
||||
},
|
||||
});
|
||||
yield setPushPermission(true);
|
||||
await setPushPermission(true);
|
||||
|
||||
var url = "error_worker.js" + "?" + (Math.random());
|
||||
registration = yield navigator.serviceWorker.register(url, {scope: "."});
|
||||
yield waitForActive(registration);
|
||||
registration = await navigator.serviceWorker.register(url, {scope: "."});
|
||||
await waitForActive(registration);
|
||||
});
|
||||
|
||||
var controlledFrame;
|
||||
add_task(function* createControlledIFrame() {
|
||||
controlledFrame = yield injectControlledFrame();
|
||||
add_task(async function createControlledIFrame() {
|
||||
controlledFrame = await injectControlledFrame();
|
||||
});
|
||||
|
||||
var idCounter = 1;
|
||||
@@ -66,18 +66,18 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* reportDeliveryErrors() {
|
||||
var reason = yield waitForDeliveryError({ type: "exception" });
|
||||
add_task(async function reportDeliveryErrors() {
|
||||
var reason = await waitForDeliveryError({ type: "exception" });
|
||||
is(reason, SpecialPowers.Ci.nsIPushErrorReporter.DELIVERY_UNCAUGHT_EXCEPTION,
|
||||
"Should report uncaught exceptions");
|
||||
|
||||
reason = yield waitForDeliveryError({ type: "rejection" });
|
||||
reason = await waitForDeliveryError({ type: "rejection" });
|
||||
is(reason, SpecialPowers.Ci.nsIPushErrorReporter.DELIVERY_UNHANDLED_REJECTION,
|
||||
"Should report unhandled rejections");
|
||||
});
|
||||
|
||||
add_task(function* reportDecryptionError() {
|
||||
var message = yield new Promise(resolve => {
|
||||
add_task(async function reportDecryptionError() {
|
||||
var message = await new Promise(resolve => {
|
||||
SpecialPowers.registerConsoleListener(message => {
|
||||
if (!message.isScriptError) {
|
||||
return;
|
||||
@@ -99,12 +99,12 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"Should report the given error string");
|
||||
});
|
||||
|
||||
add_task(function* unsubscribe() {
|
||||
add_task(async function unsubscribe() {
|
||||
controlledFrame.remove();
|
||||
});
|
||||
|
||||
add_task(function* unregister() {
|
||||
yield registration.unregister();
|
||||
add_task(async function unregister() {
|
||||
await registration.unregister();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -30,18 +30,18 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
|
||||
var registration;
|
||||
add_task(function* start() {
|
||||
yield setupPrefsAndMockSocket(new MockWebSocket());
|
||||
yield setPushPermission(false);
|
||||
add_task(async function start() {
|
||||
await setupPrefsAndMockSocket(new MockWebSocket());
|
||||
await setPushPermission(false);
|
||||
|
||||
var url = "worker.js" + "?" + Math.random();
|
||||
registration = yield navigator.serviceWorker.register(url, {scope: "."});
|
||||
yield waitForActive(registration);
|
||||
registration = await navigator.serviceWorker.register(url, {scope: "."});
|
||||
await waitForActive(registration);
|
||||
});
|
||||
|
||||
add_task(function* denySubscribe() {
|
||||
add_task(async function denySubscribe() {
|
||||
try {
|
||||
yield registration.pushManager.subscribe();
|
||||
await registration.pushManager.subscribe();
|
||||
ok(false, "subscribe() should fail because no permission for push");
|
||||
} catch (error) {
|
||||
ok(error instanceof DOMException, "Wrong exception type");
|
||||
@@ -49,23 +49,23 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* denySubscribeInWorker() {
|
||||
add_task(async function denySubscribeInWorker() {
|
||||
// If permission is revoked, `getSubscription()` should return `null`, and
|
||||
// `subscribe()` should reject immediately. Calling these from the worker
|
||||
// should not deadlock the main thread (see bug 1228723).
|
||||
var errorInfo = yield sendRequestToWorker({
|
||||
var errorInfo = await sendRequestToWorker({
|
||||
type: "denySubscribe",
|
||||
});
|
||||
ok(errorInfo.isDOMException, "Wrong exception type");
|
||||
is(errorInfo.name, "NotAllowedError", "Wrong exception name");
|
||||
});
|
||||
|
||||
add_task(function* getEndpoint() {
|
||||
var pushSubscription = yield registration.pushManager.getSubscription();
|
||||
add_task(async function getEndpoint() {
|
||||
var pushSubscription = await registration.pushManager.getSubscription();
|
||||
is(pushSubscription, null, "getSubscription() should return null because no permission for push");
|
||||
});
|
||||
|
||||
add_task(function* checkPermissionState() {
|
||||
add_task(async function checkPermissionState() {
|
||||
var permissionManager = SpecialPowers.Ci.nsIPermissionManager;
|
||||
var tests = [{
|
||||
action: permissionManager.ALLOW_ACTION,
|
||||
@@ -81,23 +81,23 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
state: "prompt",
|
||||
}];
|
||||
for (var test of tests) {
|
||||
yield setPushPermission(test.action);
|
||||
var state = yield registration.pushManager.permissionState();
|
||||
await setPushPermission(test.action);
|
||||
var state = await registration.pushManager.permissionState();
|
||||
is(state, test.state, JSON.stringify(test));
|
||||
try {
|
||||
yield SpecialPowers.pushPrefEnv({ set: [
|
||||
await SpecialPowers.pushPrefEnv({ set: [
|
||||
["dom.push.testing.ignorePermission", true]] });
|
||||
state = yield registration.pushManager.permissionState();
|
||||
state = await registration.pushManager.permissionState();
|
||||
is(state, "granted", `Should ignore ${
|
||||
test.action} if the override pref is set`);
|
||||
} finally {
|
||||
yield SpecialPowers.flushPrefEnv();
|
||||
await SpecialPowers.flushPrefEnv();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* unregister() {
|
||||
var result = yield registration.unregister();
|
||||
add_task(async function unregister() {
|
||||
var result = await registration.unregister();
|
||||
ok(result, "Unregister should return true.");
|
||||
});
|
||||
|
||||
|
||||
@@ -45,43 +45,43 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
};
|
||||
|
||||
var registration;
|
||||
add_task(function* start() {
|
||||
yield setupPrefsAndMockSocket(mockSocket);
|
||||
yield setPushPermission(true);
|
||||
add_task(async function start() {
|
||||
await setupPrefsAndMockSocket(mockSocket);
|
||||
await setPushPermission(true);
|
||||
|
||||
var url = "worker.js" + "?" + (Math.random());
|
||||
registration = yield navigator.serviceWorker.register(url, {scope: "."});
|
||||
yield waitForActive(registration);
|
||||
registration = await navigator.serviceWorker.register(url, {scope: "."});
|
||||
await waitForActive(registration);
|
||||
});
|
||||
|
||||
var controlledFrame;
|
||||
add_task(function* createControlledIFrame() {
|
||||
controlledFrame = yield injectControlledFrame();
|
||||
add_task(async function createControlledIFrame() {
|
||||
controlledFrame = await injectControlledFrame();
|
||||
});
|
||||
|
||||
add_task(function* checkPermissionState() {
|
||||
var state = yield registration.pushManager.permissionState();
|
||||
add_task(async function checkPermissionState() {
|
||||
var state = await registration.pushManager.permissionState();
|
||||
is(state, "granted", "permissionState() should resolve to granted.");
|
||||
});
|
||||
|
||||
var pushSubscription;
|
||||
add_task(function* subscribe() {
|
||||
pushSubscription = yield registration.pushManager.subscribe();
|
||||
add_task(async function subscribe() {
|
||||
pushSubscription = await registration.pushManager.subscribe();
|
||||
is(pushSubscription.options.applicationServerKey, null,
|
||||
"Subscription should not have an app server key");
|
||||
});
|
||||
|
||||
add_task(function* resubscribe() {
|
||||
var data = yield sendRequestToWorker({
|
||||
add_task(async function resubscribe() {
|
||||
var data = await sendRequestToWorker({
|
||||
type: "resubscribe",
|
||||
endpoint: pushSubscription.endpoint,
|
||||
});
|
||||
pushSubscription = yield registration.pushManager.getSubscription();
|
||||
pushSubscription = await registration.pushManager.getSubscription();
|
||||
is(data.endpoint, pushSubscription.endpoint,
|
||||
"Subscription endpoints should match after resubscribing in worker");
|
||||
});
|
||||
|
||||
add_task(function* waitForPushNotification() {
|
||||
add_task(async function waitForPushNotification() {
|
||||
var finishedPromise = controlledFrame.waitOnWorkerMessage("finished");
|
||||
|
||||
// Send a blank message.
|
||||
@@ -91,16 +91,16 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
channelID: channelID
|
||||
}));
|
||||
|
||||
yield finishedPromise;
|
||||
await finishedPromise;
|
||||
});
|
||||
|
||||
add_task(function* unsubscribe() {
|
||||
add_task(async function unsubscribe() {
|
||||
controlledFrame.remove();
|
||||
yield pushSubscription.unsubscribe();
|
||||
await pushSubscription.unsubscribe();
|
||||
});
|
||||
|
||||
add_task(function* unregister() {
|
||||
var result = yield registration.unregister();
|
||||
add_task(async function unregister() {
|
||||
var result = await registration.unregister();
|
||||
ok(result, "Unregister should return true.");
|
||||
});
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
|
||||
var registration;
|
||||
add_task(function* start() {
|
||||
yield setupPrefsAndReplaceService({
|
||||
add_task(async function start() {
|
||||
await setupPrefsAndReplaceService({
|
||||
register(pageRecord) {
|
||||
ok(pageRecord.appServerKey.length > 0,
|
||||
"App server key should not be empty");
|
||||
@@ -65,22 +65,22 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
};
|
||||
},
|
||||
});
|
||||
yield setPushPermission(true);
|
||||
testKey = yield generateKey();
|
||||
await setPushPermission(true);
|
||||
testKey = await generateKey();
|
||||
|
||||
var url = "worker.js" + "?" + (Math.random());
|
||||
registration = yield navigator.serviceWorker.register(url, {scope: "."});
|
||||
yield waitForActive(registration);
|
||||
registration = await navigator.serviceWorker.register(url, {scope: "."});
|
||||
await waitForActive(registration);
|
||||
});
|
||||
|
||||
var controlledFrame;
|
||||
add_task(function* createControlledIFrame() {
|
||||
controlledFrame = yield injectControlledFrame();
|
||||
add_task(async function createControlledIFrame() {
|
||||
controlledFrame = await injectControlledFrame();
|
||||
});
|
||||
|
||||
add_task(function* emptyKey() {
|
||||
add_task(async function emptyKey() {
|
||||
try {
|
||||
yield registration.pushManager.subscribe({
|
||||
await registration.pushManager.subscribe({
|
||||
applicationServerKey: new ArrayBuffer(0),
|
||||
});
|
||||
ok(false, "Should reject for empty app server keys");
|
||||
@@ -92,9 +92,9 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* invalidKey() {
|
||||
add_task(async function invalidKey() {
|
||||
try {
|
||||
yield registration.pushManager.subscribe({
|
||||
await registration.pushManager.subscribe({
|
||||
applicationServerKey: new Uint8Array([0]),
|
||||
});
|
||||
ok(false, "Should reject for invalid app server keys");
|
||||
@@ -106,9 +106,9 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* validKey() {
|
||||
var pushSubscription = yield registration.pushManager.subscribe({
|
||||
applicationServerKey: yield generateKey(),
|
||||
add_task(async function validKey() {
|
||||
var pushSubscription = await registration.pushManager.subscribe({
|
||||
applicationServerKey: await generateKey(),
|
||||
});
|
||||
is(pushSubscription.endpoint, "https://example.com/push/1",
|
||||
"Wrong endpoint for subscription with key");
|
||||
@@ -117,8 +117,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"App server key getter should return the same object");
|
||||
});
|
||||
|
||||
add_task(function* retrieveKey() {
|
||||
var pushSubscription = yield registration.pushManager.getSubscription();
|
||||
add_task(async function retrieveKey() {
|
||||
var pushSubscription = await registration.pushManager.getSubscription();
|
||||
is(pushSubscription.endpoint, "https://example.com/push/subWithKey",
|
||||
"Got wrong endpoint for subscription with key");
|
||||
isDeeply(
|
||||
@@ -128,11 +128,11 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
);
|
||||
});
|
||||
|
||||
add_task(function* mismatchedKey() {
|
||||
add_task(async function mismatchedKey() {
|
||||
isTestingMismatchedKey = true;
|
||||
try {
|
||||
yield registration.pushManager.subscribe({
|
||||
applicationServerKey: yield generateKey(),
|
||||
await registration.pushManager.subscribe({
|
||||
applicationServerKey: await generateKey(),
|
||||
});
|
||||
ok(false, "Should reject for mismatched app server keys");
|
||||
} catch (error) {
|
||||
@@ -145,8 +145,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* emptyKeyInWorker() {
|
||||
var errorInfo = yield sendRequestToWorker({
|
||||
add_task(async function emptyKeyInWorker() {
|
||||
var errorInfo = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: new ArrayBuffer(0),
|
||||
});
|
||||
@@ -156,8 +156,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"Wrong exception name in worker for empty key");
|
||||
});
|
||||
|
||||
add_task(function* invalidKeyInWorker() {
|
||||
var errorInfo = yield sendRequestToWorker({
|
||||
add_task(async function invalidKeyInWorker() {
|
||||
var errorInfo = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: new Uint8Array([1]),
|
||||
});
|
||||
@@ -167,9 +167,9 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"Wrong exception name in worker for invalid key");
|
||||
});
|
||||
|
||||
add_task(function* validKeyInWorker() {
|
||||
var key = yield generateKey();
|
||||
var data = yield sendRequestToWorker({
|
||||
add_task(async function validKeyInWorker() {
|
||||
var key = await generateKey();
|
||||
var data = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: key,
|
||||
});
|
||||
@@ -179,12 +179,12 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"Wrong app server key for subscription created in worker");
|
||||
});
|
||||
|
||||
add_task(function* mismatchedKeyInWorker() {
|
||||
add_task(async function mismatchedKeyInWorker() {
|
||||
isTestingMismatchedKey = true;
|
||||
try {
|
||||
var errorInfo = yield sendRequestToWorker({
|
||||
var errorInfo = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: yield generateKey(),
|
||||
key: await generateKey(),
|
||||
});
|
||||
ok(errorInfo.isDOMException,
|
||||
"Wrong exception type in worker for mismatched key");
|
||||
@@ -195,9 +195,9 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* validKeyBuffer() {
|
||||
var key = yield generateKey();
|
||||
var pushSubscription = yield registration.pushManager.subscribe({
|
||||
add_task(async function validKeyBuffer() {
|
||||
var key = await generateKey();
|
||||
var pushSubscription = await registration.pushManager.subscribe({
|
||||
applicationServerKey: key.buffer,
|
||||
});
|
||||
is(pushSubscription.endpoint, "https://example.com/push/3",
|
||||
@@ -207,9 +207,9 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"App server key getter should match given key");
|
||||
});
|
||||
|
||||
add_task(function* validKeyBufferInWorker() {
|
||||
var key = yield generateKey();
|
||||
var data = yield sendRequestToWorker({
|
||||
add_task(async function validKeyBufferInWorker() {
|
||||
var key = await generateKey();
|
||||
var data = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: key.buffer,
|
||||
});
|
||||
@@ -219,10 +219,10 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"App server key getter should match given key for subscription created in worker");
|
||||
});
|
||||
|
||||
add_task(function* validKeyString() {
|
||||
add_task(async function validKeyString() {
|
||||
var base64Key = "BOp8kf30nj6mKFFSPw_w3JAMS99Bac8zneMJ6B6lmKixUO5XTf4AtdPgYUgWke-XE25JHdcooyLgJML1R57jhKY";
|
||||
var key = base64UrlDecode(base64Key);
|
||||
var pushSubscription = yield registration.pushManager.subscribe({
|
||||
var pushSubscription = await registration.pushManager.subscribe({
|
||||
applicationServerKey: base64Key,
|
||||
});
|
||||
is(pushSubscription.endpoint, "https://example.com/push/5",
|
||||
@@ -231,10 +231,10 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"App server key getter should match Base64-decoded key");
|
||||
});
|
||||
|
||||
add_task(function* validKeyStringInWorker() {
|
||||
add_task(async function validKeyStringInWorker() {
|
||||
var base64Key = "BOp8kf30nj6mKFFSPw_w3JAMS99Bac8zneMJ6B6lmKixUO5XTf4AtdPgYUgWke-XE25JHdcooyLgJML1R57jhKY";
|
||||
var key = base64UrlDecode(base64Key);
|
||||
var data = yield sendRequestToWorker({
|
||||
var data = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: base64Key,
|
||||
});
|
||||
@@ -244,9 +244,9 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"App server key getter should match decoded key for subscription created in worker");
|
||||
});
|
||||
|
||||
add_task(function* invalidKeyString() {
|
||||
add_task(async function invalidKeyString() {
|
||||
try {
|
||||
yield registration.pushManager.subscribe({
|
||||
await registration.pushManager.subscribe({
|
||||
applicationServerKey: "!@#$^&*",
|
||||
});
|
||||
ok(false, "Should reject for invalid Base64-encoded keys");
|
||||
@@ -258,8 +258,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* invalidKeyStringInWorker() {
|
||||
var errorInfo = yield sendRequestToWorker({
|
||||
add_task(async function invalidKeyStringInWorker() {
|
||||
var errorInfo = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: "!@#$^&*",
|
||||
});
|
||||
@@ -269,9 +269,9 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"Wrong exception name in worker for invalid Base64-encoded key");
|
||||
});
|
||||
|
||||
add_task(function* emptyKeyString() {
|
||||
add_task(async function emptyKeyString() {
|
||||
try {
|
||||
yield registration.pushManager.subscribe({
|
||||
await registration.pushManager.subscribe({
|
||||
applicationServerKey: "",
|
||||
});
|
||||
ok(false, "Should reject for empty key strings");
|
||||
@@ -283,8 +283,8 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* emptyKeyStringInWorker() {
|
||||
var errorInfo = yield sendRequestToWorker({
|
||||
add_task(async function emptyKeyStringInWorker() {
|
||||
var errorInfo = await sendRequestToWorker({
|
||||
type: "subscribeWithKey",
|
||||
key: "",
|
||||
});
|
||||
@@ -294,13 +294,13 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
"Wrong exception name in worker for empty key string");
|
||||
});
|
||||
|
||||
add_task(function* unsubscribe() {
|
||||
add_task(async function unsubscribe() {
|
||||
is(subscriptions, 6, "Wrong subscription count");
|
||||
controlledFrame.remove();
|
||||
});
|
||||
|
||||
add_task(function* unregister() {
|
||||
yield registration.unregister();
|
||||
add_task(async function unregister() {
|
||||
await registration.unregister();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -26,42 +26,42 @@ http://creativecommons.org/licenses/publicdomain/
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var registration;
|
||||
add_task(function* start() {
|
||||
yield setupPrefsAndMockSocket(new MockWebSocket());
|
||||
yield setPushPermission(true);
|
||||
add_task(async function start() {
|
||||
await setupPrefsAndMockSocket(new MockWebSocket());
|
||||
await setPushPermission(true);
|
||||
|
||||
var url = "worker.js" + "?" + (Math.random());
|
||||
registration = yield navigator.serviceWorker.register(url, {scope: "."});
|
||||
yield waitForActive(registration);
|
||||
registration = await navigator.serviceWorker.register(url, {scope: "."});
|
||||
await waitForActive(registration);
|
||||
});
|
||||
|
||||
var controlledFrame;
|
||||
add_task(function* createControlledIFrame() {
|
||||
controlledFrame = yield injectControlledFrame();
|
||||
add_task(async function createControlledIFrame() {
|
||||
controlledFrame = await injectControlledFrame();
|
||||
});
|
||||
|
||||
add_task(function* togglePermission() {
|
||||
var subscription = yield registration.pushManager.subscribe();
|
||||
add_task(async function togglePermission() {
|
||||
var subscription = await registration.pushManager.subscribe();
|
||||
ok(subscription, "Should create a push subscription");
|
||||
|
||||
yield setPushPermission(false);
|
||||
var permissionState = yield registration.pushManager.permissionState();
|
||||
await setPushPermission(false);
|
||||
var permissionState = await registration.pushManager.permissionState();
|
||||
is(permissionState, "denied", "Should deny push permission");
|
||||
|
||||
var subscription = yield registration.pushManager.getSubscription();
|
||||
var subscription = await registration.pushManager.getSubscription();
|
||||
is(subscription, null, "Should not return subscription when permission is revoked");
|
||||
|
||||
var changePromise = controlledFrame.waitOnWorkerMessage("changed");
|
||||
yield setPushPermission(true);
|
||||
yield changePromise;
|
||||
await setPushPermission(true);
|
||||
await changePromise;
|
||||
|
||||
subscription = yield registration.pushManager.getSubscription();
|
||||
subscription = await registration.pushManager.getSubscription();
|
||||
is(subscription, null, "Should drop subscription after reinstating permission");
|
||||
});
|
||||
|
||||
add_task(function* unsubscribe() {
|
||||
add_task(async function unsubscribe() {
|
||||
controlledFrame.remove();
|
||||
yield registration.unregister();
|
||||
await registration.unregister();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user