Merge mozilla-central to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2017-06-22 14:10:35 +02:00
Родитель 7a1fb44a5c 673abbab34
Коммит 95c2137595
553 изменённых файлов: 6269 добавлений и 5886 удалений

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

@ -147,7 +147,12 @@ endif
.PHONY: tup
tup:
$(call BUILDSTATUS,TIERS make tup)
$(call BUILDSTATUS,TIERS $(if $(MOZ_ARTIFACT_BUILDS),artifact )make tup)
ifdef MOZ_ARTIFACT_BUILDS
$(call BUILDSTATUS,TIER_START artifact)
$(MAKE) recurse_artifact
$(call BUILDSTATUS,TIER_FINISH artifact)
endif
$(call BUILDSTATUS,TIER_START make)
$(MAKE) buildid.h source-repo.h
$(call BUILDSTATUS,TIER_FINISH make)

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

@ -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)

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

@ -29,7 +29,7 @@ add_task(async function checkSwitchPageToOnlineMode() {
let changeObserved = TestUtils.topicObserved("network:offline-status-changed");
// Click on the 'Try again' button.
await ContentTask.spawn(browser, null, function* () {
await ContentTask.spawn(browser, null, async function() {
ok(content.document.documentURI.startsWith("about:neterror?e=netOffline"), "Should be showing error page");
content.document.getElementById("errorTryAgain").click();
});

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

@ -17,7 +17,7 @@ registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_LWTHEME_USED_THEMES);
});
add_task(function* startTests() {
add_task(async function startTests() {
if (SKIP_TEST) {
ok(true, "No need to run this test since themes aren't installed");
return;
@ -59,7 +59,7 @@ function dummyLightweightTheme(id) {
};
}
add_task(function* testLightweightThemePreview() {
add_task(async function testLightweightThemePreview() {
if (SKIP_TEST) {
ok(true, "No need to run this test since themes aren't installed");
return;

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

@ -63,7 +63,7 @@ var AboutModuleFactory = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory])
};
add_task(function* init() {
add_task(async function init() {
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
for (let module of TEST_MODULES) {
registrar.registerFactory(Components.ID(module.id), "",
@ -101,14 +101,14 @@ function test_url(url, chromeResult, contentResult) {
contentResult, "Check URL with query and ref in content process.");
}
add_task(function* test_chrome() {
add_task(async function test_chrome() {
test_url("about:" + CHROME.path, true, false);
});
add_task(function* test_any() {
add_task(async function test_any() {
test_url("about:" + CANREMOTE.path, true, true);
});
add_task(function* test_remote() {
add_task(async function test_remote() {
test_url("about:" + MUSTREMOTE.path, false, true);
});

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

@ -1,7 +1,7 @@
const CHROME_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
add_task(function*() {
add_task(async function() {
let url = "javascript:dosomething()";
ok(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS),

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

@ -4,7 +4,7 @@
"use strict";
add_task(function* () {
add_task(async function() {
// There should be one tab when we start the test
let [origTab] = gBrowser.visibleTabs;

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

@ -2,7 +2,7 @@
* 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* test() {
add_task(async function test() {
gPrefService.setBoolPref("browser.ctrlTab.previews", true);
let [origTab] = gBrowser.visibleTabs;

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

@ -93,6 +93,7 @@ const startupPhases = {
"before handling user events": {blacklist: {
modules: new Set([
"resource://gre/modules/LoginManagerContextMenu.jsm",
"resource://gre/modules/Task.jsm",
]),
}},
};

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

@ -21,16 +21,16 @@ const EXPECTED_REFLOWS = [
* window is closed, the test waits until the original window
* has activated.
*/
add_task(function*() {
add_task(async function() {
// Ensure that this browser window starts focused. This seems to be
// necessary to avoid intermittent failures when running this test
// on repeat.
yield new Promise(resolve => {
await new Promise(resolve => {
waitForFocus(resolve, window);
});
let win = yield BrowserTestUtils.openNewBrowserWindow();
yield new Promise(resolve => {
let win = await BrowserTestUtils.openNewBrowserWindow();
await new Promise(resolve => {
waitForFocus(resolve, win);
});
@ -40,7 +40,7 @@ add_task(function*() {
Assert.equal(EXPECTED_REFLOWS.length, 0,
"We shouldn't have added any new expected reflows for window close.");
yield withReflowObserver(async function() {
await withReflowObserver(async function() {
let promiseOrigBrowserFocused = BrowserTestUtils.waitForCondition(() => {
return Services.focus.activeWindow == window;
});

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

@ -27,8 +27,8 @@ function getBrowserChildrenWithOrdinals() {
});
}
add_task(function* () {
yield SidebarUI.show("viewBookmarksSidebar");
add_task(async function() {
await SidebarUI.show("viewBookmarksSidebar");
SidebarUI.showSwitcherPanel();
let reversePositionButton = document.getElementById("sidebar-reverse-position");

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

@ -22,7 +22,7 @@ function clickSwitcherButton(querySelector) {
return switcherPromise;
}
add_task(function* () {
add_task(async function() {
// If a sidebar is already open, close it.
if (!document.getElementById("sidebar-box").hidden) {
ok(false, "Unexpected sidebar found - a previous test failed to cleanup correctly");
@ -30,17 +30,17 @@ add_task(function* () {
}
let sidebar = document.querySelector("#sidebar-box");
yield SidebarUI.show("viewBookmarksSidebar");
await SidebarUI.show("viewBookmarksSidebar");
yield showSwitcherPanelPromise();
yield clickSwitcherButton("#sidebar-switcher-history");
await showSwitcherPanelPromise();
await clickSwitcherButton("#sidebar-switcher-history");
is(sidebar.getAttribute("sidebarcommand"), "viewHistorySidebar", "History sidebar loaded");
yield showSwitcherPanelPromise();
yield clickSwitcherButton("#sidebar-switcher-tabs");
await showSwitcherPanelPromise();
await clickSwitcherButton("#sidebar-switcher-tabs");
is(sidebar.getAttribute("sidebarcommand"), "viewTabsSidebar", "Tabs sidebar loaded");
yield showSwitcherPanelPromise();
yield clickSwitcherButton("#sidebar-switcher-bookmarks");
await showSwitcherPanelPromise();
await clickSwitcherButton("#sidebar-switcher-bookmarks");
is(sidebar.getAttribute("sidebarcommand"), "viewBookmarksSidebar", "Bookmarks sidebar loaded");
});

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

@ -32,7 +32,7 @@ function sum(aArray) {
* Resolves once the hang is done.
*/
function hangContentProcess(browser, aMs) {
return ContentTask.spawn(browser, aMs, function*(ms) {
return ContentTask.spawn(browser, aMs, async function(ms) {
let then = Date.now();
while (Date.now() - then < ms) {
// Let's burn some CPU...

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

@ -2,7 +2,7 @@
const BUTTONID = "test-seenwidget-post-reset";
add_task(function*() {
add_task(async function() {
CustomizableUI.createWidget({
id: BUTTONID,
label: "Test widget seen post reset",

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

@ -2,7 +2,7 @@
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
add_task(function* testAutocompletePopup() {
add_task(async function testAutocompletePopup() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"browser_action": {
@ -42,43 +42,43 @@ add_task(function* testAutocompletePopup() {
},
});
function* testDatalist(browser, doc) {
async function testDatalist(browser, doc) {
let autocompletePopup = doc.getElementById("PopupAutoComplete");
let opened = promisePopupShown(autocompletePopup);
info("click in test-input now");
// two clicks to open
yield BrowserTestUtils.synthesizeMouseAtCenter("#test-input", {}, browser);
yield BrowserTestUtils.synthesizeMouseAtCenter("#test-input", {}, browser);
await BrowserTestUtils.synthesizeMouseAtCenter("#test-input", {}, browser);
await BrowserTestUtils.synthesizeMouseAtCenter("#test-input", {}, browser);
info("wait for opened event");
yield opened;
await opened;
// third to close
let closed = promisePopupHidden(autocompletePopup);
info("click in test-input now");
yield BrowserTestUtils.synthesizeMouseAtCenter("#test-input", {}, browser);
await BrowserTestUtils.synthesizeMouseAtCenter("#test-input", {}, browser);
info("wait for closed event");
yield closed;
await closed;
// If this didn't work, we hang. Other tests deal with testing the actual functionality of datalist.
ok(true, "datalist popup has been shown");
}
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
yield extension.startup();
yield extension.awaitMessage("ready");
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
await extension.startup();
await extension.awaitMessage("ready");
clickPageAction(extension);
// intentional misspell so eslint is ok with browser in background script.
let bowser = yield awaitExtensionPanel(extension);
let bowser = await awaitExtensionPanel(extension);
ok(!!bowser, "panel opened with browser");
yield testDatalist(bowser, document);
await testDatalist(bowser, document);
closePageAction(extension);
yield new Promise(resolve => setTimeout(resolve, 0));
await new Promise(resolve => setTimeout(resolve, 0));
clickBrowserAction(extension);
bowser = yield awaitExtensionPanel(extension);
bowser = await awaitExtensionPanel(extension);
ok(!!bowser, "panel opened with browser");
yield testDatalist(bowser, document);
await testDatalist(bowser, document);
closeBrowserAction(extension);
yield new Promise(resolve => setTimeout(resolve, 0));
await new Promise(resolve => setTimeout(resolve, 0));
yield extension.unload();
yield BrowserTestUtils.removeTab(tab);
await extension.unload();
await BrowserTestUtils.removeTab(tab);
});

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

@ -2,7 +2,7 @@
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
function* testSidebarBrowserStyle(sidebarAction, assertMessage) {
async function testSidebarBrowserStyle(sidebarAction, assertMessage) {
function sidebarScript() {
browser.test.onMessage.addListener((msgName, info, assertMessage) => {
if (msgName !== "check-style") {
@ -40,34 +40,34 @@ function* testSidebarBrowserStyle(sidebarAction, assertMessage) {
},
});
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser);
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
yield extension.startup();
yield extension.awaitMessage("sidebar-ready");
await extension.startup();
await extension.awaitMessage("sidebar-ready");
extension.sendMessage("check-style", sidebarAction, assertMessage);
yield extension.awaitFinish("sidebar-browser-style");
await extension.awaitFinish("sidebar-browser-style");
yield extension.unload();
await extension.unload();
yield BrowserTestUtils.removeTab(tab);
await BrowserTestUtils.removeTab(tab);
}
add_task(function* test_sidebar_without_setting_browser_style() {
yield testSidebarBrowserStyle({
add_task(async function test_sidebar_without_setting_browser_style() {
await testSidebarBrowserStyle({
"default_panel": "panel.html",
}, "Expected correct style when browser_style is excluded");
});
add_task(function* test_sidebar_with_browser_style_set_to_true() {
yield testSidebarBrowserStyle({
add_task(async function test_sidebar_with_browser_style_set_to_true() {
await testSidebarBrowserStyle({
"default_panel": "panel.html",
"browser_style": true,
}, "Expected correct style when browser_style is set to `true`");
});
add_task(function* test_sidebar_with_browser_style_set_to_false() {
yield testSidebarBrowserStyle({
add_task(async function test_sidebar_with_browser_style_set_to_false() {
await testSidebarBrowserStyle({
"default_panel": "panel.html",
"browser_style": false,
}, "Expected no style when browser_style is set to `false`");

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

@ -286,7 +286,7 @@ function makeURI(aURL) {
return Services.io.newURI(aURL);
}
add_task(function* setup() {
add_task(async function setup() {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
Assert.throws(() => getFirstResourceOfType(MigrationUtils.resourceTypes.PASSWORDS),
"The migrator doesn't exist for win8+");
@ -305,7 +305,7 @@ add_task(function* setup() {
}
});
add_task(function* test_passwordsNotAvailable() {
add_task(async function test_passwordsNotAvailable() {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
return;
}
@ -327,7 +327,7 @@ add_task(function* test_passwordsNotAvailable() {
}
});
add_task(function* test_passwordsAvailable() {
add_task(async function test_passwordsAvailable() {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
return;
}

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

@ -13,7 +13,7 @@ function run_test() {
run_next_test();
}
add_task(function* () {
add_task(async function() {
remove_bookmarks_html();
Services.prefs.setBoolPref("browser.bookmarks.autoExportHTML", true);

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

@ -37,7 +37,7 @@ function setupBehaviorAndMigrate(aDefaultBehavior, aAutocompleteEnabled = true)
gBrowserGlue.observe(null, TOPIC_BROWSERGLUE_TEST, TOPICDATA_BROWSERGLUE_TEST);
}
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 0");
setupBehaviorAndMigrate(0);
@ -51,7 +51,7 @@ add_task(function*() {
"Typed preference should be false.");
});
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 1");
setupBehaviorAndMigrate(1);
@ -65,7 +65,7 @@ add_task(function*() {
"Typed preference should be false");
});
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 2");
setupBehaviorAndMigrate(2);
@ -79,7 +79,7 @@ add_task(function*() {
"Typed preference should be false");
});
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 3");
setupBehaviorAndMigrate(3);
@ -93,7 +93,7 @@ add_task(function*() {
"Typed preference should be false");
});
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 19");
setupBehaviorAndMigrate(19);
@ -107,7 +107,7 @@ add_task(function*() {
"Typed preference should be false");
});
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 33");
setupBehaviorAndMigrate(33);
@ -121,7 +121,7 @@ add_task(function*() {
"Typed preference should be true");
});
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 129");
setupBehaviorAndMigrate(129);
@ -135,7 +135,7 @@ add_task(function*() {
"Typed preference should be false");
});
add_task(function*() {
add_task(async function() {
do_print("Migrate default.behavior = 0, autocomplete.enabled = false");
setupBehaviorAndMigrate(0, false);

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

@ -1,16 +1,16 @@
const DEFAULT_HW_ACCEL_PREF = Services.prefs.getDefaultBranch(null).getBoolPref("layers.acceleration.disabled");
const DEFAULT_PROCESS_COUNT = Services.prefs.getDefaultBranch(null).getIntPref("dom.ipc.processCount");
add_task(function*() {
yield SpecialPowers.pushPrefEnv({set: [
add_task(async function() {
await SpecialPowers.pushPrefEnv({set: [
["layers.acceleration.disabled", DEFAULT_HW_ACCEL_PREF],
["dom.ipc.processCount", DEFAULT_PROCESS_COUNT],
["browser.preferences.defaultPerformanceSettings.enabled", true],
]});
});
add_task(function*() {
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
add_task(async function() {
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.selectedBrowser.contentDocument;
@ -71,11 +71,11 @@ add_task(function*() {
is(performanceSettings.hidden, false, "performance settings section should be still shown");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(function*() {
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
add_task(async function() {
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
@ -96,11 +96,11 @@ add_task(function*() {
is(performanceSettings.hidden, true, "performance settings section should be still shown");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(function*() {
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
add_task(async function() {
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
@ -113,13 +113,13 @@ add_task(function*() {
is(performanceSettings.hidden, false, "performance settings section should be shown");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(function*() {
add_task(async function() {
Services.prefs.setIntPref("dom.ipc.processCount", 7);
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
@ -132,13 +132,13 @@ add_task(function*() {
is(contentProcessCount.selectedItem.value, 7, "selected item should be 7");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(function*() {
add_task(async function() {
Services.prefs.setBoolPref("layers.acceleration.disabled", true);
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
@ -152,5 +152,5 @@ add_task(function*() {
ok(!allowHWAccel.checked, "checkbox should not be checked");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

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

@ -1,16 +1,16 @@
const DEFAULT_HW_ACCEL_PREF = Services.prefs.getDefaultBranch(null).getBoolPref("layers.acceleration.disabled");
const DEFAULT_PROCESS_COUNT = Services.prefs.getDefaultBranch(null).getIntPref("dom.ipc.processCount");
add_task(function*() {
yield SpecialPowers.pushPrefEnv({set: [
add_task(async function() {
await SpecialPowers.pushPrefEnv({set: [
["layers.acceleration.disabled", DEFAULT_HW_ACCEL_PREF],
["dom.ipc.processCount", DEFAULT_PROCESS_COUNT],
["browser.preferences.defaultPerformanceSettings.enabled", true],
]});
});
add_task(function*() {
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
add_task(async function() {
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.selectedBrowser.contentDocument;
@ -59,11 +59,11 @@ add_task(function*() {
is(performanceSettings.hidden, false, "performance settings section should be still shown");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(function*() {
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
add_task(async function() {
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
@ -76,13 +76,13 @@ add_task(function*() {
is(performanceSettings.hidden, false, "performance settings section should be shown");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
add_task(function*() {
add_task(async function() {
Services.prefs.setBoolPref("layers.acceleration.disabled", true);
let prefs = yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
let prefs = await openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane was selected");
let doc = gBrowser.contentDocument;
@ -96,5 +96,5 @@ add_task(function*() {
ok(!allowHWAccel.checked, "checkbox should not be checked");
Services.prefs.setBoolPref("browser.preferences.defaultPerformanceSettings.enabled", true);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

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

@ -70,22 +70,22 @@ https://trac.torproject.org/projects/tor/ticket/1517
worker.terminate();
}
add_task(function* testWorker() {
add_task(async function testWorker() {
// Create one worker before setting the pref, and one after, in order to
// check that the resolution is updated whether or not the worker was
// already started
let worker1 = new Worker("worker_child.js");
yield SpecialPowers.pushPrefEnv({
await SpecialPowers.pushPrefEnv({
"set": [["privacy.resistFingerprinting", true]]});
let worker2 = new Worker("worker_child.js");
// Allow ~550 ms to elapse, so we can get non-zero
// time values for all elements.
yield new Promise(resolve => window.setTimeout(resolve, 550));
yield checkWorker(worker1);
yield checkWorker(worker2);
await new Promise(resolve => window.setTimeout(resolve, 550));
await checkWorker(worker1);
await checkWorker(worker2);
});
add_task(function* testDOM() {
add_task(async function testDOM() {
let timeStampCodesDOM = timeStampCodes.concat([
'audioContext.currentTime * 1000',
'canvasStream.currentTime * 1000',

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

@ -38,7 +38,7 @@ function compareCookies(a) {
}
// Setup and cleanup.
add_task(function* test_setup() {
add_task(async function test_setup() {
Services.prefs.clearUserPref("browser.sessionstore.privacy_level");
registerCleanupFunction(() => {
@ -48,7 +48,7 @@ add_task(function* test_setup() {
});
// Test privacy_level=none (default). We store all session cookies.
add_task(function* test_level_none() {
add_task(async function test_level_none() {
Services.cookies.removeAll();
// Set level=none, store all cookies.
@ -68,7 +68,7 @@ add_task(function* test_level_none() {
});
// Test privacy_level=encrypted. We store all non-secure session cookies.
add_task(function* test_level_encrypted() {
add_task(async function test_level_encrypted() {
Services.cookies.removeAll();
// Set level=encrypted, don't store any secure cookies.
@ -90,7 +90,7 @@ add_task(function* test_level_encrypted() {
});
// Test privacy_level=full. We store no session cookies.
add_task(function* test_level_full() {
add_task(async function test_level_full() {
Services.cookies.removeAll();
// Set level=full, don't store any cookies.

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

@ -2,7 +2,7 @@
let { EventEmitter } = Cu.import("resource:///modules/syncedtabs/EventEmitter.jsm", {});
add_task(function* testSingleListener() {
add_task(async function testSingleListener() {
let eventEmitter = new EventEmitter();
let spy = sinon.spy();
@ -16,7 +16,7 @@ add_task(function* testSingleListener() {
Assert.ok(spy.calledOnce);
});
add_task(function* testMultipleListeners() {
add_task(async function testMultipleListeners() {
let eventEmitter = new EventEmitter();
let spy1 = sinon.spy();
let spy2 = sinon.spy();

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

@ -2,7 +2,7 @@
let { SyncedTabsDeckStore } = Cu.import("resource:///modules/syncedtabs/SyncedTabsDeckStore.js", {});
add_task(function* testSelectUnkownPanel() {
add_task(async function testSelectUnkownPanel() {
let deckStore = new SyncedTabsDeckStore();
let spy = sinon.spy();
@ -12,7 +12,7 @@ add_task(function* testSelectUnkownPanel() {
Assert.ok(!spy.called);
});
add_task(function* testSetPanels() {
add_task(async function testSetPanels() {
let deckStore = new SyncedTabsDeckStore();
let spy = sinon.spy();
@ -28,7 +28,7 @@ add_task(function* testSetPanels() {
}));
});
add_task(function* testSelectPanel() {
add_task(async function testSelectPanel() {
let deckStore = new SyncedTabsDeckStore();
let spy = sinon.spy();
@ -49,7 +49,7 @@ add_task(function* testSelectPanel() {
Assert.ok(spy.calledOnce, "doesn't trigger unless panel changes");
});
add_task(function* testSetPanelsSameArray() {
add_task(async function testSetPanelsSameArray() {
let deckStore = new SyncedTabsDeckStore();
let spy = sinon.spy();
deckStore.on("change", spy);

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

@ -21,7 +21,7 @@ const ACTION_METHODS = [
"onFilterBlur",
];
add_task(function* testInitUninit() {
add_task(async function testInitUninit() {
let store = new SyncedTabsListStore();
let ViewMock = sinon.stub();
let view = {render() {}, destroy() {}};
@ -68,7 +68,7 @@ add_task(function* testInitUninit() {
Assert.ok(view.destroy.calledOnce, "view is destroyed on uninit");
});
add_task(function* testActions() {
add_task(async function testActions() {
let store = new SyncedTabsListStore();
let chromeWindowMock = {
gBrowser: {

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

@ -68,7 +68,7 @@ MockContentPermissionRequest.prototype = {
* types array, that NS_ERROR_UNEXPECTED is thrown, and the
* request is cancelled.
*/
add_task(function* test_empty_types() {
add_task(async function test_empty_types() {
let mockRequest = new MockContentPermissionRequest([]);
Assert.throws(() => { ContentPermissionPrompt.prompt(mockRequest); },
/NS_ERROR_UNEXPECTED/,
@ -81,7 +81,7 @@ add_task(function* test_empty_types() {
* one type, that NS_ERROR_UNEXPECTED is thrown, and the request
* is cancelled.
*/
add_task(function* test_multiple_types() {
add_task(async function test_multiple_types() {
let mockRequest = new MockContentPermissionRequest([
new MockContentPermissionType("test1"),
new MockContentPermissionType("test2"),
@ -97,7 +97,7 @@ add_task(function* test_multiple_types() {
* does not implement nsIContentPermissionType that NS_NOINTERFACE
* is thrown, and the request is cancelled.
*/
add_task(function* test_not_permission_type() {
add_task(async function test_not_permission_type() {
let mockRequest = new MockContentPermissionRequest([
{ QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]) },
]);
@ -112,7 +112,7 @@ add_task(function* test_not_permission_type() {
* that is not recognized, that NS_ERROR_FAILURE is thrown and
* the request is cancelled.
*/
add_task(function* test_unrecognized_type() {
add_task(async function test_unrecognized_type() {
let mockRequest = new MockContentPermissionRequest([
new MockContentPermissionType("test1"),
]);
@ -128,7 +128,7 @@ add_task(function* test_unrecognized_type() {
* ContentPermissionIntegration's createPermissionPrompt
* method.
*/
add_task(function* test_working_request() {
add_task(async function test_working_request() {
let mockType = new MockContentPermissionType("test-permission-type");
let mockRequest = new MockContentPermissionRequest([mockType]);

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

@ -7,7 +7,7 @@ var gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"]
Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
add_task(function* test_check_cleanup_loop_prefs() {
add_task(async function test_check_cleanup_loop_prefs() {
Services.prefs.setBoolPref("loop.createdRoom", true);
Services.prefs.setBoolPref("loop1.createdRoom", true);
Services.prefs.setBoolPref("loo.createdRoom", true);

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

@ -88,7 +88,7 @@ do_register_cleanup(function() {
Assert.ok(!distDir.exists());
});
add_task(function* () {
add_task(async function() {
// Force distribution.
let glue = Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIObserver)
glue.observe(null, TOPIC_BROWSERGLUE_TEST, TOPICDATA_DISTRIBUTION_CUSTOMIZATION);

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

@ -1,5 +1,9 @@
# This file is sourced by the nightly, beta, and release mozconfigs.
# TODO remove once configure defaults to stylo once stylo enabled
# on all platforms.
ac_add_options --enable-stylo=build
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
ac_add_options --with-google-api-keyfile=/builds/gapi.data
ac_add_options --with-mozilla-api-keyfile=/builds/mozilla-desktop-geoloc-api.key

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

@ -2,6 +2,9 @@ ac_add_options --enable-debug
ac_add_options --enable-dmd
ac_add_options --enable-verify-mar
# TODO remove once configure defaults to stylo once stylo enabled
ac_add_options --enable-stylo=build
MOZ_AUTOMATION_L10N_CHECK=0
. $topsrcdir/build/unix/mozconfig.linux

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

@ -16,9 +16,9 @@
"unpack": true
},
{
"version": "rustc 1.15.1 (021bd294c 2017-02-08) repack",
"size": 110077036,
"digest": "8b99d058cc081f6ca2a3cc88c3ca9c15232961d2539774dacee35e2258955ad8fc4cb0af3b903a3e3f8a264ddecb3baae9256502ffc178a2823779284ace2bd8",
"version": "rustc 1.17.0 (56124baa9 2017-04-24) repack",
"size": 121834488,
"digest": "8ce3d979c169af6c6e2bf393aa2bd4825371e87d42ebdfd7d7f06c0e3e69c0d68a3dcd39d9a85bcaa9fe5c6d6fe86e881fc8413d74c2a240204f2bafca781b9d",
"algorithm": "sha512",
"filename": "rustc.tar.xz",
"unpack": true

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

@ -28,20 +28,20 @@ var cacheData = {
_branch: null
};
add_task(function* test_valid() {
add_task(async function test_valid() {
let e = new Experiments.ExperimentEntry();
Assert.ok(e.initFromCacheData(cacheData));
Assert.ok(e.enabled);
});
add_task(function* test_upgrade() {
add_task(async function test_upgrade() {
let e = new Experiments.ExperimentEntry();
delete cacheData._branch;
Assert.ok(e.initFromCacheData(cacheData));
Assert.ok(e.enabled);
});
add_task(function* test_missing() {
add_task(async function test_missing() {
let e = new Experiments.ExperimentEntry();
delete cacheData._name;
Assert.ok(!e.initFromCacheData(cacheData));

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

@ -31,9 +31,9 @@ this.Store = class Store {
// Bind each redux method so we can call it directly from the Store. E.g.,
// store.dispatch() will call store._store.dispatch();
["dispatch", "getState", "subscribe"].forEach(method => {
this[method] = function(...args) {
this[method] = (...args) => {
return this._store[method](...args);
}.bind(this);
};
});
this.feeds = new Map();
this._feedFactories = null;

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

@ -57,10 +57,10 @@ function FormAutofillParent() {
let {profileStorage} = Cu.import("resource://formautofill/ProfileStorage.jsm", {});
log.debug("Loading profileStorage");
profileStorage.initialize().then(function onStorageInitialized() {
profileStorage.initialize().then(() => {
// Update the saved field names to compute the status and update child processes.
this._updateSavedFieldNames();
}.bind(this));
});
return profileStorage;
});
@ -286,13 +286,16 @@ FormAutofillParent.prototype = {
this.profileStorage.addresses.notifyUsed(address.guid);
} else {
if (!Services.prefs.getBoolPref("extensions.formautofill.firstTimeUse")) {
if (!this.profileStorage.addresses.mergeToStorage(address.record)) {
this.profileStorage.addresses.add(address.record);
let changedGUIDs = this.profileStorage.addresses.mergeToStorage(address.record);
if (!changedGUIDs.length) {
changedGUIDs.push(this.profileStorage.addresses.add(address.record));
}
changedGUIDs.forEach(guid => this.profileStorage.addresses.notifyUsed(guid));
return;
}
this.profileStorage.addresses.add(address.record);
let guid = this.profileStorage.addresses.add(address.record);
this.profileStorage.addresses.notifyUsed(guid);
Services.prefs.setBoolPref("extensions.formautofill.firstTimeUse", false);
FormAutofillDoorhanger.show(target, "firstTimeUse");
}

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

@ -526,18 +526,18 @@ class Addresses extends AutofillRecords {
* Merge the address if storage has multiple mergeable records.
* @param {Object} targetAddress
* The address for merge.
* @returns {boolean}
* Return true if the target address is mergeable or false if not.
* @returns {Array.<string>}
* Return an array of the merged GUID string.
*/
mergeToStorage(targetAddress) {
let merged = false;
let mergedGUIDs = [];
for (let address of this._store.data[this._collectionName]) {
if (this.mergeIfPossible(address.guid, targetAddress)) {
merged = true;
mergedGUIDs.push(address.guid);
}
}
this.log.debug("Existing records matching and merging is", merged);
return merged;
this.log.debug("Existing records matching and merging count is", mergedGUIDs.length);
return mergedGUIDs;
}
}

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

@ -50,6 +50,12 @@ var ParentUtils = {
return false;
}
}
// Check the internal field if both addresses have valid value.
for (let field of profileStorage.INTERNAL_FIELDS) {
if (field in addressA && field in addressB && (addressA[field] !== addressB[field])) {
return false;
}
}
return true;
},

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

@ -44,6 +44,8 @@ add_task(async function check_storage_after_form_submitted() {
let expectedAddresses = TEST_ADDRESSES.slice(0, 1);
await onAddressChanged("add");
// Check if timesUsed is set correctly
expectedAddresses[0].timesUsed = 1;
let matching = await checkAddresses(expectedAddresses);
ok(matching, "Address saved as expected");
});

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

@ -121,7 +121,7 @@ function runHeuristicsTest(patterns, fixturePathPrefix) {
Cu.import("resource://formautofill/FormAutofillUtils.jsm");
patterns.forEach(testPattern => {
add_task(function* () {
add_task(async function() {
do_print("Starting test fixture: " + testPattern.fixturePath);
let file = do_get_file(fixturePathPrefix + testPattern.fixturePath);
let doc = MockDocument.createTestDocumentFromFile("http://localhost:8080/test/", file);

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

@ -359,7 +359,7 @@ add_task(async function test_mergeToStorage() {
let anotherAddress = profileStorage.addresses._clone(TEST_ADDRESS_2);
profileStorage.addresses.add(anotherAddress);
anotherAddress.email = "timbl@w3.org";
do_check_eq(profileStorage.addresses.mergeToStorage(anotherAddress), true);
do_check_eq(profileStorage.addresses.mergeToStorage(anotherAddress).length, 2);
do_check_eq(profileStorage.addresses.getAll()[1].email, anotherAddress.email);
do_check_eq(profileStorage.addresses.getAll()[2].email, anotherAddress.email);
});

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

@ -85,7 +85,7 @@ const TESTCASES = [
for (let tc of TESTCASES) {
(function() {
let testcase = tc;
add_task(function* () {
add_task(async function() {
do_print("Starting testcase: " + testcase.description);
let doc = MockDocument.createTestDocument("http://localhost:8080/test/",

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

@ -52,7 +52,7 @@ const TESTCASES = [
];
TESTCASES.forEach(testcase => {
add_task(function* () {
add_task(async function() {
do_print("Starting testcase: " + testcase.description);
let doc = MockDocument.createTestDocument(

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

@ -76,7 +76,7 @@ const TESTCASES = [
];
TESTCASES.forEach(testcase => {
add_task(function* () {
add_task(async function() {
do_print("Starting testcase: " + testcase.description);
let doc = MockDocument.createTestDocument(

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

@ -79,7 +79,7 @@ function inputDetailAssertion(detail, expected) {
}
TESTCASES.forEach(testcase => {
add_task(function* () {
add_task(async function() {
do_print("Starting testcase: " + testcase.description);
let doc = MockDocument.createTestDocument(

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

@ -211,7 +211,7 @@ const TESTCASES = [
];
TESTCASES.forEach(testcase => {
add_task(function* () {
add_task(async function() {
do_print("Starting testcase: " + testcase.description);
let doc = MockDocument.createTestDocument(

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

@ -66,7 +66,7 @@ const TESTCASES = [
];
TESTCASES.forEach(testcase => {
add_task(function* () {
add_task(async function() {
do_print("Starting testcase: " + testcase.document);
let doc = MockDocument.createTestDocument(

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

@ -66,7 +66,7 @@ FormAutofillContent._markAsAutofillField = function(field) {
};
TESTCASES.forEach(testcase => {
add_task(function* () {
add_task(async function() {
do_print("Starting testcase: " + testcase.description);
markedFieldId = [];

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

@ -161,7 +161,7 @@ let testCases = [{
},
}];
add_task(function* test_all_patterns() {
add_task(async function test_all_patterns() {
testCases.forEach(testCase => {
do_print("Starting testcase: " + testCase.description);
let actual = new ProfileAutoCompleteResult(testCase.searchString,

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

@ -6,14 +6,14 @@ function checkElements(expectPresent, l) {
}
}
add_task(function*() {
yield promiseScreenshotsEnabled();
add_task(async function() {
await promiseScreenshotsEnabled();
registerCleanupFunction(function* () {
yield promiseScreenshotsReset();
registerCleanupFunction(async function() {
await promiseScreenshotsReset();
});
yield BrowserTestUtils.waitForCondition(
await BrowserTestUtils.waitForCondition(
() => document.getElementById("screenshots_mozilla_org-browser-action"),
"Screenshots button should be present", 100, 100);

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

@ -4,7 +4,7 @@ Cu.import("resource://shield-recipe-client/lib/SandboxManager.jsm");
// wrapAsync should wrap privileged Promises with Promises that are usable by
// the sandbox.
add_task(function* () {
add_task(async function() {
const manager = new SandboxManager();
manager.addHold("testing");
@ -25,7 +25,7 @@ add_task(function* () {
manager.addGlobal("ok", ok);
manager.addGlobal("equal", equal);
const sandboxResult = yield new Promise(resolve => {
const sandboxResult = await new Promise(resolve => {
manager.addGlobal("resolve", result => resolve(result));
manager.evalInSandbox(`
// Unwrapped privileged promises are not accessible in the sandbox
@ -45,7 +45,7 @@ add_task(function* () {
});
equal(sandboxResult, "wrapped", "wrapAsync methods return Promises that work in the sandbox");
yield manager.evalInSandbox(`
await manager.evalInSandbox(`
(async function sandboxTest() {
equal(
await driver.wrappedThis(),
@ -59,7 +59,7 @@ add_task(function* () {
});
// wrapAsync cloning options
add_task(function* () {
add_task(async function() {
const manager = new SandboxManager();
manager.addHold("testing");
@ -80,7 +80,7 @@ add_task(function* () {
manager.addGlobal("ok", ok);
manager.addGlobal("deepEqual", deepEqual);
yield new Promise(resolve => {
await new Promise(resolve => {
manager.addGlobal("resolve", resolve);
manager.evalInSandbox(`
(async function() {

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

@ -12,7 +12,7 @@ Services.prefs.setBoolPref(kEnabledPref, true);
Components.utils.import("resource://testing-common/AppInfo.jsm");
updateAppInfo();
add_task(function* test_page_applies() {
add_task(async function test_page_applies() {
Services.prefs.setCharPref(kPagePrefRoot + "test_LaterRun_unittest.url", "https://www.mozilla.org/%VENDOR%/%NAME%/%ID%/%VERSION%/");
Services.prefs.setIntPref(kPagePrefRoot + "test_LaterRun_unittest.minimumHoursSinceInstall", 10);
Services.prefs.setIntPref(kPagePrefRoot + "test_LaterRun_unittest.minimumSessionCount", 3);
@ -82,7 +82,7 @@ add_task(function* test_page_applies() {
clearAllPagePrefs();
});
add_task(function* test_get_URL() {
add_task(async function test_get_URL() {
Services.prefs.setIntPref(kProfileCreationTime, Math.floor((Date.now() - 11 * 60 * 60 * 1000) / 1000));
Services.prefs.setCharPref(kPagePrefRoot + "test_LaterRun_unittest.url", "https://www.mozilla.org/");
Services.prefs.setIntPref(kPagePrefRoot + "test_LaterRun_unittest.minimumHoursSinceInstall", 10);
@ -107,7 +107,7 @@ add_task(function* test_get_URL() {
clearAllPagePrefs();
});
add_task(function* test_insecure_urls() {
add_task(async function test_insecure_urls() {
Services.prefs.setCharPref(kPagePrefRoot + "test_LaterRun_unittest.url", "http://www.mozilla.org/");
Services.prefs.setIntPref(kPagePrefRoot + "test_LaterRun_unittest.minimumHoursSinceInstall", 10);
Services.prefs.setIntPref(kPagePrefRoot + "test_LaterRun_unittest.minimumSessionCount", 3);
@ -119,7 +119,7 @@ add_task(function* test_insecure_urls() {
clearAllPagePrefs();
});
add_task(function* test_dynamic_pref_getter_setter() {
add_task(async function test_dynamic_pref_getter_setter() {
delete LaterRun._sessionCount;
Services.prefs.setIntPref(kSessionCountPref, 0);
Assert.equal(LaterRun.sessionCount, 0, "Should start at 0");

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

@ -8,7 +8,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
const STORAGE_MANAGER_ENABLED = Services.prefs.getBoolPref("browser.storageManager.enabled");
add_task(function* testPermissionsListing() {
add_task(async function testPermissionsListing() {
let expectedPermissions = ["camera", "cookie", "desktop-notification", "focus-tab-by-prompt",
"geo", "image", "indexedDB", "install", "microphone", "popup", "screen"];
if (STORAGE_MANAGER_ENABLED) {
@ -21,7 +21,7 @@ add_task(function* testPermissionsListing() {
"Correct list of all permissions");
});
add_task(function* testGetAllByURI() {
add_task(async function testGetAllByURI() {
// check that it returns an empty array on an invalid URI
// like a file URI, which doesn't support site permissions
let wrongURI = Services.io.newURI("file:///example.js")
@ -60,7 +60,7 @@ add_task(function* testGetAllByURI() {
SitePermissions.remove(uri, "addon");
});
add_task(function* testGetAvailableStates() {
add_task(async function testGetAvailableStates() {
Assert.deepEqual(SitePermissions.getAvailableStates("camera"),
[ SitePermissions.UNKNOWN,
SitePermissions.ALLOW,
@ -76,7 +76,7 @@ add_task(function* testGetAvailableStates() {
SitePermissions.BLOCK ]);
});
add_task(function* testExactHostMatch() {
add_task(async function testExactHostMatch() {
let uri = Services.io.newURI("https://example.com");
let subUri = Services.io.newURI("https://test1.example.com");

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

@ -55,7 +55,7 @@ def rust_compiler(rustc_info, cargo_info):
You can install rust by running './mach bootstrap'
or by directly running the installer from https://rustup.rs/
'''))
rustc_min_version = Version('1.15.1')
rustc_min_version = Version('1.17.0')
cargo_min_version = Version('0.{}'.format(rustc_min_version.minor + 1))
version = rustc_info.version

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

@ -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

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

@ -39,50 +39,50 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=840488
});
function navigateFrame(ifr, src) {
let deferred = Promise.defer();
function onload() {
ifr.removeEventListener('load', onload);
deferred.resolve();
}
ifr.addEventListener('load', onload, false);
ifr.setAttribute('src', src);
return deferred.promise;
return new Promise(resolve => {
function onload() {
ifr.removeEventListener('load', onload);
resolve();
}
ifr.addEventListener('load', onload, false);
ifr.setAttribute('src', src);
});
}
function navigateBack(ifr) {
let deferred = Promise.defer();
return new Promise(resolve => {
// pageshow events don't fire on the iframe element, so we need to use the
// chrome event handler for the docshell.
var browser = ifr.contentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
function onpageshow(evt) {
info("Navigated back. Persisted: " + evt.persisted);
browser.removeEventListener('pageshow', onpageshow);
deferred.resolve();
}
browser.addEventListener('pageshow', onpageshow, false);
ifr.contentWindow.history.back();
return deferred.promise;
// pageshow events don't fire on the iframe element, so we need to use the
// chrome event handler for the docshell.
var browser = ifr.contentWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
function onpageshow(evt) {
info("Navigated back. Persisted: " + evt.persisted);
browser.removeEventListener('pageshow', onpageshow);
resolve();
}
browser.addEventListener('pageshow', onpageshow, false);
ifr.contentWindow.history.back();
});
}
function addFrame(parentWin, name, expectOnload) {
let ifr = parentWin.document.createElement('iframe');
parentWin.document.body.appendChild(ifr);
ifr.setAttribute('name', name);
let deferred = Promise.defer();
// We need to append 'name' to avoid running afoul of recursive frame detection.
let frameURI = uri + "?name=" + name;
navigateFrame(ifr, frameURI).then(function() {
is(String(ifr.contentWindow.location), frameURI, "Successful load");
is(!!ifr.contentWindow.wrappedJSObject.gFiredOnload, expectOnload,
"onload should only fire when scripts are enabled");
deferred.resolve();
return new Promise(resolve => {
// We need to append 'name' to avoid running afoul of recursive frame detection.
let frameURI = uri + "?name=" + name;
navigateFrame(ifr, frameURI).then(function() {
is(String(ifr.contentWindow.location), frameURI, "Successful load");
is(!!ifr.contentWindow.wrappedJSObject.gFiredOnload, expectOnload,
"onload should only fire when scripts are enabled");
resolve();
});
});
return deferred.promise;
}
function checkScriptEnabled(win, expectEnabled) {
@ -99,17 +99,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=840488
function testList(expectEnabled, win, list, idx) {
idx = idx || 0;
let deferred = Promise.defer();
let target = list[idx] + path;
info("Testing scriptability for: " + target + ". expecting " + expectEnabled);
navigateFrame(win.frameElement, target).then(function() {
checkScriptEnabled(win, expectEnabled);
if (idx == list.length - 1)
deferred.resolve();
else
testList(expectEnabled, win, list, idx + 1).then(function() { deferred.resolve(); });
return new Promise(resolve => {
let target = list[idx] + path;
info("Testing scriptability for: " + target + ". expecting " + expectEnabled);
navigateFrame(win.frameElement, target).then(function() {
checkScriptEnabled(win, expectEnabled);
if (idx == list.length - 1)
resolve();
else
testList(expectEnabled, win, list, idx + 1).then(function() { resolve(); });
});
});
return deferred.promise;
}
function testDomainPolicy(defaultScriptability, exceptions, superExceptions,
@ -131,13 +131,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=840488
}
function reloadFrame(frame) {
let deferred = Promise.defer();
frame.addEventListener('load', function onload() {
deferred.resolve();
frame.removeEventListener('load', onload);
}, false);
frame.contentWindow.location.reload(true);
return deferred.promise;
return new Promise(resolve => {
frame.addEventListener('load', function onload() {
resolve();
frame.removeEventListener('load', onload);
}, false);
frame.contentWindow.location.reload(true);
});
}
function go() {

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

@ -190,7 +190,8 @@ TableWidget.prototype = {
* Returns the index of the selected row disregarding hidden rows.
*/
get visibleSelectedIndex() {
let cells = this.columns.get(this.uniqueId).visibleCellNodes;
let column = this.firstVisibleColumn;
let cells = column.visibleCellNodes;
for (let i = 0; i < cells.length; i++) {
if (cells[i].classList.contains("theme-selected")) {
@ -201,6 +202,23 @@ TableWidget.prototype = {
return -1;
},
/**
* Returns the first visible column.
*/
get firstVisibleColumn() {
for (let column of this.columns.values()) {
if (column._private) {
continue;
}
if (column.column.clientHeight > 0) {
return column;
}
}
return null;
},
/**
* returns all editable columns.
*/

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

@ -9,6 +9,7 @@
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
showAllColumns(true);
showColumn("uniqueKey", false);
let id = getCookieId("test4", "test1.example.org", "/browser");
yield startCellEdit(id, "name");

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

@ -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.

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

@ -744,7 +744,7 @@ Animation::ElapsedTimeToTimeStamp(
const StickyTimeDuration& aElapsedTime) const
{
TimeDuration delay = mEffect
? mEffect->SpecifiedTiming().mDelay
? mEffect->SpecifiedTiming().Delay()
: TimeDuration();
return AnimationTimeToTimeStamp(aElapsedTime + delay);
}

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

@ -97,27 +97,27 @@ AnimationEffectReadOnly::GetComputedTimingAt(
// Always return the same object to benefit from return-value optimization.
ComputedTiming result;
if (aTiming.mDuration) {
MOZ_ASSERT(aTiming.mDuration.ref() >= zeroDuration,
if (aTiming.Duration()) {
MOZ_ASSERT(aTiming.Duration().ref() >= zeroDuration,
"Iteration duration should be positive");
result.mDuration = aTiming.mDuration.ref();
result.mDuration = aTiming.Duration().ref();
}
MOZ_ASSERT(aTiming.mIterations >= 0.0 && !IsNaN(aTiming.mIterations),
MOZ_ASSERT(aTiming.Iterations() >= 0.0 && !IsNaN(aTiming.Iterations()),
"mIterations should be nonnegative & finite, as ensured by "
"ValidateIterations or CSSParser");
result.mIterations = aTiming.mIterations;
result.mIterations = aTiming.Iterations();
MOZ_ASSERT(aTiming.mIterationStart >= 0.0,
MOZ_ASSERT(aTiming.IterationStart() >= 0.0,
"mIterationStart should be nonnegative, as ensured by "
"ValidateIterationStart");
result.mIterationStart = aTiming.mIterationStart;
result.mIterationStart = aTiming.IterationStart();
result.mActiveDuration = aTiming.ActiveDuration();
result.mEndTime = aTiming.EndTime();
result.mFill = aTiming.mFill == dom::FillMode::Auto ?
result.mFill = aTiming.Fill() == dom::FillMode::Auto ?
dom::FillMode::None :
aTiming.mFill;
aTiming.Fill();
// The default constructor for ComputedTiming sets all other members to
// values consistent with an animation that has not been sampled.
@ -127,11 +127,11 @@ AnimationEffectReadOnly::GetComputedTimingAt(
const TimeDuration& localTime = aLocalTime.Value();
StickyTimeDuration beforeActiveBoundary =
std::max(std::min(StickyTimeDuration(aTiming.mDelay), result.mEndTime),
std::max(std::min(StickyTimeDuration(aTiming.Delay()), result.mEndTime),
zeroDuration);
StickyTimeDuration activeAfterBoundary =
std::max(std::min(StickyTimeDuration(aTiming.mDelay +
std::max(std::min(StickyTimeDuration(aTiming.Delay() +
result.mActiveDuration),
result.mEndTime),
zeroDuration);
@ -144,7 +144,7 @@ AnimationEffectReadOnly::GetComputedTimingAt(
return result;
}
result.mActiveTime =
std::max(std::min(StickyTimeDuration(localTime - aTiming.mDelay),
std::max(std::min(StickyTimeDuration(localTime - aTiming.Delay()),
result.mActiveDuration),
zeroDuration);
} else if (localTime < beforeActiveBoundary ||
@ -155,13 +155,13 @@ AnimationEffectReadOnly::GetComputedTimingAt(
return result;
}
result.mActiveTime
= std::max(StickyTimeDuration(localTime - aTiming.mDelay),
= std::max(StickyTimeDuration(localTime - aTiming.Delay()),
zeroDuration);
} else {
MOZ_ASSERT(result.mActiveDuration != zeroDuration,
"How can we be in the middle of a zero-duration interval?");
result.mPhase = ComputedTiming::AnimationPhase::Active;
result.mActiveTime = localTime - aTiming.mDelay;
result.mActiveTime = localTime - aTiming.Delay();
}
// Convert active time to a multiple of iterations.
@ -220,7 +220,7 @@ AnimationEffectReadOnly::GetComputedTimingAt(
// Factor in the direction.
bool thisIterationReverse = false;
switch (aTiming.mDirection) {
switch (aTiming.Direction()) {
case PlaybackDirection::Normal:
thisIterationReverse = false;
break;
@ -250,8 +250,8 @@ AnimationEffectReadOnly::GetComputedTimingAt(
}
// Apply the easing.
if (aTiming.mFunction) {
progress = aTiming.mFunction->GetValue(progress, result.mBeforeFlag);
if (aTiming.TimingFunction()) {
progress = aTiming.TimingFunction()->GetValue(progress, result.mBeforeFlag);
}
MOZ_ASSERT(IsFinite(progress), "Progress value should be finite");
@ -276,14 +276,14 @@ GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
ComputedTimingProperties& aRetVal)
{
// AnimationEffectTimingProperties
aRetVal.mDelay = aTiming.mDelay.ToMilliseconds();
aRetVal.mEndDelay = aTiming.mEndDelay.ToMilliseconds();
aRetVal.mDelay = aTiming.Delay().ToMilliseconds();
aRetVal.mEndDelay = aTiming.EndDelay().ToMilliseconds();
aRetVal.mFill = aComputedTiming.mFill;
aRetVal.mIterations = aComputedTiming.mIterations;
aRetVal.mIterationStart = aComputedTiming.mIterationStart;
aRetVal.mDuration.SetAsUnrestrictedDouble() =
aComputedTiming.mDuration.ToMilliseconds();
aRetVal.mDirection = aTiming.mDirection;
aRetVal.mDirection = aTiming.Direction();
// ComputedTimingProperties
aRetVal.mActiveDuration = aComputedTiming.mActiveDuration.ToMilliseconds();

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

@ -33,10 +33,10 @@ void
AnimationEffectTiming::SetDelay(double aDelay)
{
TimeDuration delay = TimeDuration::FromMilliseconds(aDelay);
if (mTiming.mDelay == delay) {
if (mTiming.Delay() == delay) {
return;
}
mTiming.mDelay = delay;
mTiming.SetDelay(delay);
PostSpecifiedTimingUpdated(mEffect);
}
@ -45,10 +45,10 @@ void
AnimationEffectTiming::SetEndDelay(double aEndDelay)
{
TimeDuration endDelay = TimeDuration::FromMilliseconds(aEndDelay);
if (mTiming.mEndDelay == endDelay) {
if (mTiming.EndDelay() == endDelay) {
return;
}
mTiming.mEndDelay = endDelay;
mTiming.SetEndDelay(endDelay);
PostSpecifiedTimingUpdated(mEffect);
}
@ -56,10 +56,10 @@ AnimationEffectTiming::SetEndDelay(double aEndDelay)
void
AnimationEffectTiming::SetFill(const FillMode& aFill)
{
if (mTiming.mFill == aFill) {
if (mTiming.Fill() == aFill) {
return;
}
mTiming.mFill = aFill;
mTiming.SetFill(aFill);
PostSpecifiedTimingUpdated(mEffect);
}
@ -68,7 +68,7 @@ void
AnimationEffectTiming::SetIterationStart(double aIterationStart,
ErrorResult& aRv)
{
if (mTiming.mIterationStart == aIterationStart) {
if (mTiming.IterationStart() == aIterationStart) {
return;
}
@ -77,7 +77,7 @@ AnimationEffectTiming::SetIterationStart(double aIterationStart,
return;
}
mTiming.mIterationStart = aIterationStart;
mTiming.SetIterationStart(aIterationStart);
PostSpecifiedTimingUpdated(mEffect);
}
@ -85,7 +85,7 @@ AnimationEffectTiming::SetIterationStart(double aIterationStart,
void
AnimationEffectTiming::SetIterations(double aIterations, ErrorResult& aRv)
{
if (mTiming.mIterations == aIterations) {
if (mTiming.Iterations() == aIterations) {
return;
}
@ -94,7 +94,7 @@ AnimationEffectTiming::SetIterations(double aIterations, ErrorResult& aRv)
return;
}
mTiming.mIterations = aIterations;
mTiming.SetIterations(aIterations);
PostSpecifiedTimingUpdated(mEffect);
}
@ -109,11 +109,11 @@ AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration,
return;
}
if (mTiming.mDuration == newDuration) {
if (mTiming.Duration() == newDuration) {
return;
}
mTiming.mDuration = newDuration;
mTiming.SetDuration(Move(newDuration));
PostSpecifiedTimingUpdated(mEffect);
}
@ -121,11 +121,11 @@ AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration,
void
AnimationEffectTiming::SetDirection(const PlaybackDirection& aDirection)
{
if (mTiming.mDirection == aDirection) {
if (mTiming.Direction() == aDirection) {
return;
}
mTiming.mDirection = aDirection;
mTiming.SetDirection(aDirection);
PostSpecifiedTimingUpdated(mEffect);
}
@ -139,11 +139,11 @@ AnimationEffectTiming::SetEasing(const nsAString& aEasing, ErrorResult& aRv)
return;
}
if (mTiming.mFunction == newFunction) {
if (mTiming.TimingFunction() == newFunction) {
return;
}
mTiming.mFunction = newFunction;
mTiming.SetTimingFunction(Move(newFunction));
PostSpecifiedTimingUpdated(mEffect);
}

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

@ -30,8 +30,8 @@ void
AnimationEffectTimingReadOnly::GetDuration(
OwningUnrestrictedDoubleOrString& aRetVal) const
{
if (mTiming.mDuration) {
aRetVal.SetAsUnrestrictedDouble() = mTiming.mDuration->ToMilliseconds();
if (mTiming.Duration()) {
aRetVal.SetAsUnrestrictedDouble() = mTiming.Duration()->ToMilliseconds();
} else {
aRetVal.SetAsString().AssignLiteral("auto");
}
@ -40,8 +40,8 @@ AnimationEffectTimingReadOnly::GetDuration(
void
AnimationEffectTimingReadOnly::GetEasing(nsString& aRetVal) const
{
if (mTiming.mFunction) {
mTiming.mFunction->AppendToString(aRetVal);
if (mTiming.TimingFunction()) {
mTiming.TimingFunction()->AppendToString(aRetVal);
} else {
aRetVal.AssignLiteral("linear");
}

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

@ -38,13 +38,13 @@ public:
nsISupports* GetParentObject() const { return mDocument; }
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
double Delay() const { return mTiming.mDelay.ToMilliseconds(); }
double EndDelay() const { return mTiming.mEndDelay.ToMilliseconds(); }
FillMode Fill() const { return mTiming.mFill; }
double IterationStart() const { return mTiming.mIterationStart; }
double Iterations() const { return mTiming.mIterations; }
double Delay() const { return mTiming.Delay().ToMilliseconds(); }
double EndDelay() const { return mTiming.EndDelay().ToMilliseconds(); }
FillMode Fill() const { return mTiming.Fill(); }
double IterationStart() const { return mTiming.IterationStart(); }
double Iterations() const { return mTiming.Iterations(); }
void GetDuration(OwningUnrestrictedDoubleOrString& aRetVal) const;
PlaybackDirection Direction() const { return mTiming.mDirection; }
PlaybackDirection Direction() const { return mTiming.Direction(); }
void GetEasing(nsString& aRetVal) const;
const TimingParams& AsTimingParams() const { return mTiming; }

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

@ -40,10 +40,10 @@ GetTimingProperties(
}
template <class OptionsType>
static TimingParams
TimingParamsFromOptionsUnion(const OptionsType& aOptions,
nsIDocument* aDocument,
ErrorResult& aRv)
/* static */ TimingParams
TimingParams::FromOptionsType(const OptionsType& aOptions,
nsIDocument* aDocument,
ErrorResult& aRv)
{
TimingParams result;
if (aOptions.IsUnrestrictedDouble()) {
@ -53,6 +53,7 @@ TimingParamsFromOptionsUnion(const OptionsType& aOptions,
StickyTimeDuration::FromMilliseconds(durationInMs));
} else {
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
return result;
}
} else {
const dom::AnimationEffectTimingProperties& timing =
@ -86,6 +87,8 @@ TimingParamsFromOptionsUnion(const OptionsType& aOptions,
result.mFill = timing.mFill;
result.mFunction = easing;
}
result.Update();
return result;
}
@ -95,7 +98,7 @@ TimingParams::FromOptionsUnion(
nsIDocument* aDocument,
ErrorResult& aRv)
{
return TimingParamsFromOptionsUnion(aOptions, aDocument, aRv);
return FromOptionsType(aOptions, aDocument, aRv);
}
/* static */ TimingParams
@ -104,7 +107,7 @@ TimingParams::FromOptionsUnion(
nsIDocument* aDocument,
ErrorResult& aRv)
{
return TimingParamsFromOptionsUnion(aOptions, aDocument, aRv);
return FromOptionsType(aOptions, aDocument, aRv);
}
/* static */ Maybe<ComputedTimingFunction>
@ -188,6 +191,8 @@ TimingParams::ParseEasing(const nsAString& aEasing,
bool
TimingParams::operator==(const TimingParams& aOther) const
{
// We don't compare mActiveDuration and mEndTime because they are calculated
// from other timing parameters.
return mDuration == aOther.mDuration &&
mDelay == aOther.mDelay &&
mIterations == aOther.mIterations &&

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

@ -35,6 +35,44 @@ struct TimingParams
{
TimingParams() = default;
TimingParams(float aDuration, float aDelay,
float aIterationCount,
dom::PlaybackDirection aDirection,
dom::FillMode aFillMode)
: mIterations(aIterationCount)
, mDirection(aDirection)
, mFill(aFillMode)
{
mDuration.emplace(StickyTimeDuration::FromMilliseconds(aDuration));
mDelay = TimeDuration::FromMilliseconds(aDelay);
Update();
}
TimingParams(const TimeDuration& aDuration,
const TimeDuration& aDelay,
const TimeDuration& aEndDelay,
float aIterations,
float aIterationStart,
dom::PlaybackDirection aDirection,
dom::FillMode aFillMode,
Maybe<ComputedTimingFunction>&& aFunction)
: mDelay(aDelay)
, mEndDelay(aEndDelay)
, mIterations(aIterations)
, mIterationStart(aIterationStart)
, mDirection(aDirection)
, mFill(aFillMode)
, mFunction(aFunction)
{
mDuration.emplace(aDuration);
Update();
}
template <class OptionsType>
static TimingParams FromOptionsType(
const OptionsType& aOptions,
nsIDocument* aDocument,
ErrorResult& aRv);
static TimingParams FromOptionsUnion(
const dom::UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
nsIDocument* aDocument, ErrorResult& aRv);
@ -87,6 +125,107 @@ struct TimingParams
nsIDocument* aDocument,
ErrorResult& aRv);
static StickyTimeDuration CalcActiveDuration(
const Maybe<StickyTimeDuration>& aDuration,
double aIterations)
{
// If either the iteration duration or iteration count is zero,
// Web Animations says that the active duration is zero. This is to
// ensure that the result is defined when the other argument is Infinity.
static const StickyTimeDuration zeroDuration;
if (!aDuration || *aDuration == zeroDuration || aIterations == 0.0) {
return zeroDuration;
}
return aDuration->MultDouble(aIterations);
}
// Return the duration of the active interval calculated by duration and
// iteration count.
StickyTimeDuration ActiveDuration() const
{
MOZ_ASSERT(CalcActiveDuration(mDuration, mIterations) == mActiveDuration,
"Cached value of active duration should be up to date");
return mActiveDuration;
}
StickyTimeDuration EndTime() const
{
MOZ_ASSERT(mEndTime == std::max(mDelay + ActiveDuration() + mEndDelay,
StickyTimeDuration()),
"Cached value of end time should be up to date");
return mEndTime;
}
bool operator==(const TimingParams& aOther) const;
bool operator!=(const TimingParams& aOther) const
{
return !(*this == aOther);
}
void SetDuration(Maybe<StickyTimeDuration>&& aDuration)
{
mDuration = Move(aDuration);
Update();
}
const Maybe<StickyTimeDuration>& Duration() const { return mDuration; }
void SetDelay(const TimeDuration& aDelay)
{
mDelay = aDelay;
Update();
}
const TimeDuration& Delay() const { return mDelay; }
void SetEndDelay(const TimeDuration& aEndDelay)
{
mEndDelay = aEndDelay;
Update();
}
const TimeDuration& EndDelay() const { return mEndDelay; }
void SetIterations(double aIterations)
{
mIterations = aIterations;
Update();
}
double Iterations() const { return mIterations; }
void SetIterationStart(double aIterationStart)
{
mIterationStart = aIterationStart;
}
double IterationStart() const { return mIterationStart; }
void SetDirection(dom::PlaybackDirection aDirection)
{
mDirection = aDirection;
}
dom::PlaybackDirection Direction() const { return mDirection; }
void SetFill(dom::FillMode aFill)
{
mFill = aFill;
}
dom::FillMode Fill() const { return mFill; }
void SetTimingFunction(Maybe<ComputedTimingFunction>&& aFunction)
{
mFunction = Move(aFunction);
}
const Maybe<ComputedTimingFunction>& TimingFunction() const
{
return mFunction;
}
private:
void Update()
{
mActiveDuration = CalcActiveDuration(mDuration, mIterations);
mEndTime = std::max(mDelay + mActiveDuration + mEndDelay,
StickyTimeDuration());
}
// mDuration.isNothing() represents the "auto" value
Maybe<StickyTimeDuration> mDuration;
TimeDuration mDelay; // Initializes to zero
@ -96,33 +235,8 @@ struct TimingParams
dom::PlaybackDirection mDirection = dom::PlaybackDirection::Normal;
dom::FillMode mFill = dom::FillMode::Auto;
Maybe<ComputedTimingFunction> mFunction;
// Return the duration of the active interval calculated by duration and
// iteration count.
StickyTimeDuration ActiveDuration() const
{
// If either the iteration duration or iteration count is zero,
// Web Animations says that the active duration is zero. This is to
// ensure that the result is defined when the other argument is Infinity.
static const StickyTimeDuration zeroDuration;
if (!mDuration || *mDuration == zeroDuration || mIterations == 0.0) {
return zeroDuration;
}
return mDuration->MultDouble(mIterations);
}
StickyTimeDuration EndTime() const
{
return std::max(mDelay + ActiveDuration() + mEndDelay,
StickyTimeDuration());
}
bool operator==(const TimingParams& aOther) const;
bool operator!=(const TimingParams& aOther) const
{
return !(*this == aOther);
}
StickyTimeDuration mActiveDuration = StickyTimeDuration();
StickyTimeDuration mEndTime = StickyTimeDuration();
};
} // namespace mozilla

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

@ -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);
});
});

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

@ -4342,6 +4342,14 @@ nsDOMWindowUtils::GetDirectionFromText(const nsAString& aString, int32_t* aRetva
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetIsStyledByServo(bool* aStyledByServo)
{
nsIDocument* doc = GetDocument();
*aStyledByServo = doc && doc->IsStyledByServo();
return NS_OK;
}
NS_INTERFACE_MAP_BEGIN(nsTranslationNodeList)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsITranslationNodeList)

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

@ -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);
}
});

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