Skip to content

Commit

Permalink
Merge mozilla-central to autoland. a=merge on a CLOSED TREE
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Maries committed Jul 4, 2019
2 parents 96da04d + daed363 commit 960e4c4
Show file tree
Hide file tree
Showing 206 changed files with 4,433 additions and 3,706 deletions.
8 changes: 2 additions & 6 deletions browser/base/content/test/general/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,11 @@ function setTestPluginEnabledState(newEnabledState, pluginName) {
}

function pushPrefs(...aPrefs) {
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
});
return SpecialPowers.pushPrefEnv({"set": aPrefs});
}

function popPrefs() {
return new Promise(resolve => {
SpecialPowers.popPrefEnv(resolve);
});
return SpecialPowers.popPrefEnv();
}

function updateBlocklist(aCallback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ const kDumpAllStacks = false;
const whitelist = {
modules: new Set([
"chrome://mochikit/content/ShutdownLeaksCollector.jsm",
"resource://specialpowers/specialpowers.js",
"resource://specialpowers/specialpowersAPI.js",
"resource://specialpowers/SpecialPowersChild.jsm",
"resource://specialpowers/SpecialPowersAPI.jsm",
"resource://specialpowers/WrapPrivileged.jsm",

"resource://gre/modules/ContentProcessSingleton.jsm",

Expand Down Expand Up @@ -64,8 +65,6 @@ const whitelist = {
]),
frameScripts: new Set([
// Test related
"resource://specialpowers/MozillaLogger.js",
"resource://specialpowers/specialpowersFrameScript.js",
"chrome://mochikit/content/shutdown-leaks-collector.js",
"chrome://mochikit/content/tests/SimpleTest/AsyncUtilsContent.js",
"chrome://mochikit/content/tests/BrowserTestUtils/content-utils.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@
const permission = "geolocation";
const promiseGranted = this.promiseStateChanged(permission, "granted");
this.setPermissions(ALLOW_ACTION);
promiseGranted.then(() => {
promiseGranted.then(async () => {
const promisePrompt = this.promiseStateChanged(permission, "prompt");
SpecialPowers.popPermissions();
await SpecialPowers.popPermissions();
return promisePrompt;
}).then(resolve);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,54 +174,47 @@ function checkMenuEntries(expectedValues, isFormAutofillResult = true) {
}
}

function invokeAsyncChromeTask(message, response, payload = {}) {
function invokeAsyncChromeTask(message, payload = {}) {
info(`expecting the chrome task finished: ${message}`);
return new Promise(resolve => {
formFillChromeScript.sendAsyncMessage(message, payload);
formFillChromeScript.addMessageListener(response, function onReceived(data) {
formFillChromeScript.removeMessageListener(response, onReceived);

resolve(data);
});
});
return formFillChromeScript.sendQuery(message, payload);
}

async function addAddress(address) {
await invokeAsyncChromeTask("FormAutofillTest:AddAddress", "FormAutofillTest:AddressAdded", {address});
await invokeAsyncChromeTask("FormAutofillTest:AddAddress", {address});
await sleep();
}

async function removeAddress(guid) {
return invokeAsyncChromeTask("FormAutofillTest:RemoveAddress", "FormAutofillTest:AddressRemoved", {guid});
return invokeAsyncChromeTask("FormAutofillTest:RemoveAddress", {guid});
}

async function updateAddress(guid, address) {
return invokeAsyncChromeTask("FormAutofillTest:UpdateAddress", "FormAutofillTest:AddressUpdated", {address, guid});
return invokeAsyncChromeTask("FormAutofillTest:UpdateAddress", {address, guid});
}

async function checkAddresses(expectedAddresses) {
return invokeAsyncChromeTask("FormAutofillTest:CheckAddresses", "FormAutofillTest:areAddressesMatching", {expectedAddresses});
return invokeAsyncChromeTask("FormAutofillTest:CheckAddresses", {expectedAddresses});
}

async function cleanUpAddresses() {
return invokeAsyncChromeTask("FormAutofillTest:CleanUpAddresses", "FormAutofillTest:AddressesCleanedUp");
return invokeAsyncChromeTask("FormAutofillTest:CleanUpAddresses");
}

async function addCreditCard(creditcard) {
await invokeAsyncChromeTask("FormAutofillTest:AddCreditCard", "FormAutofillTest:CreditCardAdded", {creditcard});
await invokeAsyncChromeTask("FormAutofillTest:AddCreditCard", {creditcard});
await sleep();
}

async function removeCreditCard(guid) {
return invokeAsyncChromeTask("FormAutofillTest:RemoveCreditCard", "FormAutofillTest:CreditCardRemoved", {guid});
return invokeAsyncChromeTask("FormAutofillTest:RemoveCreditCard", {guid});
}

async function checkCreditCards(expectedCreditCards) {
return invokeAsyncChromeTask("FormAutofillTest:CheckCreditCards", "FormAutofillTest:areCreditCardsMatching", {expectedCreditCards});
return invokeAsyncChromeTask("FormAutofillTest:CheckCreditCards", {expectedCreditCards});
}

async function cleanUpCreditCards() {
return invokeAsyncChromeTask("FormAutofillTest:CleanUpCreditCards", "FormAutofillTest:CreditCardsCleanedUp");
return invokeAsyncChromeTask("FormAutofillTest:CleanUpCreditCards");
}

async function cleanUpStorage() {
Expand All @@ -230,12 +223,12 @@ async function cleanUpStorage() {
}

async function canTestOSKeyStoreLogin() {
let {canTest} = await invokeAsyncChromeTask("FormAutofillTest:CanTestOSKeyStoreLogin", "FormAutofillTest:CanTestOSKeyStoreLoginResult");
let {canTest} = await invokeAsyncChromeTask("FormAutofillTest:CanTestOSKeyStoreLogin");
return canTest;
}

async function waitForOSKeyStoreLogin(login = false) {
await invokeAsyncChromeTask("FormAutofillTest:OSKeyStoreLogin", "FormAutofillTest:OSKeyStoreLoggedIn", {login});
await invokeAsyncChromeTask("FormAutofillTest:OSKeyStoreLogin", {login});
}

function patchRecordCCNumber(record) {
Expand Down Expand Up @@ -302,15 +295,13 @@ function formAutoFillCommonSetup() {
});

add_task(async function setup() {
formFillChromeScript.sendAsyncMessage("setup");
info(`expecting the storage setup`);
await formFillChromeScript.promiseOneMessage("setup-finished");
await formFillChromeScript.sendQuery("setup");
});

SimpleTest.registerCleanupFunction(async () => {
formFillChromeScript.sendAsyncMessage("cleanup");
info(`expecting the storage cleanup`);
await formFillChromeScript.promiseOneMessage("cleanup-finished");
await formFillChromeScript.sendQuery("cleanup");

formFillChromeScript.destroy();
expectingPopup = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ let {formAutofillStorage} = ChromeUtils.import("resource://formautofill/FormAuto

const {ADDRESSES_COLLECTION_NAME, CREDITCARDS_COLLECTION_NAME} = FormAutofillUtils;

let destroyed = false;

var ParentUtils = {
async _getRecords(collectionName) {
return new Promise(resolve => {
Expand All @@ -34,20 +36,24 @@ var ParentUtils = {
}

// every notification type should have the collection name.
let allowedNames = [ADDRESSES_COLLECTION_NAME, CREDITCARDS_COLLECTION_NAME];
assert.ok(allowedNames.includes(subject.wrappedJSObject.collectionName),
"should include the collection name");
// every notification except removeAll should have a guid.
if (data != "removeAll") {
assert.ok(subject.wrappedJSObject.guid, "should have a guid");
// We're not allowed to trigger assertions during mochitest
// cleanup functions.
if (!destroyed) {
let allowedNames = [ADDRESSES_COLLECTION_NAME, CREDITCARDS_COLLECTION_NAME];
assert.ok(allowedNames.includes(subject.wrappedJSObject.collectionName),
"should include the collection name");
// every notification except removeAll should have a guid.
if (data != "removeAll") {
assert.ok(subject.wrappedJSObject.guid, "should have a guid");
}
}
Services.obs.removeObserver(observer, obsTopic);
resolve();
}, topic);
});
},

async _operateRecord(collectionName, type, msgData, contentMsg) {
async _operateRecord(collectionName, type, msgData) {
let times, topic;

if (collectionName == ADDRESSES_COLLECTION_NAME) {
Expand Down Expand Up @@ -83,22 +89,20 @@ var ParentUtils = {
}

await this._storageChangeObserved({type, times, topic});
sendAsyncMessage(contentMsg);
},

async operateAddress(type, msgData, contentMsg) {
async operateAddress(type, msgData) {
await this._operateRecord(ADDRESSES_COLLECTION_NAME, ...arguments);
},

async operateCreditCard(type, msgData, contentMsg) {
async operateCreditCard(type, msgData) {
await this._operateRecord(CREDITCARDS_COLLECTION_NAME, ...arguments);
},

async cleanUpAddresses() {
const guids = (await this._getRecords(ADDRESSES_COLLECTION_NAME)).map(record => record.guid);

if (guids.length == 0) {
sendAsyncMessage("FormAutofillTest:AddressesCleanedUp");
return;
}

Expand All @@ -112,7 +116,6 @@ var ParentUtils = {
const guids = (await this._getRecords(CREDITCARDS_COLLECTION_NAME)).map(record => record.guid);

if (guids.length == 0) {
sendAsyncMessage("FormAutofillTest:CreditCardsCleanedUp");
return;
}

Expand Down Expand Up @@ -167,82 +170,76 @@ var ParentUtils = {
},

async checkAddresses({expectedAddresses}) {
const areMatched = await this._checkRecords(ADDRESSES_COLLECTION_NAME, expectedAddresses);

sendAsyncMessage("FormAutofillTest:areAddressesMatching", areMatched);
return this._checkRecords(ADDRESSES_COLLECTION_NAME, expectedAddresses);
},

async checkCreditCards({expectedCreditCards}) {
const areMatched = await this._checkRecords(CREDITCARDS_COLLECTION_NAME, expectedCreditCards);

sendAsyncMessage("FormAutofillTest:areCreditCardsMatching", areMatched);
return this._checkRecords(CREDITCARDS_COLLECTION_NAME, expectedCreditCards);
},

observe(subject, topic, data) {
assert.ok(topic === "formautofill-storage-changed");
if (!destroyed) {
assert.ok(topic === "formautofill-storage-changed");
}
sendAsyncMessage("formautofill-storage-changed", {subject: null, topic, data});
},
};

Services.obs.addObserver(ParentUtils, "formautofill-storage-changed");

Services.mm.addMessageListener("FormAutofill:FieldsIdentified", () => {
sendAsyncMessage("FormAutofillTest:FieldsIdentified");
return null;
});

addMessageListener("FormAutofillTest:AddAddress", (msg) => {
ParentUtils.operateAddress("add", msg, "FormAutofillTest:AddressAdded");
return ParentUtils.operateAddress("add", msg);
});

addMessageListener("FormAutofillTest:RemoveAddress", (msg) => {
ParentUtils.operateAddress("remove", msg, "FormAutofillTest:AddressRemoved");
return ParentUtils.operateAddress("remove", msg);
});

addMessageListener("FormAutofillTest:UpdateAddress", (msg) => {
ParentUtils.operateAddress("update", msg, "FormAutofillTest:AddressUpdated");
return ParentUtils.operateAddress("update", msg);
});

addMessageListener("FormAutofillTest:CheckAddresses", (msg) => {
ParentUtils.checkAddresses(msg);
return ParentUtils.checkAddresses(msg);
});

addMessageListener("FormAutofillTest:CleanUpAddresses", (msg) => {
ParentUtils.cleanUpAddresses();
return ParentUtils.cleanUpAddresses();
});

addMessageListener("FormAutofillTest:AddCreditCard", (msg) => {
ParentUtils.operateCreditCard("add", msg, "FormAutofillTest:CreditCardAdded");
return ParentUtils.operateCreditCard("add", msg);
});

addMessageListener("FormAutofillTest:RemoveCreditCard", (msg) => {
ParentUtils.operateCreditCard("remove", msg, "FormAutofillTest:CreditCardRemoved");
return ParentUtils.operateCreditCard("remove", msg);
});

addMessageListener("FormAutofillTest:CheckCreditCards", (msg) => {
ParentUtils.checkCreditCards(msg);
return ParentUtils.checkCreditCards(msg);
});

addMessageListener("FormAutofillTest:CleanUpCreditCards", (msg) => {
ParentUtils.cleanUpCreditCards();
return ParentUtils.cleanUpCreditCards();
});

addMessageListener("FormAutofillTest:CanTestOSKeyStoreLogin", (msg) => {
sendAsyncMessage("FormAutofillTest:CanTestOSKeyStoreLoginResult",
{canTest: OSKeyStoreTestUtils.canTestOSKeyStoreLogin()});
return {canTest: OSKeyStoreTestUtils.canTestOSKeyStoreLogin()};
});

addMessageListener("FormAutofillTest:OSKeyStoreLogin", async (msg) => {
await OSKeyStoreTestUtils.waitForOSKeyStoreLogin(msg.login);
sendAsyncMessage("FormAutofillTest:OSKeyStoreLoggedIn");
});

addMessageListener("setup", async () => {
ParentUtils.setup();
sendAsyncMessage("setup-finished", {});
});

addMessageListener("cleanup", async () => {
destroyed = true;
await ParentUtils.cleanup();

sendAsyncMessage("cleanup-finished", {});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
chromeScript.destroy();
});

let result = chromeScript.sendSyncMessage("CheckSubKeys");
ok(result[0][0], "Check that there are no sub_keys for the test country");
let result = await chromeScript.sendQuery("CheckSubKeys");
ok(result, "Check that there are no sub_keys for the test country");
});

add_task(async function test_form_will_submit_without_sub_keys() {
Expand Down
1 change: 0 additions & 1 deletion chrome/nsChromeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "nsQueryObject.h"

#include "mozilla/dom/URL.h"
#include "nsDOMWindowList.h"
#include "nsIConsoleService.h"
#include "mozilla/dom/Document.h"
#include "nsIDOMWindow.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ add_task(async function testActiveTabOnNonExistingSidebar() {
// to simulate the scenario where an extension has installed a sidebar
// which has been saved in the preference but it doesn't exist anymore.
await SpecialPowers.pushPrefEnv({
set: [["devtools.inspector.activeSidebar"], "unexisting-sidebar-id"],
set: [["devtools.inspector.activeSidebar", "unexisting-sidebar-id"]],
});

const res = await openInspectorForURL("about:blank");
Expand Down
2 changes: 1 addition & 1 deletion devtools/client/inspector/markup/views/element-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const HTML_VOID_ELEMENTS = [
// element markup and their respective title tooltip text.
const DISPLAY_TYPES = {
"flex": INSPECTOR_L10N.getStr("markupView.display.flex.tooltiptext"),
"inline-flex": INSPECTOR_L10N.getStr("markupView.display.flex.tooltiptext"),
"inline-flex": INSPECTOR_L10N.getStr("markupView.display.inlineFlex.tooltiptext"),
"grid": INSPECTOR_L10N.getStr("markupView.display.grid.tooltiptext"),
"inline-grid": INSPECTOR_L10N.getStr("markupView.display.inlineGrid.tooltiptext"),
"subgrid": INSPECTOR_L10N.getStr("markupView.display.subgrid.tooltiptiptext"),
Expand Down
8 changes: 4 additions & 4 deletions devtools/client/shared/test/shared-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ var closeTabAndToolbox = async function(tab = gBrowser.selectedTab) {
}

await removeTab(tab);

await new Promise(resolve => setTimeout(resolve, 0));
};

/**
Expand Down Expand Up @@ -596,10 +598,8 @@ function waitForClipboardPromise(setup, expected) {
* @return {Promise} resolves when the preferences have been updated
*/
function pushPref(preferenceName, value) {
return new Promise(resolve => {
const options = {"set": [[preferenceName, value]]};
SpecialPowers.pushPrefEnv(options, resolve);
});
const options = {"set": [[preferenceName, value]]};
return SpecialPowers.pushPrefEnv(options);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

// This test needs to add tabs that are controlled by a service worker
// so use some special powers to dig around and find gBrowser
let {gBrowser} = SpecialPowers._getTopChromeWindow(SpecialPowers.window.get());
let {gBrowser} = SpecialPowers._getTopChromeWindow(SpecialPowers.window);

SimpleTest.registerCleanupFunction(() => {
while (gBrowser.tabs.length > 1) {
Expand Down
Loading

0 comments on commit 960e4c4

Please sign in to comment.