Backed out 34 changesets (bug 1561150, bug 1541557, bug 1561724, bug 1561999, bug 1558298, bug 1561061, bug 1532795, bug 1560400, bug 1561122) for beta simulation failures (bug 1563905, bug 1564001). a=backout

Backed out changeset 210d6d52e8b0 (bug 1541557)
Backed out changeset 3115db154c45 (bug 1561122)
Backed out changeset b42748878b6e (bug 1561122)
Backed out changeset 266160ca8e9d (bug 1561999)
Backed out changeset 00e935828f41 (bug 1561724)
Backed out changeset 4aaf4882780d (bug 1561150)
Backed out changeset 6644e38a6692 (bug 1561150)
Backed out changeset 72cd895b1613 (bug 1561061)
Backed out changeset f0bac27bad8a (bug 1560400)
Backed out changeset 95da39224eab (bug 1560400)
Backed out changeset 3fe4d4942fd2 (bug 1532795)
Backed out changeset 23e90c6fec2b (bug 1532795)
Backed out changeset a7f093fbef06 (bug 1532795)
Backed out changeset c873f0eb94be (bug 1532795)
Backed out changeset cf359a8ec753 (bug 1532795)
Backed out changeset f2c260cae4b5 (bug 1541557)
Backed out changeset 054a0b7aa81d (bug 1541557)
Backed out changeset f808ec45ff9c (bug 1541557)
Backed out changeset 1025eeef0954 (bug 1541557)
Backed out changeset fe88b250e418 (bug 1541557)
Backed out changeset 6680278c231b (bug 1541557)
Backed out changeset 255735c1ff63 (bug 1541557)
Backed out changeset 51969e1c9c44 (bug 1558298)
Backed out changeset d12525990565 (bug 1558298)
Backed out changeset ef4ec8f0f886 (bug 1558298)
Backed out changeset 45a9599d9641 (bug 1558298)
Backed out changeset 4ccecdba1c34 (bug 1558298)
Backed out changeset 0e91fc9541c2 (bug 1558298)
Backed out changeset edd1cc6badf7 (bug 1558298)
Backed out changeset ba24251835fb (bug 1558298)
Backed out changeset ca88016511bb (bug 1558298)
Backed out changeset c95e6e599836 (bug 1558298)
Backed out changeset 9b1a9d802434 (bug 1558298)
Backed out changeset f859e4de0007 (bug 1558298)

--HG--
rename : testing/mochitest/tests/SimpleTest/MozillaLogger.js => testing/specialpowers/content/MozillaLogger.js
rename : testing/specialpowers/content/SpecialPowersParent.jsm => testing/specialpowers/content/SpecialPowersObserver.jsm
rename : testing/specialpowers/content/SpecialPowersAPIParent.jsm => testing/specialpowers/content/SpecialPowersObserverAPI.js
rename : testing/specialpowers/content/SpecialPowersChild.jsm => testing/specialpowers/content/specialpowers.js
rename : testing/specialpowers/content/SpecialPowersAPI.jsm => testing/specialpowers/content/specialpowersAPI.js
extra : rebase_source : 223d2e49710b016c9973765d402c61692004518e
extra : amend_source : ec773fe82334e6da536bb21e83a994a5f2d03091
This commit is contained in:
Sebastian Hengst 2019-07-08 10:37:28 +02:00
Родитель 40b709bc47
Коммит 515d14403f
180 изменённых файлов: 3689 добавлений и 3367 удалений

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

@ -191,11 +191,15 @@ function setTestPluginEnabledState(newEnabledState, pluginName) {
}
function pushPrefs(...aPrefs) {
return SpecialPowers.pushPrefEnv({ set: aPrefs });
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({ set: aPrefs }, resolve);
});
}
function popPrefs() {
return SpecialPowers.popPrefEnv();
return new Promise(resolve => {
SpecialPowers.popPrefEnv(resolve);
});
}
function updateBlocklist(aCallback) {

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

@ -20,9 +20,8 @@ const kDumpAllStacks = false;
const whitelist = {
modules: new Set([
"chrome://mochikit/content/ShutdownLeaksCollector.jsm",
"resource://specialpowers/SpecialPowersChild.jsm",
"resource://specialpowers/SpecialPowersAPI.jsm",
"resource://specialpowers/WrapPrivileged.jsm",
"resource://specialpowers/specialpowers.js",
"resource://specialpowers/specialpowersAPI.js",
"resource://gre/modules/ContentProcessSingleton.jsm",
@ -65,6 +64,8 @@ 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",

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

@ -129,9 +129,9 @@
const permission = "geolocation";
const promiseGranted = this.promiseStateChanged(permission, "granted");
this.setPermissions(ALLOW_ACTION);
promiseGranted.then(async () => {
promiseGranted.then(() => {
const promisePrompt = this.promiseStateChanged(permission, "prompt");
await SpecialPowers.popPermissions();
SpecialPowers.popPermissions();
return promisePrompt;
}).then(resolve);
});

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

@ -224,54 +224,90 @@ function checkMenuEntries(expectedValues, isFormAutofillResult = true) {
}
}
function invokeAsyncChromeTask(message, payload = {}) {
function invokeAsyncChromeTask(message, response, payload = {}) {
info(`expecting the chrome task finished: ${message}`);
return formFillChromeScript.sendQuery(message, payload);
return new Promise(resolve => {
formFillChromeScript.sendAsyncMessage(message, payload);
formFillChromeScript.addMessageListener(response, function onReceived(
data
) {
formFillChromeScript.removeMessageListener(response, onReceived);
resolve(data);
});
});
}
async function addAddress(address) {
await invokeAsyncChromeTask("FormAutofillTest:AddAddress", { address });
await invokeAsyncChromeTask(
"FormAutofillTest:AddAddress",
"FormAutofillTest:AddressAdded",
{ address }
);
await sleep();
}
async function removeAddress(guid) {
return invokeAsyncChromeTask("FormAutofillTest:RemoveAddress", { guid });
return invokeAsyncChromeTask(
"FormAutofillTest:RemoveAddress",
"FormAutofillTest:AddressRemoved",
{ guid }
);
}
async function updateAddress(guid, address) {
return invokeAsyncChromeTask("FormAutofillTest:UpdateAddress", {
address,
guid,
});
return invokeAsyncChromeTask(
"FormAutofillTest:UpdateAddress",
"FormAutofillTest:AddressUpdated",
{ address, guid }
);
}
async function checkAddresses(expectedAddresses) {
return invokeAsyncChromeTask("FormAutofillTest:CheckAddresses", {
expectedAddresses,
});
return invokeAsyncChromeTask(
"FormAutofillTest:CheckAddresses",
"FormAutofillTest:areAddressesMatching",
{ expectedAddresses }
);
}
async function cleanUpAddresses() {
return invokeAsyncChromeTask("FormAutofillTest:CleanUpAddresses");
return invokeAsyncChromeTask(
"FormAutofillTest:CleanUpAddresses",
"FormAutofillTest:AddressesCleanedUp"
);
}
async function addCreditCard(creditcard) {
await invokeAsyncChromeTask("FormAutofillTest:AddCreditCard", { creditcard });
await invokeAsyncChromeTask(
"FormAutofillTest:AddCreditCard",
"FormAutofillTest:CreditCardAdded",
{ creditcard }
);
await sleep();
}
async function removeCreditCard(guid) {
return invokeAsyncChromeTask("FormAutofillTest:RemoveCreditCard", { guid });
return invokeAsyncChromeTask(
"FormAutofillTest:RemoveCreditCard",
"FormAutofillTest:CreditCardRemoved",
{ guid }
);
}
async function checkCreditCards(expectedCreditCards) {
return invokeAsyncChromeTask("FormAutofillTest:CheckCreditCards", {
expectedCreditCards,
});
return invokeAsyncChromeTask(
"FormAutofillTest:CheckCreditCards",
"FormAutofillTest:areCreditCardsMatching",
{ expectedCreditCards }
);
}
async function cleanUpCreditCards() {
return invokeAsyncChromeTask("FormAutofillTest:CleanUpCreditCards");
return invokeAsyncChromeTask(
"FormAutofillTest:CleanUpCreditCards",
"FormAutofillTest:CreditCardsCleanedUp"
);
}
async function cleanUpStorage() {
@ -281,13 +317,18 @@ async function cleanUpStorage() {
async function canTestOSKeyStoreLogin() {
let { canTest } = await invokeAsyncChromeTask(
"FormAutofillTest:CanTestOSKeyStoreLogin"
"FormAutofillTest:CanTestOSKeyStoreLogin",
"FormAutofillTest:CanTestOSKeyStoreLoginResult"
);
return canTest;
}
async function waitForOSKeyStoreLogin(login = false) {
await invokeAsyncChromeTask("FormAutofillTest:OSKeyStoreLogin", { login });
await invokeAsyncChromeTask(
"FormAutofillTest:OSKeyStoreLogin",
"FormAutofillTest:OSKeyStoreLoggedIn",
{ login }
);
}
function patchRecordCCNumber(record) {
@ -356,13 +397,15 @@ function formAutoFillCommonSetup() {
});
add_task(async function setup() {
formFillChromeScript.sendAsyncMessage("setup");
info(`expecting the storage setup`);
await formFillChromeScript.sendQuery("setup");
await formFillChromeScript.promiseOneMessage("setup-finished");
});
SimpleTest.registerCleanupFunction(async () => {
formFillChromeScript.sendAsyncMessage("cleanup");
info(`expecting the storage cleanup`);
await formFillChromeScript.sendQuery("cleanup");
await formFillChromeScript.promiseOneMessage("cleanup-finished");
formFillChromeScript.destroy();
expectingPopup = null;

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

@ -24,8 +24,6 @@ const {
CREDITCARDS_COLLECTION_NAME,
} = FormAutofillUtils;
let destroyed = false;
var ParentUtils = {
async _getRecords(collectionName) {
return new Promise(resolve => {
@ -60,9 +58,6 @@ var ParentUtils = {
}
// every notification type should have the collection name.
// We're not allowed to trigger assertions during mochitest
// cleanup functions.
if (!destroyed) {
let allowedNames = [
ADDRESSES_COLLECTION_NAME,
CREDITCARDS_COLLECTION_NAME,
@ -75,14 +70,13 @@ var ParentUtils = {
if (data != "removeAll") {
assert.ok(subject.wrappedJSObject.guid, "should have a guid");
}
}
Services.obs.removeObserver(observer, obsTopic);
resolve();
}, topic);
});
},
async _operateRecord(collectionName, type, msgData) {
async _operateRecord(collectionName, type, msgData, contentMsg) {
let times, topic;
if (collectionName == ADDRESSES_COLLECTION_NAME) {
@ -127,13 +121,14 @@ var ParentUtils = {
}
await this._storageChangeObserved({ type, times, topic });
sendAsyncMessage(contentMsg);
},
async operateAddress(type, msgData) {
async operateAddress(type, msgData, contentMsg) {
await this._operateRecord(ADDRESSES_COLLECTION_NAME, ...arguments);
},
async operateCreditCard(type, msgData) {
async operateCreditCard(type, msgData, contentMsg) {
await this._operateRecord(CREDITCARDS_COLLECTION_NAME, ...arguments);
},
@ -143,6 +138,7 @@ var ParentUtils = {
);
if (guids.length == 0) {
sendAsyncMessage("FormAutofillTest:AddressesCleanedUp");
return;
}
@ -162,6 +158,7 @@ var ParentUtils = {
);
if (guids.length == 0) {
sendAsyncMessage("FormAutofillTest:CreditCardsCleanedUp");
return;
}
@ -228,17 +225,25 @@ var ParentUtils = {
},
async checkAddresses({ expectedAddresses }) {
return this._checkRecords(ADDRESSES_COLLECTION_NAME, expectedAddresses);
const areMatched = await this._checkRecords(
ADDRESSES_COLLECTION_NAME,
expectedAddresses
);
sendAsyncMessage("FormAutofillTest:areAddressesMatching", areMatched);
},
async checkCreditCards({ expectedCreditCards }) {
return this._checkRecords(CREDITCARDS_COLLECTION_NAME, expectedCreditCards);
const areMatched = await this._checkRecords(
CREDITCARDS_COLLECTION_NAME,
expectedCreditCards
);
sendAsyncMessage("FormAutofillTest:areCreditCardsMatching", areMatched);
},
observe(subject, topic, data) {
if (!destroyed) {
assert.ok(topic === "formautofill-storage-changed");
}
sendAsyncMessage("formautofill-storage-changed", {
subject: null,
topic,
@ -250,58 +255,67 @@ var ParentUtils = {
Services.obs.addObserver(ParentUtils, "formautofill-storage-changed");
Services.mm.addMessageListener("FormAutofill:FieldsIdentified", () => {
return null;
sendAsyncMessage("FormAutofillTest:FieldsIdentified");
});
addMessageListener("FormAutofillTest:AddAddress", msg => {
return ParentUtils.operateAddress("add", msg);
ParentUtils.operateAddress("add", msg, "FormAutofillTest:AddressAdded");
});
addMessageListener("FormAutofillTest:RemoveAddress", msg => {
return ParentUtils.operateAddress("remove", msg);
ParentUtils.operateAddress("remove", msg, "FormAutofillTest:AddressRemoved");
});
addMessageListener("FormAutofillTest:UpdateAddress", msg => {
return ParentUtils.operateAddress("update", msg);
ParentUtils.operateAddress("update", msg, "FormAutofillTest:AddressUpdated");
});
addMessageListener("FormAutofillTest:CheckAddresses", msg => {
return ParentUtils.checkAddresses(msg);
ParentUtils.checkAddresses(msg);
});
addMessageListener("FormAutofillTest:CleanUpAddresses", msg => {
return ParentUtils.cleanUpAddresses();
ParentUtils.cleanUpAddresses();
});
addMessageListener("FormAutofillTest:AddCreditCard", msg => {
return ParentUtils.operateCreditCard("add", msg);
ParentUtils.operateCreditCard("add", msg, "FormAutofillTest:CreditCardAdded");
});
addMessageListener("FormAutofillTest:RemoveCreditCard", msg => {
return ParentUtils.operateCreditCard("remove", msg);
ParentUtils.operateCreditCard(
"remove",
msg,
"FormAutofillTest:CreditCardRemoved"
);
});
addMessageListener("FormAutofillTest:CheckCreditCards", msg => {
return ParentUtils.checkCreditCards(msg);
ParentUtils.checkCreditCards(msg);
});
addMessageListener("FormAutofillTest:CleanUpCreditCards", msg => {
return ParentUtils.cleanUpCreditCards();
ParentUtils.cleanUpCreditCards();
});
addMessageListener("FormAutofillTest:CanTestOSKeyStoreLogin", msg => {
return { canTest: OSKeyStoreTestUtils.canTestOSKeyStoreLogin() };
sendAsyncMessage("FormAutofillTest:CanTestOSKeyStoreLoginResult", {
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", {});
});

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

@ -44,8 +44,8 @@ add_task(async function test_DE_is_valid_testcase() {
chromeScript.destroy();
});
let result = await chromeScript.sendQuery("CheckSubKeys");
ok(result, "Check that there are no sub_keys for the test country");
let result = chromeScript.sendSyncMessage("CheckSubKeys");
ok(result[0][0], "Check that there are no sub_keys for the test country");
});
add_task(async function test_form_will_submit_without_sub_keys() {

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

@ -16,6 +16,7 @@
#include "nsQueryObject.h"
#include "mozilla/dom/URL.h"
#include "nsDOMWindowList.h"
#include "nsIConsoleService.h"
#include "mozilla/dom/Document.h"
#include "nsIDOMWindow.h"

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

@ -331,7 +331,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");

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

@ -483,8 +483,6 @@ var closeTabAndToolbox = async function(tab = gBrowser.selectedTab) {
}
await removeTab(tab);
await new Promise(resolve => setTimeout(resolve, 0));
};
/**
@ -631,8 +629,10 @@ 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]] };
return SpecialPowers.pushPrefEnv(options);
SpecialPowers.pushPrefEnv(options, resolve);
});
}
/**

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

@ -92,7 +92,7 @@ addEventListener("load", startTest);
// 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);
let {gBrowser} = SpecialPowers._getTopChromeWindow(SpecialPowers.window.get());
SimpleTest.registerCleanupFunction(() => {
while (gBrowser.tabs.length > 1) {

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

@ -16,7 +16,6 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Location.h"
#include "mozilla/dom/LocationBinding.h"
#include "mozilla/dom/StructuredCloneTags.h"
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/dom/WindowGlobalParent.h"
@ -91,12 +90,6 @@ already_AddRefed<BrowsingContext> BrowsingContext::Get(uint64_t aId) {
return do_AddRef(sBrowsingContexts->Get(aId));
}
/* static */
already_AddRefed<BrowsingContext> BrowsingContext::GetFromWindow(
WindowProxyHolder& aProxy) {
return do_AddRef(aProxy.get());
}
CanonicalBrowsingContext* BrowsingContext::Canonical() {
return CanonicalBrowsingContext::Cast(this);
}
@ -558,45 +551,6 @@ JSObject* BrowsingContext::WrapObject(JSContext* aCx,
return BrowsingContext_Binding::Wrap(aCx, this, aGivenProto);
}
bool BrowsingContext::WriteStructuredClone(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
StructuredCloneHolder* aHolder) {
return (JS_WriteUint32Pair(aWriter, SCTAG_DOM_BROWSING_CONTEXT, 0) &&
JS_WriteUint32Pair(aWriter, uint32_t(Id()), uint32_t(Id() >> 32)));
}
/* static */
JSObject* BrowsingContext::ReadStructuredClone(JSContext* aCx,
JSStructuredCloneReader* aReader,
StructuredCloneHolder* aHolder) {
uint32_t idLow = 0;
uint32_t idHigh = 0;
if (!JS_ReadUint32Pair(aReader, &idLow, &idHigh)) {
return nullptr;
}
uint64_t id = uint64_t(idHigh) << 32 | idLow;
// Note: Do this check after reading our ID data. Returning null will abort
// the decode operation anyway, but we should at least be as safe as possible.
if (NS_WARN_IF(!NS_IsMainThread())) {
MOZ_DIAGNOSTIC_ASSERT(false,
"We shouldn't be trying to decode a BrowsingContext "
"on a background thread.");
return nullptr;
}
JS::RootedValue val(aCx, JS::NullValue());
// We'll get rooting hazard errors from the RefPtr destructor if it isn't
// destroyed before we try to return a raw JSObject*, so create it in its own
// scope.
if (RefPtr<BrowsingContext> context = Get(id)) {
if (!GetOrCreateDOMReflector(aCx, context, &val) || !val.isObject()) {
return nullptr;
}
}
return val.toObjectOrNull();
}
void BrowsingContext::NotifyUserGestureActivation() {
// We would set the user gesture activation flag on the top level browsing
// context, which would automatically be sync to other top level browsing

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

@ -51,7 +51,6 @@ template <typename>
struct Nullable;
template <typename T>
class Sequence;
class StructuredCloneHolder;
struct WindowPostMessageOptions;
class WindowProxyHolder;
@ -105,13 +104,6 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase {
return Get(aId);
}
static already_AddRefed<BrowsingContext> GetFromWindow(
WindowProxyHolder& aProxy);
static already_AddRefed<BrowsingContext> GetFromWindow(
GlobalObject&, WindowProxyHolder& aProxy) {
return GetFromWindow(aProxy);
}
// Create a brand-new BrowsingContext object.
static already_AddRefed<BrowsingContext> Create(BrowsingContext* aParent,
BrowsingContext* aOpener,
@ -274,12 +266,6 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase {
JSObject* WrapObject(JSContext* aCx);
static JSObject* ReadStructuredClone(JSContext* aCx,
JSStructuredCloneReader* aReader,
StructuredCloneHolder* aHolder);
bool WriteStructuredClone(JSContext* aCx, JSStructuredCloneWriter* aWriter,
StructuredCloneHolder* aHolder);
void StartDelayedAutoplayMediaComponents();
/**

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

@ -8,13 +8,15 @@
onload="setTimeout(nextTest, 0);"
title="bug 293235 test">
<script src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
<script type="application/javascript" src="docshell_helpers.js" />
<script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
<script type="application/javascript"><![CDATA[
var {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
// Define the generator-iterator for the tests.
var tests = testIterator();

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

@ -8,6 +8,8 @@
onload="setTimeout(nextTest, 0);"
title="bug 396649 test">
<script src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
<script type="application/javascript" src="docshell_helpers.js" />

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

@ -9,7 +9,8 @@
title="bug 89419 test">
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
<script src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/specialpowers.js"/>
<script type="application/javascript" src="docshell_helpers.js" />
<script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>

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

@ -44,20 +44,18 @@ function checkLoadFrame1() {
myFrame1.src = CROSS_ORIGIN_URI;
}
async function checkNavFrame1() {
function checkNavFrame1() {
myFrame1.removeEventListener("load", checkNavFrame1);
is(await SpecialPowers.spawn(myFrame1, [], () => this.content.location.href),
CROSS_ORIGIN_URI,
is(SpecialPowers.wrap(myFrame1.contentWindow).location.href, CROSS_ORIGIN_URI,
"cross origin dummy loaded into frame1");
myFrame1.addEventListener("load", checkBackNavFrame1);
myFrame1.src = SAME_ORIGIN_URI + "#bar";
}
async function checkBackNavFrame1() {
function checkBackNavFrame1() {
myFrame1.removeEventListener("load", checkBackNavFrame1);
is(await SpecialPowers.spawn(myFrame1, [], () => this.content.location.href),
SAME_ORIGIN_URI + "#bar",
is(SpecialPowers.wrap(myFrame1.contentWindow).location.href, SAME_ORIGIN_URI + "#bar",
"navagiating back to same origin dummy for frame1");
checkFinish();
}

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

@ -56,12 +56,10 @@ function navigateByHyperlink(name) {
// Functions that call into Mochitest framework
// /////////////////////////////////////////////////////////////////////////
async function isNavigated(wnd, message) {
function isNavigated(wnd, message) {
var result = null;
try {
result = await SpecialPowers.spawn(wnd, [], () =>
this.content.document.body.innerHTML.trim()
);
result = SpecialPowers.wrap(wnd).document.body.innerHTML.trim();
} catch (ex) {
result = ex;
}

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

@ -61,11 +61,11 @@ function testChild3() {
}
}
xpcWaitForFinishedFrames(async function() {
await isNavigated(frames[0], "Should be able to navigate on-domain opener's children by setting location.");
await isNavigated(frames[1], "Should be able to navigate on-domain opener's children by calling window.open.");
await isNavigated(frames[2], "Should be able to navigate on-domain opener's children by submitting form.");
await isNavigated(frames[3], "Should be able to navigate on-domain opener's children by targeted hyperlink.");
xpcWaitForFinishedFrames(function() {
isNavigated(frames[0], "Should be able to navigate on-domain opener's children by setting location.");
isNavigated(frames[1], "Should be able to navigate on-domain opener's children by calling window.open.");
isNavigated(frames[2], "Should be able to navigate on-domain opener's children by submitting form.");
isNavigated(frames[3], "Should be able to navigate on-domain opener's children by targeted hyperlink.");
window0.close();
window1.close();

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

@ -19,11 +19,11 @@ window.onload = function() {
navigateByForm("child2");
navigateByHyperlink("child3");
xpcWaitForFinishedFrames(async function() {
await isNavigated(frames[0], "Should be able to navigate off-domain child by setting location.");
await isNavigated(frames[1], "Should be able to navigate off-domain child by calling window.open.");
await isNavigated(frames[2], "Should be able to navigate off-domain child by submitting form.");
await isNavigated(frames[3], "Should be able to navigate off-domain child by targeted hyperlink.");
xpcWaitForFinishedFrames(function() {
isNavigated(frames[0], "Should be able to navigate off-domain child by setting location.");
isNavigated(frames[1], "Should be able to navigate off-domain child by calling window.open.");
isNavigated(frames[2], "Should be able to navigate off-domain child by submitting form.");
isNavigated(frames[3], "Should be able to navigate off-domain child by targeted hyperlink.");
xpcCleanupWindows();
SimpleTest.finish();

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

@ -19,11 +19,11 @@ window.onload = function() {
navigateByForm("child2_child0");
navigateByHyperlink("child3_child0");
xpcWaitForFinishedFrames(async function() {
await isNavigated(frames[0].frames[0], "Should be able to navigate off-domain grandchild by setting location.");
await isNavigated(frames[1].frames[0], "Should be able to navigate off-domain grandchild by calling window.open.");
await isNavigated(frames[2].frames[0], "Should be able to navigate off-domain grandchild by submitting form.");
await isNavigated(frames[3].frames[0], "Should be able to navigate off-domain grandchild by targeted hyperlink.");
xpcWaitForFinishedFrames(function() {
isNavigated(frames[0].frames[0], "Should be able to navigate off-domain grandchild by setting location.");
isNavigated(frames[1].frames[0], "Should be able to navigate off-domain grandchild by calling window.open.");
isNavigated(frames[2].frames[0], "Should be able to navigate off-domain grandchild by submitting form.");
isNavigated(frames[3].frames[0], "Should be able to navigate off-domain grandchild by targeted hyperlink.");
xpcCleanupWindows();
SimpleTest.finish();

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

@ -19,11 +19,11 @@ window.onload = function() {
navigateByForm("window2");
navigateByHyperlink("window3");
xpcWaitForFinishedFrames(async function() {
await isNavigated(window0, "Should be able to navigate popup by setting location.");
await isNavigated(window1, "Should be able to navigate popup by calling window.open.");
await isNavigated(window2, "Should be able to navigate popup by submitting form.");
await isNavigated(window3, "Should be able to navigate popup by targeted hyperlink.");
xpcWaitForFinishedFrames(function() {
isNavigated(window0, "Should be able to navigate popup by setting location.");
isNavigated(window1, "Should be able to navigate popup by calling window.open.");
isNavigated(window2, "Should be able to navigate popup by submitting form.");
isNavigated(window3, "Should be able to navigate popup by targeted hyperlink.");
window0.close();
window1.close();

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

@ -35,11 +35,11 @@ function testChild3() {
window3 = window.open("navigate.html#child3,hyperlink", "window3", "width=10,height=10");
}
xpcWaitForFinishedFrames(async function() {
await isNavigated(frames[0], "Should be able to navigate on-domain opener's children by setting location.");
await isNavigated(frames[1], "Should be able to navigate on-domain opener's children by calling window.open.");
await isNavigated(frames[2], "Should be able to navigate on-domain opener's children by submitting form.");
await isNavigated(frames[3], "Should be able to navigate on-domain opener's children by targeted hyperlink.");
xpcWaitForFinishedFrames(function() {
isNavigated(frames[0], "Should be able to navigate on-domain opener's children by setting location.");
isNavigated(frames[1], "Should be able to navigate on-domain opener's children by calling window.open.");
isNavigated(frames[2], "Should be able to navigate on-domain opener's children by submitting form.");
isNavigated(frames[3], "Should be able to navigate on-domain opener's children by targeted hyperlink.");
window0.close();
window1.close();

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

@ -16,11 +16,11 @@ window.onload = function() {
'<iframe src="navigate.html#child2,form"></iframe>' +
'<iframe src="navigate.html#child3,hyperlink"></iframe>';
xpcWaitForFinishedFrames(async function() {
await isNavigated(frames[0], "Should be able to navigate sibling with on-domain parent by setting location.");
await isNavigated(frames[1], "Should be able to navigate sibling with on-domain parent by calling window.open.");
await isNavigated(frames[2], "Should be able to navigate sibling with on-domain parent by submitting form.");
await isNavigated(frames[3], "Should be able to navigate sibling with on-domain parent by targeted hyperlink.");
xpcWaitForFinishedFrames(function() {
isNavigated(frames[0], "Should be able to navigate sibling with on-domain parent by setting location.");
isNavigated(frames[1], "Should be able to navigate sibling with on-domain parent by calling window.open.");
isNavigated(frames[2], "Should be able to navigate sibling with on-domain parent by submitting form.");
isNavigated(frames[3], "Should be able to navigate sibling with on-domain parent by targeted hyperlink.");
xpcCleanupWindows();
SimpleTest.finish();

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

@ -1,71 +0,0 @@
"use strict";
add_task(async function test_BrowsingContext_structured_clone() {
let browser = Services.appShell.createWindowlessBrowser(false);
let frame = browser.document.createElement("iframe");
browser.document.body.appendChild(frame);
let { browsingContext } = frame;
let sch = new StructuredCloneHolder({ browsingContext });
let deserialize = () => sch.deserialize({}, true);
// Check that decoding a live browsing context produces the correct
// object.
equal(
deserialize().browsingContext,
browsingContext,
"Got correct browsing context from StructuredClone deserialize"
);
// Check that decoding a second time still succeeds.
equal(
deserialize().browsingContext,
browsingContext,
"Got correct browsing context from second StructuredClone deserialize"
);
// Destroy the browsing context and make sure that the decode fails
// with a DataCloneError.
//
// Making sure the BrowsingContext is actually destroyed by the time
// we do the second decode is a bit tricky. We obviously have clear
// our local references to it, and give the GC a chance to reap them.
// And we also, of course, have to destroy the frame that it belongs
// to, or its frame loader and window global would hold it alive.
//
// Beyond that, we don't *have* to reload or destroy the parent
// document, but we do anyway just to be safe.
//
// Then comes the tricky bit: The WindowGlobal actors (which keep
// references to their BrowsingContexts) require an IPC round trip to
// be completely destroyed, even though they're in-process, so we make
// a quick trip through the event loop, and then run the CC in order
// to allow their (now snow-white) references to be collected.
frame.remove();
frame = null;
browsingContext = null;
browser.document.location.reload();
browser.close();
Cu.forceGC();
// Give the IPC messages that destroy the actors a chance to be
// processed.
await new Promise(executeSoon);
Cu.forceCC();
// OK. We can be fairly confident that the BrowsingContext object
// stored in our structured clone data has been destroyed. Make sure
// that attempting to decode it again leads to the appropriate error.
Assert.throws(
deserialize,
e => e.name === "DataCloneError",
"Should get a DataCloneError when trying to decode a dead BrowsingContext"
);
});

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

@ -2,7 +2,6 @@
head = head_docshell.js
[test_bug442584.js]
[test_browsing_context_structured_clone.js]
[test_nsDefaultURIFixup.js]
[test_nsDefaultURIFixup_search.js]
skip-if = os == 'android'

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

@ -10,8 +10,6 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/BrowsingContextBinding.h"
#include "mozilla/dom/StructuredCloneBlob.h"
#include "mozilla/dom/Directory.h"
#include "mozilla/dom/DirectoryBinding.h"
@ -912,10 +910,6 @@ JSObject* StructuredCloneHolder::CustomReadHandler(
return ReadInputStream(aCx, aIndex, this);
}
if (aTag == SCTAG_DOM_BROWSING_CONTEXT) {
return BrowsingContext::ReadStructuredClone(aCx, aReader, this);
}
return ReadFullySerializableObjects(aCx, aReader, aTag);
}
@ -979,15 +973,6 @@ bool StructuredCloneHolder::CustomWriteHandler(JSContext* aCx,
}
}
// See if this is a BrowsingContext object.
if (mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::DifferentProcess) {
BrowsingContext* holder = nullptr;
if (NS_SUCCEEDED(UNWRAP_OBJECT(BrowsingContext, &obj, holder))) {
return holder->WriteStructuredClone(aCx, aWriter, this);
}
}
// See if this is a WasmModule.
if ((mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope ==

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

@ -137,8 +137,6 @@ enum StructuredCloneTags {
SCTAG_DOM_STRUCTURED_CLONE_HOLDER,
SCTAG_DOM_BROWSING_CONTEXT,
// IMPORTANT: If you plan to add an new IDB tag, it _must_ be add before the
// "less stable" tags!
};

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

@ -9,6 +9,7 @@
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/dom/WindowProxyHolder.h"
#include "nsContentUtils.h"
#include "nsDOMWindowList.h"
#include "nsGlobalWindow.h"
#include "nsHTMLDocument.h"
#include "nsJSUtils.h"
@ -17,17 +18,18 @@
namespace mozilla {
namespace dom {
static bool ShouldExposeChildWindow(const nsString& aNameBeingResolved,
static bool ShouldExposeChildWindow(nsString& aNameBeingResolved,
BrowsingContext* aChild) {
Element* e = aChild->GetEmbedderElement();
nsPIDOMWindowOuter* child = aChild->GetDOMWindow();
Element* e = child->GetFrameElementInternal();
if (e && e->IsInShadowTree()) {
return false;
}
// If we're same-origin with the child, go ahead and expose it.
nsPIDOMWindowOuter* child = aChild->GetDOMWindow();
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(child);
if (sop && nsContentUtils::SubjectPrincipal()->Equals(sop->GetPrincipal())) {
NS_ENSURE_TRUE(sop, false);
if (nsContentUtils::SubjectPrincipal()->Equals(sop->GetPrincipal())) {
return true;
}
@ -167,12 +169,23 @@ bool WindowNamedPropertiesHandler::ownPropNames(
// The names live on the outer window, which might be null
nsGlobalWindowOuter* outer = win->GetOuterWindowInternal();
if (outer) {
if (BrowsingContext* bc = outer->GetBrowsingContext()) {
for (const auto& child : bc->GetChildren()) {
const nsString& name = child->Name();
if (!name.IsEmpty() && !names.Contains(name)) {
nsDOMWindowList* childWindows = outer->GetFrames();
if (childWindows) {
uint32_t length = childWindows->GetLength();
for (uint32_t i = 0; i < length; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item =
childWindows->GetDocShellTreeItemAt(i);
// This is a bit silly, since we could presumably just do
// item->GetWindow(). But it's not obvious whether this does the same
// thing as GetChildWindow() with the item's name (due to the complexity
// of FindChildWithName). Since GetChildWindow is what we use in
// getOwnPropDescriptor, let's try to be consistent.
nsString name;
item->GetName(name);
if (!names.Contains(name)) {
// Make sure we really would expose it from getOwnPropDescriptor.
if (ShouldExposeChildWindow(name, child)) {
RefPtr<BrowsingContext> child = win->GetChildWindow(name);
if (child && ShouldExposeChildWindow(name, child)) {
names.AppendElement(name);
}
}

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

@ -336,6 +336,7 @@ UNIFIED_SOURCES += [
'nsDOMNavigationTiming.cpp',
'nsDOMSerializer.cpp',
'nsDOMTokenList.cpp',
'nsDOMWindowList.cpp',
'nsFocusManager.cpp',
'nsFrameLoader.cpp',
'nsFrameLoaderOwner.cpp',

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

@ -0,0 +1,82 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#include "nsDOMWindowList.h"
#include "FlushType.h"
#include "nsCOMPtr.h"
#include "mozilla/dom/Document.h"
#include "nsIDOMWindow.h"
#include "nsIDocShell.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIScriptGlobalObject.h"
#include "nsIWebNavigation.h"
using namespace mozilla;
nsDOMWindowList::nsDOMWindowList(nsIDocShell* aDocShell) {
SetDocShell(aDocShell);
}
nsDOMWindowList::~nsDOMWindowList() {}
void nsDOMWindowList::SetDocShell(nsIDocShell* aDocShell) {
mDocShellNode = aDocShell; // Weak Reference
}
void nsDOMWindowList::EnsureFresh() {
nsCOMPtr<nsIWebNavigation> shellAsNav = do_QueryInterface(mDocShellNode);
if (shellAsNav) {
nsCOMPtr<dom::Document> doc;
shellAsNav->GetDocument(getter_AddRefs(doc));
if (doc) {
doc->FlushPendingNotifications(FlushType::ContentAndNotify);
}
}
}
uint32_t nsDOMWindowList::GetLength() {
EnsureFresh();
NS_ENSURE_TRUE(mDocShellNode, 0);
int32_t length;
nsresult rv = mDocShellNode->GetChildCount(&length);
NS_ENSURE_SUCCESS(rv, 0);
return uint32_t(length);
}
already_AddRefed<nsPIDOMWindowOuter> nsDOMWindowList::IndexedGetter(
uint32_t aIndex) {
nsCOMPtr<nsIDocShellTreeItem> item = GetDocShellTreeItemAt(aIndex);
if (!item) {
return nullptr;
}
nsCOMPtr<nsPIDOMWindowOuter> window = item->GetWindow();
MOZ_ASSERT(window);
return window.forget();
}
already_AddRefed<nsPIDOMWindowOuter> nsDOMWindowList::NamedItem(
const nsAString& aName) {
EnsureFresh();
if (!mDocShellNode) {
return nullptr;
}
nsCOMPtr<nsIDocShellTreeItem> item;
mDocShellNode->FindChildWithName(aName, false, false, nullptr, nullptr,
getter_AddRefs(item));
nsCOMPtr<nsPIDOMWindowOuter> childWindow(do_GetInterface(item));
return childWindow.forget();
}

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

@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef nsDOMWindowList_h___
#define nsDOMWindowList_h___
#include "nsCOMPtr.h"
#include <stdint.h>
#include "nsIDocShell.h"
class nsIDocShell;
class nsIDOMWindow;
class nsDOMWindowList final {
public:
explicit nsDOMWindowList(nsIDocShell* aDocShell);
NS_INLINE_DECL_REFCOUNTING(nsDOMWindowList)
uint32_t GetLength();
already_AddRefed<nsPIDOMWindowOuter> IndexedGetter(uint32_t aIndex);
already_AddRefed<nsPIDOMWindowOuter> NamedItem(const nsAString& aName);
// local methods
void SetDocShell(nsIDocShell* aDocShell);
already_AddRefed<nsIDocShellTreeItem> GetDocShellTreeItemAt(uint32_t aIndex) {
EnsureFresh();
nsCOMPtr<nsIDocShellTreeItem> item;
if (mDocShellNode) {
mDocShellNode->GetChildAt(aIndex, getter_AddRefs(item));
}
return item.forget();
}
protected:
~nsDOMWindowList();
// Note: this function may flush and cause mDocShellNode to become null.
void EnsureFresh();
nsIDocShell* mDocShellNode; // Weak Reference
};
#endif // nsDOMWindowList_h___

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

@ -50,6 +50,7 @@
#include "nsISizeOfEventTarget.h"
#include "nsDOMJSUtils.h"
#include "nsArrayUtils.h"
#include "nsDOMWindowList.h"
#include "mozilla/dom/WakeLock.h"
#include "mozilla/dom/power/PowerManagerService.h"
#include "nsIContentSecurityPolicy.h"
@ -2707,7 +2708,11 @@ bool nsGlobalWindowInner::GetClosed(ErrorResult& aError) {
FORWARD_TO_OUTER(GetClosedOuter, (), true);
}
Nullable<WindowProxyHolder> nsGlobalWindowInner::IndexedGetter(
nsDOMWindowList* nsGlobalWindowInner::GetFrames() {
FORWARD_TO_OUTER(GetFrames, (), nullptr);
}
already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowInner::IndexedGetter(
uint32_t aIndex) {
FORWARD_TO_OUTER(IndexedGetterOuter, (aIndex), nullptr);
}

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

@ -77,6 +77,7 @@ class nsITimeoutHandler;
class nsIWebBrowserChrome;
class mozIDOMWindowProxy;
class nsDOMWindowList;
class nsScreen;
class nsHistory;
class nsGlobalWindowObserver;
@ -380,8 +381,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
NS_DECL_NSIINTERFACEREQUESTOR
// WebIDL interface.
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> IndexedGetter(
uint32_t aIndex);
already_AddRefed<nsPIDOMWindowOuter> IndexedGetter(uint32_t aIndex);
static bool IsPrivilegedChromeWindow(JSContext* /* unused */, JSObject* aObj);
@ -612,6 +612,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
void Focus(mozilla::ErrorResult& aError);
nsresult Focus() override;
void Blur(mozilla::ErrorResult& aError);
nsDOMWindowList* GetFrames() final;
mozilla::dom::BrowsingContext* GetFrames(mozilla::ErrorResult& aError);
uint32_t Length();
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetTop(

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

@ -48,6 +48,7 @@
#include "nsISizeOfEventTarget.h"
#include "nsDOMJSUtils.h"
#include "nsArrayUtils.h"
#include "nsDOMWindowList.h"
#include "mozilla/dom/WakeLock.h"
#include "mozilla/dom/power/PowerManagerService.h"
#include "nsIDocShellTreeOwner.h"
@ -509,9 +510,8 @@ class nsOuterWindowProxy : public MaybeCrossOriginObject<js::Wrapper> {
// Returns a non-null window only if id is an index and we have a
// window at that index.
Nullable<WindowProxyHolder> GetSubframeWindow(JSContext* cx,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id) const;
already_AddRefed<nsPIDOMWindowOuter> GetSubframeWindow(
JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id) const;
bool AppendIndexedPropertyNames(JSObject* proxy,
JS::MutableHandleVector<jsid> props) const;
@ -784,7 +784,7 @@ bool nsOuterWindowProxy::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
return ReportCrossOriginDenial(cx, id, NS_LITERAL_CSTRING("delete"));
}
if (!GetSubframeWindow(cx, proxy, id).IsNull()) {
if (nsCOMPtr<nsPIDOMWindowOuter> frame = GetSubframeWindow(cx, proxy, id)) {
// Fail (which means throw if strict, else return false).
return result.failCantDeleteWindowElement();
}
@ -818,7 +818,7 @@ bool nsOuterWindowProxy::has(JSContext* cx, JS::Handle<JSObject*> proxy,
return hasOwn(cx, proxy, id, bp);
}
if (!GetSubframeWindow(cx, proxy, id).IsNull()) {
if (nsCOMPtr<nsPIDOMWindowOuter> frame = GetSubframeWindow(cx, proxy, id)) {
*bp = true;
return true;
}
@ -851,7 +851,7 @@ bool nsOuterWindowProxy::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy,
return js::BaseProxyHandler::hasOwn(cx, proxy, id, bp);
}
if (!GetSubframeWindow(cx, proxy, id).IsNull()) {
if (nsCOMPtr<nsPIDOMWindowOuter> frame = GetSubframeWindow(cx, proxy, id)) {
*bp = true;
return true;
}
@ -982,17 +982,28 @@ bool nsOuterWindowProxy::GetSubframeWindow(JSContext* cx,
JS::Handle<jsid> id,
JS::MutableHandle<JS::Value> vp,
bool& found) const {
Nullable<WindowProxyHolder> frame = GetSubframeWindow(cx, proxy, id);
if (frame.IsNull()) {
nsCOMPtr<nsPIDOMWindowOuter> frame = GetSubframeWindow(cx, proxy, id);
if (!frame) {
found = false;
return true;
}
found = true;
return WrapObject(cx, frame.Value(), vp);
// Just return the window's global
nsGlobalWindowOuter* global = nsGlobalWindowOuter::Cast(frame);
frame->EnsureInnerWindow();
JSObject* obj = global->GetGlobalJSObject();
// This null check fixes a hard-to-reproduce crash that occurs when we
// get here when we're mid-call to nsDocShell::Destroy. See bug 640904
// comment 105.
if (MOZ_UNLIKELY(!obj)) {
return xpc::Throw(cx, NS_ERROR_FAILURE);
}
vp.setObject(*obj);
return JS_WrapValue(cx, vp);
}
Nullable<WindowProxyHolder> nsOuterWindowProxy::GetSubframeWindow(
already_AddRefed<nsPIDOMWindowOuter> nsOuterWindowProxy::GetSubframeWindow(
JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id) const {
uint32_t index = GetArrayIndexFromId(id);
if (!IsArrayIndex(index)) {
@ -1289,6 +1300,7 @@ void nsGlobalWindowOuter::CleanUp() {
StartDying();
mFrames = nullptr;
mWindowUtils = nullptr;
ClearControllers();
@ -2368,6 +2380,10 @@ void nsGlobalWindowOuter::SetDocShell(nsDocShell* aDocShell) {
mTopLevelOuterContentWindow =
!mIsChrome && GetScriptableTopInternal() == this;
if (mFrames) {
mFrames->SetDocShell(aDocShell);
}
// Get our enclosing chrome shell and retrieve its global window impl, so
// that we can do some forwarding to the chrome document.
RefPtr<EventTarget> chromeEventHandler;
@ -2459,6 +2475,10 @@ void nsGlobalWindowOuter::DetachFromDocShell() {
mDocShell = nullptr;
mBrowsingContext->ClearDocShell();
if (mFrames) {
mFrames->SetDocShell(nullptr);
}
MaybeForgiveSpamCount();
CleanUp();
}
@ -3176,16 +3196,20 @@ bool nsGlobalWindowOuter::GetClosedOuter() {
bool nsGlobalWindowOuter::Closed() { return GetClosedOuter(); }
Nullable<WindowProxyHolder> nsGlobalWindowOuter::IndexedGetterOuter(
uint32_t aIndex) {
BrowsingContext* bc = GetBrowsingContext();
NS_ENSURE_TRUE(bc, nullptr);
const BrowsingContext::Children& children = bc->GetChildren();
if (aIndex < children.Length()) {
return WindowProxyHolder(children[aIndex]);
nsDOMWindowList* nsGlobalWindowOuter::GetFrames() {
if (!mFrames && mDocShell) {
mFrames = new nsDOMWindowList(mDocShell);
}
return nullptr;
return mFrames;
}
already_AddRefed<nsPIDOMWindowOuter> nsGlobalWindowOuter::IndexedGetterOuter(
uint32_t aIndex) {
nsDOMWindowList* windows = GetFrames();
NS_ENSURE_TRUE(windows, nullptr);
return windows->IndexedGetter(aIndex);
}
nsIControllers* nsGlobalWindowOuter::GetControllersOuter(ErrorResult& aError) {
@ -3938,8 +3962,9 @@ double nsGlobalWindowOuter::GetScrollXOuter() { return GetScrollXY(false).x; }
double nsGlobalWindowOuter::GetScrollYOuter() { return GetScrollXY(false).y; }
uint32_t nsGlobalWindowOuter::Length() {
BrowsingContext* bc = GetBrowsingContext();
return bc ? bc->GetChildren().Length() : 0;
nsDOMWindowList* windows = GetFrames();
return windows ? windows->GetLength() : 0;
}
Nullable<WindowProxyHolder> nsGlobalWindowOuter::GetTopOuter() {

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

@ -74,6 +74,7 @@ class nsIWebBrowserChrome;
class mozIDOMWindowProxy;
class nsDocShellLoadState;
class nsDOMWindowList;
class nsScreen;
class nsHistory;
class nsGlobalWindowObserver;
@ -353,8 +354,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
// nsIObserver
NS_DECL_NSIOBSERVER
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> IndexedGetterOuter(
uint32_t aIndex);
already_AddRefed<nsPIDOMWindowOuter> IndexedGetterOuter(uint32_t aIndex);
already_AddRefed<nsPIDOMWindowOuter> GetTop() override;
// Similar to GetTop() except that it stops at content frames that an
@ -535,6 +535,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
nsresult Focus() override;
void BlurOuter();
mozilla::dom::BrowsingContext* GetFramesOuter();
nsDOMWindowList* GetFrames() final;
uint32_t Length();
mozilla::dom::Nullable<mozilla::dom::WindowProxyHolder> GetTopOuter();
@ -918,8 +919,8 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
virtual bool ShouldShowFocusRing() override;
virtual void SetKeyboardIndicators(
UIStateChangeType aShowFocusRings) override;
virtual void SetKeyboardIndicators(UIStateChangeType aShowFocusRings)
override;
public:
virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() override;
@ -1099,6 +1100,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
// For |window.arguments|, via |openDialog|.
nsCOMPtr<nsIArray> mArguments;
RefPtr<nsDOMWindowList> mFrames;
RefPtr<nsDOMWindowUtils> mWindowUtils;
nsString mStatus;

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

@ -25,6 +25,7 @@
#define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed"
class nsDOMOfflineResourceList;
class nsDOMWindowList;
class nsGlobalWindowInner;
class nsGlobalWindowOuter;
class nsIArray;
@ -545,6 +546,8 @@ class nsPIDOMWindowInner : public mozIDOMWindow {
virtual nsresult GetControllers(nsIControllers** aControllers) = 0;
virtual nsDOMWindowList* GetFrames() = 0;
virtual nsresult GetInnerWidth(int32_t* aWidth) = 0;
virtual nsresult GetInnerHeight(int32_t* aHeight) = 0;
@ -1042,6 +1045,8 @@ class nsPIDOMWindowOuter : public mozIDOMWindowProxy {
virtual already_AddRefed<mozilla::dom::Selection> GetSelection() = 0;
virtual already_AddRefed<nsPIDOMWindowOuter> GetOpener() = 0;
virtual nsDOMWindowList* GetFrames() = 0;
// aLoadState will be passed on through to the windowwatcher.
// aForceNoOpener will act just like a "noopener" feature in aOptions except
// will not affect any other window features.

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

@ -7,14 +7,13 @@
#include "nsWindowMemoryReporter.h"
#include "nsWindowSizes.h"
#include "nsGlobalWindow.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/Document.h"
#include "nsDOMWindowList.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/ResultExtensions.h"
#include "nsNetCID.h"
#include "nsPrintfCString.h"
#include "XPCJSMemoryReporter.h"
@ -62,16 +61,19 @@ static nsresult AddNonJSSizeOfWindowAndItsDescendents(
windowSizes.addToTabSizes(aSizes);
BrowsingContext* bc = aWindow->GetBrowsingContext();
if (!bc) {
return NS_OK;
}
nsDOMWindowList* frames = aWindow->GetFrames();
uint32_t length = frames->GetLength();
// Measure this window's descendents.
for (const auto& frame : bc->GetChildren()) {
if (auto* childWin = nsGlobalWindowOuter::Cast(frame->GetDOMWindow())) {
MOZ_TRY(AddNonJSSizeOfWindowAndItsDescendents(childWin, aSizes));
}
for (uint32_t i = 0; i < length; i++) {
nsCOMPtr<nsPIDOMWindowOuter> child = frames->IndexedGetter(i);
NS_ENSURE_STATE(child);
nsGlobalWindowOuter* childWin = nsGlobalWindowOuter::Cast(child);
nsresult rv = AddNonJSSizeOfWindowAndItsDescendents(childWin, aSizes);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}

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

@ -10,8 +10,6 @@
<label value="CPOWs"/>
<script type="application/javascript"><![CDATA[
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var test_state = "remote";
var test_node = null;
var reentered = false;
@ -402,7 +400,7 @@
let failed = false;
const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
Services.prefs.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
opener.wrappedJSObject.SpecialPowers.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
try {
msg.objects.f();
} catch (e) {
@ -418,7 +416,7 @@
function recvSafe(msg) {
const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
Services.prefs.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
opener.wrappedJSObject.SpecialPowers.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
try {
msg.objects.f();
} catch (e) {

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

@ -34,7 +34,7 @@ function createFileWithData(fileData) {
/** Test for Bug 914381. File's created in JS using an nsIFile should allow mozGetFullPathInternal calls to succeed **/
var file = createFileWithData("Test bug 914381");
SpecialPowers.pushPrefEnv({ set: [["dom.file.createInChild", true]]})
SpecialPowers.pushPrefEnv({ set: [ "dom.file.createInChild" ]})
.then(() => {
return File.createFromNsIFile(file);
})

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

@ -13,14 +13,12 @@
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
SimpleTest.waitForExplicitFinish();
const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
Services.prefs.setBoolPref(PREF_UNSAFE_FORBIDDEN, false);
SpecialPowers.setBoolPref(PREF_UNSAFE_FORBIDDEN, false);
SimpleTest.registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_UNSAFE_FORBIDDEN);
SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
});
function done() {

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

@ -23,8 +23,7 @@
<script class="testbody" type="application/javascript">
<![CDATA[
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var SpecialPowers = window.opener.wrappedJSObject.SpecialPowers;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
SimpleTest.waitForFocus(runTests, window);
@ -1481,7 +1480,7 @@ function runReleaseTests()
// Release the TIP
TIP = null;
// Needs to run GC forcibly for testing this.
Cu.forceGC();
SpecialPowers.gc();
is(input.value, "",
description + "the input should be empty because the composition should be canceled");
@ -1771,7 +1770,7 @@ function runCompositionWithKeyEventTests()
var convertKeyEvent = new KeyboardEvent("", { key: "Convert", code: "Convert", keyCode: KeyboardEvent.DOM_VK_CONVERT });
var backspaceKeyEvent = new KeyboardEvent("", { key: "Backspace", code: "Backspace", keyCode: KeyboardEvent.DOM_VK_BACK_SPACE });
Services.prefs.setBoolPref("dom.keyboardevent.dispatch_during_composition", false);
SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", false);
// nsITextInputProcessor.startComposition()
reset();
@ -2005,7 +2004,7 @@ function runCompositionWithKeyEventTests()
is(input.value, "FOobarbuzzboo!",
description + "committing text directly should append the committing text to the focused editor");
Services.prefs.setBoolPref("dom.keyboardevent.dispatch_during_composition", true);
SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", true);
// Even if "dom.keyboardevent.dispatch_during_composition" is true, keypress event shouldn't be fired during composition
reset();
@ -2109,7 +2108,7 @@ function runCompositionWithKeyEventTests()
is(events[1].type, "compositionend",
description + "TIP.cancelComposition(escKeydownEvent) should cause compositionend (keyup event shouldn't be fired)");
Services.prefs.clearUserPref("dom.keyboardevent.dispatch_during_composition");
SpecialPowers.clearUserPref("dom.keyboardevent.dispatch_during_composition");
window.removeEventListener("compositionstart", handler, false);
window.removeEventListener("compositionupdate", handler, false);
@ -2156,7 +2155,7 @@ function runConsumingKeydownBeforeCompositionTests()
var enterKeyEvent = new KeyboardEvent("", { key: "Enter", code: "Enter", keyCode: KeyboardEvent.DOM_VK_RETURN });
var escKeyEvent = new KeyboardEvent("", { key: "Escape", code: "Escape", keyCode: KeyboardEvent.DOM_VK_ESCAPE });
Services.prefs.setBoolPref("dom.keyboardevent.dispatch_during_composition", false);
SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", false);
// If keydown before compositionstart is consumed, composition shouldn't be started.
reset();
@ -2206,7 +2205,7 @@ function runConsumingKeydownBeforeCompositionTests()
is(input.value, "",
description + "TIP.commitCompositionWith(\"foo\", printableKeyEvent) shouldn't cause inserting text");
Services.prefs.setBoolPref("dom.keyboardevent.dispatch_during_composition", true);
SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", true);
// If composition is already started, TIP.flushPendingComposition(printableKeyEvent) shouldn't be canceled.
TIP.startComposition();
@ -2274,7 +2273,7 @@ function runConsumingKeydownBeforeCompositionTests()
is(input.value, "",
description + "TIP.cancelComposition(escKeyEvent) should cancel composition even if preceding keydown is consumed because there was a composition already");
Services.prefs.clearUserPref("dom.keyboardevent.dispatch_during_composition");
SpecialPowers.clearUserPref("dom.keyboardevent.dispatch_during_composition");
window.removeEventListener("compositionstart", handler, false);
window.removeEventListener("compositionupdate", handler, false);
@ -2595,7 +2594,7 @@ function runKeyTests()
// key events during composition
try {
Services.prefs.setBoolPref("dom.keyboardevent.dispatch_during_composition", false);
SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", false);
ok(TIP.startComposition(), "TIP.startComposition() should start composition");
@ -2609,7 +2608,7 @@ function runKeyTests()
is(events.length, 0,
description + "TIP.keyup(keyA) shouldn't cause key events during composition if it's disabled by the pref");
Services.prefs.setBoolPref("dom.keyboardevent.dispatch_during_composition", true);
SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", true);
reset();
TIP.keydown(keyA);
is(events.length, 1,
@ -2625,7 +2624,7 @@ function runKeyTests()
} finally {
TIP.cancelComposition();
Services.prefs.clearUserPref("dom.keyboardevent.dispatch_during_composition");
SpecialPowers.clearUserPref("dom.keyboardevent.dispatch_during_composition");
}
// Test .location computation

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

@ -15,8 +15,8 @@ function getTestPlugin(pluginName) {
return null;
}
// Copied from /dom/plugins/test/mochitest/utils.js
async function setTestPluginEnabledState(newEnabledState, pluginName) {
var oldEnabledState = await SpecialPowers.setTestPluginEnabledState(
function setTestPluginEnabledState(newEnabledState, pluginName) {
var oldEnabledState = SpecialPowers.setTestPluginEnabledState(
newEnabledState,
pluginName
);
@ -30,7 +30,7 @@ async function setTestPluginEnabledState(newEnabledState, pluginName) {
return plugin.enabledState == newEnabledState;
});
SimpleTest.registerCleanupFunction(function() {
return SpecialPowers.setTestPluginEnabledState(oldEnabledState, pluginName);
SpecialPowers.setTestPluginEnabledState(oldEnabledState, pluginName);
});
}
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);

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

@ -16,10 +16,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
function doTest() {
var file = location.href;
var asyncFrame;
/* Async parent frames from pushPrefEnv don't show up in e10s. */
if (SpecialPowers.getBoolPref("javascript.options.asyncstack")) {
var isE10S = !SpecialPowers.isMainProcess();
if (!isE10S && SpecialPowers.getBoolPref("javascript.options.asyncstack")) {
asyncFrame = `Async*@${file}:153:17
`;
} else {

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

@ -37,12 +37,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
function doTest() {
var t = new TestInterfaceJS();
/* Async parent frames from pushPrefEnv don't show up in e10s. */
var isE10S = !SpecialPowers.isMainProcess();
var asyncStack = SpecialPowers.getBoolPref("javascript.options.asyncstack");
var ourFile = location.href;
var unwrapError = "Promise rejection value is a non-unwrappable cross-compartment wrapper.";
var parentFrame = asyncStack ? `Async*@${ourFile}:130:17
var parentFrame = (asyncStack && !isE10S) ? `Async*@${ourFile}:130:17
` : "";
Promise.all([

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

@ -16,7 +16,7 @@
</div>
<pre id="test">
<script type="application/javascript">
SpecialPowers.pushPrefEnv({"set": [["canvas.hitregions.enabled", true]]}).then(function() {
SpecialPowers.pushPrefEnv({"set": [["canvas.hitregions.enabled", true]]}, function() {
var input = document.getElementById("input");
var regionId = "";

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

@ -9,8 +9,6 @@ interface nsIDocShell;
interface BrowsingContext {
static BrowsingContext? get(unsigned long long aId);
static BrowsingContext? getFromWindow(WindowProxy window);
BrowsingContext? findChildWithName(DOMString name);
BrowsingContext? findWithName(DOMString name);

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

@ -23,7 +23,6 @@ let seenClick = false;
SpecialPowers.pushPrefEnv(
{ set: [[HACK_PREF, document.domain]] },
() => {
SimpleTest.waitForFocus(() => {
// Test seeing the non-primary 'click'
document.addEventListener("click", (e) => {
@ -46,8 +45,8 @@ SpecialPowers.pushPrefEnv(
ok(false, "Shouldn't have got 'auxclick' after preventDefaulting 'click'");
}, { once: true });
synthesizeMouseAtCenter(linkEl, { button: 1 });
});
});
})
);
</script>
</body>
</html>

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

@ -152,7 +152,6 @@ async function testFullscreenMouseBtn(event, button, next) {
// Restore the pref environment we changed before
// entering testNonTrustContext.
await SpecialPowers.popPrefEnv();
await SpecialPowers.popPrefEnv();
finish();
}

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

@ -39,8 +39,8 @@ function onFileOpened(message) {
const elem = document.getElementById("file");
is(getGlobal(elem), window,
"getGlobal() works as expected");
is(getGlobal(file), window,
"File from MessageManager is not wrapped");
isnot(getGlobal(file), window,
"File from MessageManager is wrapped");
SpecialPowers.wrap(elem).mozSetFileArray([file]);
is(getGlobal(elem.files[0]), window,
"File read back from input element is not wrapped");

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

@ -12,13 +12,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1414077
/** Test for Bug 1414077 **/
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
SimpleTest.waitForExplicitFinish();
add_task(async function() {
await SpecialPowers.pushPrefEnv({"set": [["browser.enable_automatic_image_resizing", true]]});
return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set":[["browser.enable_automatic_image_resizing", true]]}, function() {
var testWin = document.querySelector("iframe");
testWin.height = 0;
testWin.width = 0;
testWin.src = "image.png";
testWin.onload = function() {
var testDoc = testWin.contentDocument;
@ -37,9 +36,8 @@ add_task(async function() {
ok(testDoc.imageIsOverflowing, "image is overflowing");
ok(testDoc.imageIsResized, "image is resized to fit visible area");
resolve();
SimpleTest.finish();
};
})
});
</script>
@ -47,6 +45,6 @@ add_task(async function() {
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1414077">Mozilla Bug 1414077</a>
<iframe width="0" height="0"></iframe>
<iframe></iframe>
</body>
</html>

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

@ -888,14 +888,6 @@ nsresult ContentChild::ProvideWindowCommon(
// load in the current process.
bool loadInDifferentProcess = aForceNoOpener && sNoopenerNewProcess;
if (aTabOpener && !loadInDifferentProcess && aURI) {
nsCOMPtr<nsILoadContext> context;
if (aParent) {
context = do_GetInterface(aTabOpener->WebNavigation());
}
// Only special-case cross-process loads if Fission is disabled. With
// Fission enabled, the initial in-process load will automatically be
// retargeted to the correct process.
if (!(context && context->UseRemoteSubframes())) {
nsCOMPtr<nsIWebBrowserChrome3> browserChrome3;
rv = aTabOpener->GetWebBrowserChrome(getter_AddRefs(browserChrome3));
if (NS_SUCCEEDED(rv) && browserChrome3) {
@ -904,7 +896,6 @@ nsresult ContentChild::ProvideWindowCommon(
loadInDifferentProcess = NS_SUCCEEDED(rv) && !shouldLoad;
}
}
}
// If we're in a content process and we have noopener set, there's no reason
// to load in our process, so let's load it elsewhere!

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

@ -8,8 +8,6 @@
#include "mozilla/dom/JSWindowActorBinding.h"
#include "mozilla/dom/MessageManagerBinding.h"
#include "mozilla/dom/PWindowGlobal.h"
#include "mozilla/dom/Promise.h"
#include "js/Promise.h"
namespace mozilla {
namespace dom {
@ -37,6 +35,10 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(JSWindowActor)
JSWindowActor::JSWindowActor() : mNextQueryId(0) {}
nsIGlobalObject* JSWindowActor::GetParentObject() const {
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
}
void JSWindowActor::StartDestroy() {
DestroyCallback(DestroyCallbackFunction::WillDestroy);
}
@ -46,7 +48,8 @@ void JSWindowActor::AfterDestroy() {
}
void JSWindowActor::DestroyCallback(DestroyCallbackFunction callback) {
AutoEntryScript aes(GetParentObject(), "JSWindowActor destroy callback");
AutoEntryScript aes(xpc::PrivilegedJunkScope(),
"JSWindowActor destroy callback");
JSContext* cx = aes.cx();
MozActorDestroyCallbacks callbacksHolder;
NS_ENSURE_TRUE_VOID(GetWrapper());
@ -88,8 +91,8 @@ void JSWindowActor::SendAsyncMessage(JSContext* aCx,
JS::Handle<JS::Value> aTransfers,
ErrorResult& aRv) {
ipc::StructuredCloneData data;
if (!nsFrameMessageManager::GetParamsForMessage(aCx, aObj, aTransfers,
data)) {
if (!aObj.isUndefined() && !nsFrameMessageManager::GetParamsForMessage(
aCx, aObj, aTransfers, data)) {
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
return;
}
@ -106,8 +109,8 @@ already_AddRefed<Promise> JSWindowActor::SendQuery(
JSContext* aCx, const nsAString& aMessageName, JS::Handle<JS::Value> aObj,
JS::Handle<JS::Value> aTransfers, ErrorResult& aRv) {
ipc::StructuredCloneData data;
if (!nsFrameMessageManager::GetParamsForMessage(aCx, aObj, aTransfers,
data)) {
if (!aObj.isUndefined() && !nsFrameMessageManager::GetParamsForMessage(
aCx, aObj, aTransfers, data)) {
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
return nullptr;
}
@ -137,7 +140,8 @@ already_AddRefed<Promise> JSWindowActor::SendQuery(
void JSWindowActor::ReceiveRawMessage(const JSWindowActorMessageMeta& aMetadata,
ipc::StructuredCloneData&& aData) {
AutoEntryScript aes(GetParentObject(), "JSWindowActor message handler");
AutoEntryScript aes(xpc::PrivilegedJunkScope(),
"JSWindowActor message handler");
JSContext* cx = aes.cx();
// Read the message into a JS object from IPC.
@ -145,11 +149,6 @@ void JSWindowActor::ReceiveRawMessage(const JSWindowActorMessageMeta& aMetadata,
JS::Rooted<JS::Value> data(cx);
aData.Read(cx, &data, error);
if (NS_WARN_IF(error.Failed())) {
if (XRE_IsParentProcess()) {
MOZ_ASSERT(false, "Should not receive non-decodable data");
} else {
MOZ_DIAGNOSTIC_ASSERT(false, "Should not receive non-decodable data");
}
MOZ_ALWAYS_TRUE(error.MaybeSetPendingException(cx));
return;
}
@ -236,15 +235,8 @@ void JSWindowActor::ReceiveQueryReply(JSContext* aCx,
return;
}
JSAutoRealm ar(aCx, promise->PromiseObj());
JS::RootedValue data(aCx, aData);
if (NS_WARN_IF(!JS_WrapValue(aCx, &data))) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
if (aMetadata.kind() == JSWindowActorMessageKind::QueryResolve) {
promise->MaybeResolve(aCx, data);
promise->MaybeResolve(aCx, aData);
} else {
promise->MaybeReject(NS_ERROR_DOM_OPERATION_ERR);
}
@ -270,9 +262,8 @@ void JSWindowActor::QueryHandler::RejectedCallback(
Unused << JS::CallOriginalPromiseReject(aCx, aValue);
// The exception probably isn't cloneable, so just send down undefined.
ipc::StructuredCloneData data;
data.Write(aCx, JS::UndefinedHandleValue, IgnoredErrorResult());
SendReply(aCx, JSWindowActorMessageKind::QueryReject, std::move(data));
SendReply(aCx, JSWindowActorMessageKind::QueryReject,
ipc::StructuredCloneData());
}
void JSWindowActor::QueryHandler::ResolvedCallback(
@ -298,9 +289,8 @@ void JSWindowActor::QueryHandler::ResolvedCallback(
JS_ClearPendingException(aCx);
ipc::StructuredCloneData data;
data.Write(aCx, JS::UndefinedHandleValue, IgnoredErrorResult());
SendReply(aCx, JSWindowActorMessageKind::QueryReject, std::move(data));
SendReply(aCx, JSWindowActorMessageKind::QueryReject,
ipc::StructuredCloneData());
return;
}

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

@ -56,7 +56,7 @@ class JSWindowActor : public nsISupports, public nsWrapperCache {
void ReceiveRawMessage(const JSWindowActorMessageMeta& aMetadata,
ipc::StructuredCloneData&& aData);
virtual nsIGlobalObject* GetParentObject() const = 0;
nsIGlobalObject* GetParentObject() const;
void RejectPendingQueries();

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

@ -17,10 +17,6 @@
namespace mozilla {
namespace dom {
JSWindowActorChild::JSWindowActorChild(nsIGlobalObject* aGlobal)
: mGlobal(aGlobal ? aGlobal
: xpc::NativeGlobal(xpc::PrivilegedJunkScope())) {}
JSWindowActorChild::~JSWindowActorChild() { MOZ_ASSERT(!mManager); }
JSObject* JSWindowActorChild::WrapObject(JSContext* aCx,

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

@ -37,17 +37,12 @@ class JSWindowActorChild final : public JSWindowActor {
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(JSWindowActorChild,
JSWindowActor)
explicit JSWindowActorChild(nsIGlobalObject* aGlobal = nullptr);
nsIGlobalObject* GetParentObject() const override { return mGlobal; }
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
static already_AddRefed<JSWindowActorChild> Constructor(GlobalObject& aGlobal,
ErrorResult& aRv) {
nsCOMPtr<nsIGlobalObject> global(do_QueryInterface(aGlobal.GetAsSupports()));
return MakeAndAddRef<JSWindowActorChild>(global);
return MakeAndAddRef<JSWindowActorChild>();
}
WindowGlobalChild* GetManager() const;
@ -69,8 +64,6 @@ class JSWindowActorChild final : public JSWindowActor {
bool mCanSend = true;
RefPtr<WindowGlobalChild> mManager;
nsCOMPtr<nsIGlobalObject> mGlobal;
};
} // namespace dom

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

@ -14,10 +14,6 @@ namespace dom {
JSWindowActorParent::~JSWindowActorParent() { MOZ_ASSERT(!mManager); }
nsIGlobalObject* JSWindowActorParent::GetParentObject() const {
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
}
JSObject* JSWindowActorParent::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return JSWindowActorParent_Binding::Wrap(aCx, this, aGivenProto);

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

@ -40,8 +40,6 @@ class JSWindowActorParent final : public JSWindowActor {
return MakeAndAddRef<JSWindowActorParent>();
}
nsIGlobalObject* GetParentObject() const override;
WindowGlobalParent* GetManager() const;
void Init(const nsAString& aName, WindowGlobalParent* aManager);
void StartDestroy();

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

@ -60,7 +60,7 @@ var tests = [
{
keySystem: "com.widevine.alpha",
expectedStatus: 'cdm-not-installed',
prefs: [["media.eme.enabled", true], ["media.gmp-widevinecdm.enabled", true]]
prefs: [["media.eme.enabled", true], , ["media.gmp-widevinecdm.enabled", true]]
},
{
keySystem: CLEARKEY_KEYSYSTEM,

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

@ -162,7 +162,6 @@ function startTest(test, token) {
createMedia(test.type, test.name, token);
}
SimpleTest.waitForExplicitFinish();
createTestArray().then(testArray => {
manager.runTests(testArray, startTest);
});

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

@ -8,12 +8,12 @@ var NotificationTest = (function() {
function setup_testing_env() {
SimpleTest.waitForExplicitFinish();
// turn on testing pref (used by notification.cpp, and mock the alerts
return SpecialPowers.setBoolPref("notification.prompt.testing", true);
SpecialPowers.setBoolPref("notification.prompt.testing", true);
}
async function teardown_testing_env() {
await SpecialPowers.clearUserPref("notification.prompt.testing");
await SpecialPowers.clearUserPref("notification.prompt.testing.allow");
function teardown_testing_env() {
SpecialPowers.clearUserPref("notification.prompt.testing");
SpecialPowers.clearUserPref("notification.prompt.testing.allow");
SimpleTest.finish();
}
@ -79,10 +79,9 @@ var NotificationTest = (function() {
// NotificationTest API
return {
run(tests, callback) {
let ready = setup_testing_env();
setup_testing_env();
addLoadEvent(async function() {
await ready;
addLoadEvent(function() {
executeTests(tests, function() {
teardown_testing_env();
callback && callback();
@ -91,17 +90,11 @@ var NotificationTest = (function() {
},
allowNotifications() {
return SpecialPowers.setBoolPref(
"notification.prompt.testing.allow",
true
);
SpecialPowers.setBoolPref("notification.prompt.testing.allow", true);
},
denyNotifications() {
return SpecialPowers.setBoolPref(
"notification.prompt.testing.allow",
false
);
SpecialPowers.setBoolPref("notification.prompt.testing.allow", false);
},
clickNotification(notification) {

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

@ -32,13 +32,13 @@
Notification.requestPermission();
},
async function(done) {
function(done) {
info("Test requestPermission deny");
function assertPermissionDenied(perm) {
is(perm, "denied", "Permission should be denied.");
is(Notification.permission, "denied", "Permission should be denied.");
}
await NotificationTest.denyNotifications();
NotificationTest.denyNotifications();
Notification.requestPermission()
.then(assertPermissionDenied)
.then(_ => Notification.requestPermission(assertPermissionDenied))
@ -48,13 +48,13 @@
.then(done);
},
async function(done) {
function(done) {
info("Test requestPermission grant");
function assertPermissionGranted(perm) {
is(perm, "granted", "Permission should be granted.");
is(Notification.permission, "granted", "Permission should be granted");
}
await NotificationTest.allowNotifications();
NotificationTest.allowNotifications();
Notification.requestPermission()
.then(assertPermissionGranted)
.then(_ => Notification.requestPermission(assertPermissionGranted))

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

@ -37,7 +37,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1429432
response = await Notification.requestPermission();
is(response, "granted", "Granted permission in insecure context with pref set");
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
script.destroy();
SimpleTest.finish();

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

@ -130,9 +130,9 @@
const permission = 'geolocation';
const promiseGranted = this.promiseStateChanged(permission, 'granted');
this.setPermissions(ALLOW_ACTION);
promiseGranted.then(async () => {
promiseGranted.then(() => {
const promisePrompt = this.promiseStateChanged(permission, 'prompt');
await SpecialPowers.popPermissions();
SpecialPowers.popPermissions();
return promisePrompt;
}).then(resolve);
});

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

@ -120,11 +120,7 @@ function waitScrollFinish(aTarget) {
*/
function setTestPluginEnabledState(aState, aPluginName) {
let name = aPluginName || "Test Plug-in";
let resolved = false;
SpecialPowers.setTestPluginEnabledState(aState, name).then(() => {
resolved = true;
});
SpecialPowers.Services.tm.spinEventLoopUntil(() => resolved);
SpecialPowers.setTestPluginEnabledState(aState, name);
}
/**

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

@ -45,11 +45,8 @@ function setTestPluginEnabledState(newEnabledState, pluginName) {
SpecialPowers.Services.tm.spinEventLoopUntil(() => {
return plugin.enabledState == newEnabledState;
});
SimpleTest.registerCleanupFunction(async function() {
return SpecialPowers.setTestPluginEnabledState(
await oldEnabledState,
pluginName
);
SimpleTest.registerCleanupFunction(function() {
SpecialPowers.setTestPluginEnabledState(oldEnabledState, pluginName);
});
}

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

@ -10,6 +10,11 @@
"use strict";
SimpleTest.waitForExplicitFinish();
function addPerms() {
ok(SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Shockwave Flash"), "Should find allowed test flash plugin");
ok(!SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Third Test Plug-in"), "Should not find disallowed plugin");
SpecialPowers.pushPermissions([{type: "plugin:flash", allow: true, context: document}], run);
}
function findPlugin(pluginName) {
for (var i = 0; i < navigator.plugins.length; i++) {
@ -40,13 +45,7 @@
document.body.appendChild(obj);
}
async function run() {
ok(await SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Shockwave Flash"), "Should find allowed test flash plugin");
ok(!await SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Third Test Plug-in"), "Should not find disallowed plugin");
await new Promise(resolve => {
SpecialPowers.pushPermissions([{type: "plugin:flash", allow: true, context: document}], resolve);
});
function run() {
createNode("plugin-flash", "application/x-shockwave-flash-test");
createNode("disallowedPlugin", "application/x-third-test");
var pluginElement = document.getElementById("plugin-flash");
@ -71,6 +70,6 @@
}
</script>
<body onload="run()">
<body onload="addPerms()">
</body>
</html>

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

@ -19,8 +19,6 @@
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
SimpleTest.waitForExplicitFinish();
SimpleTest.expectChildProcessCrash();
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
@ -91,9 +89,9 @@ function finishTest() {
os.removeObserver(testObserver, "plugin-crashed");
--obsCount;
}
Services.prefs.clearUserPref(hangUITimeoutPref);
Services.prefs.clearUserPref(hangUIMinDisplayPref);
Services.prefs.clearUserPref(timeoutPref);
SpecialPowers.clearUserPref(hangUITimeoutPref);
SpecialPowers.clearUserPref(hangUIMinDisplayPref);
SpecialPowers.clearUserPref(timeoutPref);
SimpleTest.finish();
}
@ -153,9 +151,9 @@ function test9b() {
function test9a() {
resetVars();
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 1);
Services.prefs.setIntPref(timeoutPref, 45);
SpecialPowers.setIntPref(hangUITimeoutPref, 1);
SpecialPowers.setIntPref(hangUIMinDisplayPref, 1);
SpecialPowers.setIntPref(timeoutPref, 45);
hanguiContinue("test9a: Continue button works with checkbox", true, "test9b");
p.stall(STALL_DURATION);
}
@ -167,8 +165,8 @@ function test9() {
function test8a() {
resetVars();
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 4);
SpecialPowers.setIntPref(hangUITimeoutPref, 1);
SpecialPowers.setIntPref(hangUIMinDisplayPref, 4);
hanguiExpect("test8a: Plugin Hang UI is not showing (disabled due to hangUIMinDisplaySecs)", false, false, "test9");
var exceptionThrown = false;
try {
@ -186,7 +184,7 @@ function test8() {
function test7a() {
resetVars();
Services.prefs.setIntPref(hangUITimeoutPref, 0);
SpecialPowers.setIntPref(hangUITimeoutPref, 0);
hanguiExpect("test7a: Plugin Hang UI is not showing (disabled)", false, false, "test8");
var exceptionThrown = false;
try {
@ -203,9 +201,9 @@ function test7() {
}
function test6() {
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 1);
Services.prefs.setIntPref(timeoutPref, 3);
SpecialPowers.setIntPref(hangUITimeoutPref, 1);
SpecialPowers.setIntPref(hangUIMinDisplayPref, 1);
SpecialPowers.setIntPref(timeoutPref, 3);
hanguiExpect("test6: Plugin Hang UI is showing", true, true, "test7");
var exceptionThrown = false;
try {
@ -252,9 +250,9 @@ function test2() {
}
function test1() {
Services.prefs.setIntPref(hangUITimeoutPref, 1);
Services.prefs.setIntPref(hangUIMinDisplayPref, 1);
Services.prefs.setIntPref(timeoutPref, 45);
SpecialPowers.setIntPref(hangUITimeoutPref, 1);
SpecialPowers.setIntPref(hangUIMinDisplayPref, 1);
SpecialPowers.setIntPref(timeoutPref, 45);
hanguiExpect("test1: Plugin Hang UI is showing", true, true, "test2");
p.stall(STALL_DURATION);
}

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

@ -40,14 +40,14 @@ function testSetup() {
function testInitialUnavailable() {
request = new PresentationRequest("https://example.com");
return request.getAvailability().then(async function(aAvailability) {
return request.getAvailability().then(function(aAvailability) {
is(aAvailability.value, false, "Should have no available device after setup");
aAvailability.onchange = function() {
aAvailability.onchange = null;
ok(aAvailability.value, "Device should be available.");
};
availability = aAvailability;
await gScript.sendQuery("trigger-device-add", testDevice);
gScript.sendAsyncMessage("trigger-device-add", testDevice);
}).catch(function(aError) {
ok(false, "Error occurred when getting availability: " + aError);
teardown();

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

@ -65,7 +65,7 @@ let currentMockSocket = null;
function setupMockPushSocket(mockWebSocket) {
currentMockSocket = mockWebSocket;
currentMockSocket._isActive = true;
chromeScript.sendAsyncMessage("socket-setup");
chromeScript.sendSyncMessage("socket-setup");
chromeScript.addMessageListener("socket-client-msg", function(msg) {
mockWebSocket.handleMessage(msg);
});
@ -76,7 +76,7 @@ function teardownMockPushSocket() {
return new Promise(resolve => {
currentMockSocket._isActive = false;
chromeScript.addMessageListener("socket-server-teardown", resolve);
chromeScript.sendAsyncMessage("socket-teardown");
chromeScript.sendSyncMessage("socket-teardown");
});
}
return Promise.resolve();

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

@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=840388
}
var secureTestsStarted = false;
async function checkTestsCompleted() {
function checkTestsCompleted() {
for (var prop in testsToRunInsecure) {
// some test hasn't run yet so we're not done
if (!testsToRunInsecure[prop])
@ -60,7 +60,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=840388
}
//call to change the preferences
counter++;
await SpecialPowers.setBoolPref("security.mixed_content.block_active_content", false);
SpecialPowers.setBoolPref("security.mixed_content.block_active_content", false);
blockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content");
log("blockActive set to "+blockActive+".");
secureTestsStarted = false;

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

@ -64,7 +64,8 @@
return Promise.all(unregisterArray);
}
async function testScopes() {
function testScopes() {
return new Promise(function(resolve, reject) {
function chromeScriptSource() {
let swm = Cc["@mozilla.org/serviceworkers/manager;1"]
.getService(Ci.nsIServiceWorkerManager);
@ -88,8 +89,8 @@
let chromeScript = SpecialPowers.loadChromeScript(chromeScriptSource);
let docPrincipal = SpecialPowers.wrap(document).nodePrincipal.URI.spec;
getScope = async (path) => {
let rv = await chromeScript.sendQuery("getScope", { principal: docPrincipal, path });
getScope = (path) => {
let rv = chromeScript.sendSyncMessage("getScope", { principal: docPrincipal, path })[0][0];
if (rv.exception)
throw rv.exception;
return rv.scope;
@ -104,25 +105,27 @@
return base + s;
}
async function fail(fn) {
function fail(fn) {
try {
await getScope(p("index.html"));
getScope(p("index.html"));
ok(false, "No registration");
} catch(e) {
ok(true, "No registration");
}
}
is(await getScope(p("sub.html")), p("sub"), "Scope should match");
is(await getScope(p("sub/dir.html")), p("sub/dir.html"), "Scope should match");
is(await getScope(p("sub/dir")), p("sub/dir"), "Scope should match");
is(await getScope(p("sub/dir/foo")), p("sub/dir/"), "Scope should match");
is(await getScope(p("sub/dir/afoo")), p("sub/dir/a"), "Scope should match");
is(await getScope(p("star*wars")), p("star*"), "Scope should match");
is(await getScope(p("scope/some_file.html")), p("scope/"), "Scope should match");
await fail("index.html");
await fail("sua.html");
await fail("star/a.html");
is(getScope(p("sub.html")), p("sub"), "Scope should match");
is(getScope(p("sub/dir.html")), p("sub/dir.html"), "Scope should match");
is(getScope(p("sub/dir")), p("sub/dir"), "Scope should match");
is(getScope(p("sub/dir/foo")), p("sub/dir/"), "Scope should match");
is(getScope(p("sub/dir/afoo")), p("sub/dir/a"), "Scope should match");
is(getScope(p("star*wars")), p("star*"), "Scope should match");
is(getScope(p("scope/some_file.html")), p("scope/"), "Scope should match");
fail("index.html");
fail("sua.html");
fail("star/a.html");
resolve();
});
}
function runTest() {

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

@ -47,13 +47,13 @@ let chromeScript = SpecialPowers.loadChromeScript(() => {
});
});
async function onMozillaIFrameLoaded() {
let chromeBuildID = await chromeScript.sendQuery("test:getBuildID");
let chromeBuildID = chromeScript.sendSyncMessage("test:getBuildID")[0][0];
chromeScript.destroy();
ok(+chromeBuildID > LEGACY_BUILD_ID,
`navigator.buildID should be exposed in chrome - got "${chromeBuildID}"`);
function onMozillaIFrameLoaded() {
//
// Access navigator.buildID from mozilla.org.
//

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

@ -8,7 +8,7 @@
<iframe src="about:blank"></iframe>
<script type="text/javascript">
async function checkForFindDialog() {
function checkForFindDialog() {
let chromeScript = SpecialPowers.loadChromeScript(_ => {
addMessageListener("test:check", () => {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
@ -25,7 +25,7 @@
});
let sawFind = await chromeScript.sendQuery("test:check");
let sawFind = chromeScript.sendSyncMessage("test:check")[0][0];
chromeScript.destroy();
return sawFind;
}
@ -67,7 +67,7 @@
"Should return false and not show a dialog if we pass an empty string.");
// Double check to ensure that the parent didn't open a find dialog
let sawWindow = await checkForFindDialog();
let sawWindow = checkForFindDialog();
ok(!sawWindow, "Should never have seen the dialog.");
});
}

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

@ -11,9 +11,7 @@
var SimpleTest = opener.wrappedJSObject.SimpleTest;
var ok = opener.wrappedJSObject.ok;
// Note: We can't use frames[0] here because the type="content" attribute
// isolates it into a separate browsing context hierarchy.
var doc = document.querySelector("iframe").contentDocument;
var doc = frames[0].document;
ok(doc.createElement("body") instanceof HTMLBodyElement,
"Should be instance of HTMLBodyElement");
ok(doc.createElement("div") instanceof HTMLDivElement,

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

@ -34,7 +34,7 @@ window.onload = function() {
myLoadTime = performance.now();
}
SpecialPowers.pushPrefEnv({"set":[["dom.background_loading_iframe", true]]}).then(function () {
SpecialPowers.pushPrefEnv({"set":[["dom.background_loading_iframe", true]]}, function () {
var iframe1 = document.createElement("iframe");
var iframe2 = document.createElement("iframe");
var iframe3 = document.createElement("iframe");

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

@ -3,15 +3,16 @@
var GamepadService;
async function setGamepadPreferenceAndCreateIframe(iframeSrc) {
await SpecialPowers.pushPrefEnv({
set: [["dom.gamepad.test.enabled", true]],
});
function setGamepadPreferenceAndCreateIframe(iframeSrc) {
SpecialPowers.pushPrefEnv(
{ set: [["dom.gamepad.test.enabled", true]] },
() => {
let iframe = document.createElement("iframe");
iframe.src = iframeSrc;
document.body.appendChild(iframe);
}
);
}
function runGamepadTest(callback) {
GamepadService = navigator.requestGamepadServiceTest();

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

@ -43,8 +43,8 @@ function pressButton() {
GamepadService.newButtonEvent(gamepad_index, 0, false, false);
}
async function startTest() {
await SpecialPowers.pushPrefEnv({ "set": [
function startTest() {
SpecialPowers.pushPrefEnv({ "set": [
["dom.gamepad.extensions.enabled", true],
["dom.gamepad.extensions.lightindicator", true],
["dom.gamepad.extensions.multitouch", true]] });

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

@ -52,14 +52,13 @@ function pressButton() {
}
let frames_loaded = 0;
async function startTest() {
function startTest() {
frames_loaded++;
let promise = SpecialPowers.pushPrefEnv({ "set": [
SpecialPowers.pushPrefEnv({ "set": [
["dom.gamepad.extensions.enabled", true],
["dom.gamepad.extensions.lightindicator", true],
["dom.gamepad.extensions.multitouch", true]] });
if (frames_loaded == 2) {
await promise;
// Add a gamepad
GamepadService.addGamepad("test gamepad", // id
GamepadService.standardMapping,

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

@ -93,7 +93,7 @@ function runTest() {
prompt("summary", "text");
info("prompt is closed");
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
SimpleTest.finish();
}

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

@ -17,7 +17,7 @@ async function setup() {
winUtils.advanceTimeAndRefresh(100);
}
async function* runTests() {
function* runTests() {
var e = document.getElementById("edit");
var doc = e.contentDocument;
var win = e.contentWindow;
@ -181,9 +181,9 @@ async function* runTests() {
is(testPageSelectCommand("cmd_selectPageUp", 0), 22 - lineNum, "cmd_selectPageUp");
};
await SpecialPowers.pushPrefEnv({set: [["layout.word_select.eat_space_to_next_word", false]]});
yield SpecialPowers.pushPrefEnv({set: [["layout.word_select.eat_space_to_next_word", false]]});
runSelectionTests(body, 1);
await SpecialPowers.pushPrefEnv({set: [["layout.word_select.eat_space_to_next_word", true]]});
yield SpecialPowers.pushPrefEnv({set: [["layout.word_select.eat_space_to_next_word", true]]});
runSelectionTests(node(2), 0);
}
@ -196,7 +196,7 @@ async function testRunner() {
let curTest = runTests();
while (true) {
winUtils.advanceTimeAndRefresh(100);
if ((await curTest.next()).done) {
if (curTest.next().done) {
break;
}
winUtils.advanceTimeAndRefresh(100);

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

@ -50,7 +50,7 @@ var tests = [
var loadCount = 0;
var script;
var loadListener = async function(evt) {
var loadListener = function(evt) {
if (loadCount == 0) {
/* eslint-env mozilla/frame-script */
script = SpecialPowers.loadChromeScript(function() {
@ -86,7 +86,7 @@ var loadListener = async function(evt) {
hunspell.removeDirectory(de_DE);
});
});
var existenceChecks = await script.sendQuery("check-existence");
var existenceChecks = script.sendSyncMessage("check-existence")[0][0];
is(existenceChecks[0], true, "true expected (en-GB directory should exist)");
is(existenceChecks[1], true, "true expected (en-AU directory should exist)");
is(existenceChecks[2], true, "true expected (de-DE directory should exist)");
@ -124,7 +124,7 @@ function continueTest(evt) {
content.src = "http://mochi.test:8888/tests/editor/spellchecker/tests/bug1200533_subframe.html?firstload=false";
} else {
// Remove the fake dictionaries again, since it's otherwise picked up by later tests.
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
SimpleTest.finish();
}

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

@ -29,7 +29,7 @@ var content = document.getElementById("content");
var firstLoad = true;
var script;
var loadListener = async function(evt) {
var loadListener = function(evt) {
if (firstLoad) {
/* eslint-env mozilla/frame-script */
script = SpecialPowers.loadChromeScript(function() {
@ -53,7 +53,7 @@ var loadListener = async function(evt) {
addMessageListener("en_GB-exists", () => en_GB.exists());
addMessageListener("destroy", () => hunspell.removeDirectory(en_GB));
});
is(await script.sendQuery("en_GB-exists"), true,
is(script.sendSyncMessage("en_GB-exists")[0][0], true,
"true expected (en-GB directory should exist)");
}
@ -97,7 +97,7 @@ var loadListener = async function(evt) {
content.removeEventListener("load", loadListener);
// Remove the fake en-GB dictionary again, since it's otherwise picked up by later tests.
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
// Reset the preference, so the last value we set doesn't collide with the next test.
SimpleTest.finish();

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

@ -34,7 +34,7 @@ var onSpellCheck =
/** Test for Bug 1205983 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async function() {
SimpleTest.waitForFocus(function() {
/* eslint-env mozilla/frame-script */
script = SpecialPowers.loadChromeScript(function() {
// eslint-disable-next-line mozilla/use-services
@ -57,7 +57,7 @@ SimpleTest.waitForFocus(async function() {
addMessageListener("de_DE-exists", () => de_DE.exists());
addMessageListener("destroy", () => hunspell.removeDirectory(de_DE));
});
is(await script.sendQuery("de_DE-exists"), true,
is(script.sendSyncMessage("de_DE-exists")[0][0], true,
"true expected (de_DE directory should exist)");
document.getElementById("de-DE").focus();
@ -106,7 +106,7 @@ function enFocus() {
is(sel.toString(), "German", "one misspelled word expected: German");
// Remove the fake de_DE dictionary again.
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
// Focus again, so the spelling gets updated, but before we need to kill the focus handler.
elem_de.onfocus = null;

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

@ -41,13 +41,13 @@ var onSpellCheck =
"resource://testing-common/AsyncSpellCheckTestHelper.jsm").onSpellCheck;
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async function() {
/* global actorParent */
SimpleTest.waitForFocus(function() {
/* global browserElement */
/* eslint-env mozilla/frame-script */
script = SpecialPowers.loadChromeScript(function() {
var chromeWin = actorParent.rootFrameLoader
.ownerElement.ownerGlobal.docShell
.rootTreeItem.domWindow;
var chromeWin = browserElement.ownerGlobal.docShell
.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow);
var contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
contextMenu.addEventListener("popupshown",
() => sendAsyncMessage("popupshown"));
@ -85,9 +85,9 @@ SimpleTest.waitForFocus(async function() {
addMessageListener("contextMenu-not-null", () => contextMenu != null);
addMessageListener("de_DE-exists", () => de_DE.exists());
});
is(await script.sendQuery("contextMenu-not-null"), true,
is(script.sendSyncMessage("contextMenu-not-null")[0][0], true,
"Got context menu XUL");
is(await script.sendQuery("de_DE-exists"), true,
is(script.sendSyncMessage("de_DE-exists")[0][0], true,
"true expected (de_DE directory should exist)");
script.addMessageListener("popupshown", handlePopup);
@ -117,8 +117,8 @@ SimpleTest.waitForFocus(async function() {
});
});
async function handlePopup() {
var state = await script.sendQuery("hidepopup");
function handlePopup() {
var state = script.sendSyncMessage("hidepopup")[0][0];
is(state, "open", "checking if popup is open");
onSpellCheck(elem_de, function() {
@ -135,7 +135,7 @@ async function handlePopup() {
is(getMisspelledWords(editor_de), "heute" + "ist" + "ein" + "guter", "some misspelled words expected: heute ist ein guter");
// Remove the fake de_DE dictionary again.
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
// This will clear the content preferences and reset "spellchecker.dictionary".
spellchecker.SetCurrentDictionary("");

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

@ -28,7 +28,7 @@ var content = document.getElementById("content");
var firstLoad = true;
var script;
var loadListener = async function(evt) {
var loadListener = function(evt) {
if (firstLoad) {
/* eslint-env mozilla/frame-script */
script = SpecialPowers.loadChromeScript(function() {
@ -52,7 +52,7 @@ var loadListener = async function(evt) {
addMessageListener("en_GB-exists", () => en_GB.exists());
addMessageListener("destroy", () => hunspell.removeDirectory(en_GB));
});
is(await script.sendQuery("en_GB-exists"), true,
is(script.sendSyncMessage("en_GB-exists")[0][0], true,
"true expected (en-GB directory should exist)");
}
@ -89,7 +89,7 @@ var loadListener = async function(evt) {
content.removeEventListener("load", loadListener);
// Remove the fake en-GB dictionary again, since it's otherwise picked up by later tests.
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
// This will clear the content preferences and reset "spellchecker.dictionary".
spellchecker.SetCurrentDictionary("");

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

@ -34,7 +34,7 @@ var onSpellCheck =
/** Test for Bug 697981 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async function() {
SimpleTest.waitForFocus(function() {
/* eslint-env mozilla/frame-script */
script = SpecialPowers.loadChromeScript(function() {
// eslint-disable-next-line mozilla/use-services
@ -57,7 +57,7 @@ SimpleTest.waitForFocus(async function() {
addMessageListener("de_DE-exists", () => de_DE.exists());
addMessageListener("destroy", () => hunspell.removeDirectory(de_DE));
});
is(await script.sendQuery("de_DE-exists"), true,
is(script.sendSyncMessage("de_DE-exists")[0][0], true,
"true expected (de_DE directory should exist)");
document.getElementById("de-DE").focus();
@ -107,7 +107,7 @@ function enFocus() {
is(getMisspelledWords(editor_de), "German", "one misspelled word expected: German");
// Remove the fake de_DE dictionary again.
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
// Focus again, so the spelling gets updated, but before we need to kill the focus handler.
elem_de.onfocus = null;

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

@ -29,7 +29,7 @@ var firstLoad = true;
var expected = "";
var script;
var loadListener = async function(evt) {
var loadListener = function(evt) {
if (firstLoad) {
/* eslint-env mozilla/frame-script */
script = SpecialPowers.loadChromeScript(function() {
@ -53,7 +53,7 @@ var loadListener = async function(evt) {
addMessageListener("en_GB-exists", () => en_GB.exists());
addMessageListener("destroy", () => hunspell.removeDirectory(en_GB));
});
is(await script.sendQuery("en_GB-exists"), true,
is(script.sendSyncMessage("en_GB-exists")[0][0], true,
"true expected (en-GB directory should exist)");
}
@ -90,7 +90,7 @@ var loadListener = async function(evt) {
content.removeEventListener("load", loadListener);
// Remove the fake en-GB dictionary again, since it's otherwise picked up by later tests.
script.sendAsyncMessage("destroy");
script.sendSyncMessage("destroy");
// This will clear the content preferences and reset "spellchecker.dictionary".
spellchecker.SetCurrentDictionary("");

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

@ -513,7 +513,7 @@ async function waitUntilApzStable() {
parentProcessFlush
);
ApzCleanup.register(() => {
waitUntilApzStable.chromeHelper.sendAsyncMessage("cleanup", null);
waitUntilApzStable.chromeHelper.sendSyncMessage("cleanup", null);
waitUntilApzStable.chromeHelper.destroy();
delete waitUntilApzStable.chromeHelper;
});
@ -694,7 +694,9 @@ function getSnapshot(rect) {
});
}
return getSnapshot.chromeHelper.sendQuery("snapshot", JSON.stringify(rect));
return getSnapshot.chromeHelper
.sendSyncMessage("snapshot", JSON.stringify(rect))
.toString();
}
// Takes the document's query string and parses it, assuming the query string

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

@ -33,12 +33,8 @@ function listener(callback) {
/* eslint-env mozilla/frame-script */
function chromeTouchEventCounter(operation) {
function chromeProcessCounter() {
addMessageListener("start", function() {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const PREFIX = "apz:ctec:";
const LISTENERS = {
"start": function() {
var topWin = Services.wm.getMostRecentWindow("navigator:browser");
if (typeof topWin.eventCounts != "undefined") {
dump("Found pre-existing eventCounts object on the top window!\n");
@ -54,18 +50,16 @@ function chromeTouchEventCounter(operation) {
topWin.addEventListener("touchend", topWin.counter, { passive: true });
return true;
},
});
"report": function() {
addMessageListener("report", function() {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var topWin = Services.wm.getMostRecentWindow("navigator:browser");
return JSON.stringify(topWin.eventCounts);
},
"end": function() {
for (let [msg, func] of Object.entries(LISTENERS)) {
Services.ppmm.removeMessageListener(PREFIX + msg, func);
}
});
addMessageListener("end", function() {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var topWin = Services.wm.getMostRecentWindow("navigator:browser");
if (typeof topWin.eventCounts == "undefined") {
dump("The eventCounts object was not found on the top window!\n");
@ -77,12 +71,7 @@ function chromeTouchEventCounter(operation) {
delete topWin.counter;
delete topWin.eventCounts;
return true;
},
};
for (let [msg, func] of Object.entries(LISTENERS)) {
Services.ppmm.addMessageListener(PREFIX + msg, func);
}
});
}
if (typeof chromeTouchEventCounter.chromeHelper == "undefined") {
@ -91,7 +80,7 @@ function chromeTouchEventCounter(operation) {
ApzCleanup.register(function() { chromeTouchEventCounter.chromeHelper.destroy(); });
}
return SpecialPowers.Services.cpmm.sendSyncMessage(`apz:ctec:${operation}`, "")[0];
return chromeTouchEventCounter.chromeHelper.sendSyncMessage(operation, "");
}
// Simple wrapper that waits until the chrome process has seen |count| instances

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

@ -6,4 +6,3 @@ subsuite = gpu
[test_bug509244.html]
[test_bug513439.html]
[test_font_whitelist.html]
skip-if = debug || asan # Race between pref service and gfx platform IPC causes frequent failures on debug/ASan

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

@ -20,8 +20,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1121643
/** Test for Bug 1121643 **/
SimpleTest.requestFlakyTimeout("This test is flaky.");
const InspectorUtils = SpecialPowers.InspectorUtils;
// Given an element id, returns the first font face name encountered.
@ -55,7 +53,6 @@ let testFontWhitelist = async function(useMono, useSans, useSerif) {
}
await SpecialPowers.pushPrefEnv({"set": [["font.system.whitelist",
whitelist.join(", ")]]});
await new Promise(resolve => setTimeout(resolve, 2000));
// If whitelist is empty, then whitelisting is considered disabled
// and all fonts are allowed.
info("font whitelist: " + JSON.stringify(whitelist));

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

@ -13,11 +13,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1124898
/** Test for Bug 1124898 **/
SimpleTest.waitForExplicitFinish();
(async () => {
await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal", true]]});
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
SimpleTest.expectAssertions(0, 1); // Dumb unrelated widget assertion - see bug 1126023.
var w = window.open("about:blank", "w", "chrome");
is(w.eval('typeof getAttention'), 'function', 'getAttention exists on regular chrome window');
is(w.eval('typeof messageManager'), 'object', 'messageManager exists on regular chrome window');
@ -36,7 +34,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1124898
w.close();
SimpleTest.finish();
}
})();
</script>
</head>

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

@ -14,17 +14,14 @@
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
function init() {
var f = new Function("let test = 'let is ok'; return test;");
is(f(), 'let is ok', 'let should be ok');
SimpleTest.finish();
}
(async () => {
await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
Test = {
include: function(p) {
var sawError = false;
@ -45,7 +42,8 @@
// If init is called directly, it works.
setTimeout('init();', 0);
})();
SimpleTest.waitForExplicitFinish();
]]></script>
</window>

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

@ -18,8 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=732665
<script type="application/javascript">
<![CDATA[
add_task(async () => {
await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
//
// Important! If this test starts failing after a tricky platform-y change,
@ -77,7 +76,7 @@ add_task(async () => {
contentSb.nnslChrome = chromeSb.nearNativeStackLimit;
var nestedLimit = Cu.evalInSandbox("nearNativeStackLimit(1, function() { nestedLimit = nnslChrome(0);}); nestedLimit;", contentSb);
ok(nestedLimit >= 11, "Chrome should be invokable from content script with an exhausted stack: " + nestedLimit);
});
]]>
</script>
</window>

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

@ -17,12 +17,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500931
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
add_task(async () => {
var sandbox = new Cu.Sandbox("about:blank");
var test_utils = window.windowUtils;
await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
function getCOW(x) {
@ -225,6 +224,5 @@ try {
todo(false, "COWs should be unwrapped when entering chrome space, " +
"not raise " + e);
}
});
]]></script>
</window>

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

@ -14,10 +14,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1223372
/** Test for Bug 1223372 **/
const {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm");
async function go() {
SimpleTest.waitForExplicitFinish();
await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
function go() {
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
SimpleTest.waitForExplicitFinish();
var frame = $('subframe');
frame.onload = null;

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

@ -18,6 +18,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
<script type="application/javascript">
<![CDATA[
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
/** Test for ES constructors on Xrayed globals. **/
SimpleTest.waitForExplicitFinish();
let global = Cu.getGlobalForObject.bind(Cu);
@ -476,70 +479,73 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
}
// We will need arraysEqual and testArrayIterators both in this global scope
// and in sandboxes.
function arraysEqual(arr1, arr2, reason) {
is(arr1.length, arr2.length, `${reason}; lengths should be equal`)
// and in sandboxes, so define them as strings up front.
var arraysEqualSource = `function arraysEqual(arr1, arr2, reason) {
is(arr1.length, arr2.length, \`\${reason}; lengths should be equal\`)
for (var i = 0; i < arr1.length; ++i) {
if (Array.isArray(arr2[i])) {
arraysEqual(arr1[i], arr2[i], `${reason}; item at index ${i}`);
arraysEqual(arr1[i], arr2[i], \`\${reason}; item at index \${i}\`);
} else {
is(arr1[i], arr2[i], `${reason}; item at index ${i} should be equal`);
}
is(arr1[i], arr2[i], \`\${reason}; item at index \${i} should be equal\`);
}
}
}`;
eval(arraysEqualSource);
var testArrayIteratorsSource = `
function testArrayIterators(arrayLike, equivalentArray, reason) {
arraysEqual([...arrayLike], equivalentArray, `${reason}; spread operator`);
arraysEqual([...arrayLike], equivalentArray, \`\${reason}; spread operator\`);
arraysEqual([...arrayLike.entries()], [...equivalentArray.entries()],
`${reason}; entries`);
\`\${reason}; entries\`);
arraysEqual([...arrayLike.keys()], [...equivalentArray.keys()],
`${reason}; keys`);
\`\${reason}; keys\`);
if (arrayLike.values) {
arraysEqual([...arrayLike.values()], equivalentArray,
`${reason}; values`);
\`\${reason}; values\`);
}
var forEachCopy = [];
arrayLike.forEach(function(arg) { forEachCopy.push(arg); });
arraysEqual(forEachCopy, equivalentArray, `${reason}; forEach copy`);
arraysEqual(forEachCopy, equivalentArray, \`\${reason}; forEach copy\`);
var everyCopy = [];
arrayLike.every(function(arg) { everyCopy.push(arg); return true; });
arraysEqual(everyCopy, equivalentArray, `${reason}; every() copy`);
arraysEqual(everyCopy, equivalentArray, \`\${reason}; every() copy\`);
var filterCopy = [];
var filterResult = arrayLike.filter(function(arg) {
filterCopy.push(arg);
return true;
});
arraysEqual(filterCopy, equivalentArray, `${reason}; filter copy`);
arraysEqual([...filterResult], equivalentArray, `${reason}; filter result`);
arraysEqual(filterCopy, equivalentArray, \`\${reason}; filter copy\`);
arraysEqual([...filterResult], equivalentArray, \`\${reason}; filter result\`);
var findCopy = [];
arrayLike.find(function(arg) { findCopy.push(arg); return false; });
arraysEqual(findCopy, equivalentArray, `${reason}; find() copy`);
arraysEqual(findCopy, equivalentArray, \`\${reason}; find() copy\`);
var findIndexCopy = [];
arrayLike.findIndex(function(arg) { findIndexCopy.push(arg); return false; });
arraysEqual(findIndexCopy, equivalentArray, `${reason}; findIndex() copy`);
arraysEqual(findIndexCopy, equivalentArray, \`\${reason}; findIndex() copy\`);
var mapCopy = [];
var mapResult = arrayLike.map(function(arg) { mapCopy.push(arg); return arg});
arraysEqual(mapCopy, equivalentArray, `${reason}; map() copy`);
arraysEqual([...mapResult], equivalentArray, `${reason}; map() result`);
arraysEqual(mapCopy, equivalentArray, \`\${reason}; map() copy\`);
arraysEqual([...mapResult], equivalentArray, \`\${reason}; map() result\`);
var reduceCopy = [];
arrayLike.reduce(function(_, arg) { reduceCopy.push(arg); }, 0);
arraysEqual(reduceCopy, equivalentArray, `${reason}; reduce() copy`);
arraysEqual(reduceCopy, equivalentArray, \`\${reason}; reduce() copy\`);
var reduceRightCopy = [];
arrayLike.reduceRight(function(_, arg) { reduceRightCopy.unshift(arg); }, 0);
arraysEqual(reduceRightCopy, equivalentArray, `${reason}; reduceRight() copy`);
arraysEqual(reduceRightCopy, equivalentArray, \`\${reason}; reduceRight() copy\`);
var someCopy = [];
arrayLike.some(function(arg) { someCopy.push(arg); return false; });
arraysEqual(someCopy, equivalentArray, `${reason}; some() copy`);
}
arraysEqual(someCopy, equivalentArray, \`\${reason}; some() copy\`);
}`;
eval(testArrayIteratorsSource);
function testDate() {
// toGMTString is handled oddly in the engine. We don't bother to support
@ -794,7 +800,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
// Can create TypedArray from content ArrayBuffer
var buffer = new iwin.ArrayBuffer(8);
new window[c](buffer);
eval(`new ${c}(buffer);`);
var xray = new iwin[c](0);
var xrayTypedArrayProto = Object.getPrototypeOf(Object.getPrototypeOf(xray));
@ -807,8 +813,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
// they'll just run with our principal anyway.
//
// But we do want to export is(), since we want ours called.
wesb.eval(String(arraysEqual));
wesb.eval(String(testArrayIterators));
wesb.eval(arraysEqualSource);
wesb.eval(testArrayIteratorsSource);
Cu.exportFunction(is, wesb,
{ defineAs: "is" });
wesb.eval('testArrayIterators(t, [0, 0, 3, 0, 0, 0, 0, 0, 0, 0])');

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

@ -7,6 +7,7 @@
#include "AccessCheck.h"
#include "nsJSPrincipals.h"
#include "nsDOMWindowList.h"
#include "nsGlobalWindow.h"
#include "XPCWrapper.h"

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

@ -1649,12 +1649,16 @@ bool DOMXrayTraits::resolveOwnProperty(JSContext* cx, HandleObject wrapper,
nsGlobalWindowInner* win = AsWindow(cx, wrapper);
// Note: As() unwraps outer windows to get to the inner window.
if (win) {
Nullable<WindowProxyHolder> subframe = win->IndexedGetter(index);
if (!subframe.IsNull()) {
if (MOZ_UNLIKELY(!WrapObject(cx, subframe.Value(), desc.value()))) {
nsCOMPtr<nsPIDOMWindowOuter> subframe = win->IndexedGetter(index);
if (subframe) {
subframe->EnsureInnerWindow();
nsGlobalWindowOuter* global = nsGlobalWindowOuter::Cast(subframe);
JSObject* obj = global->GetGlobalJSObject();
if (MOZ_UNLIKELY(!obj)) {
// It's gone?
return xpc::Throw(cx, NS_ERROR_FAILURE);
}
desc.value().setObject(*obj);
FillPropertyDescriptor(desc, wrapper, true);
return JS_WrapPropertyDescriptor(cx, desc);
}

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

@ -11,17 +11,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=396024
<iframe src="about:blank" type="content"></iframe>
<script type="application/javascript">
<![CDATA[
// Note: We can't use window.frames directly here because the type="content"
// attributes isolate the frames into their own BrowsingContext hierarchies.
let frameElts = document.getElementsByTagName("iframe");
var is = window.opener.wrappedJSObject.is;
var ok = window.opener.wrappedJSObject.ok;
var todo = window.opener.wrappedJSObject.todo;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
function printpreview() {
gWbp = frameElts[1].contentWindow.docShell.initOrReusePrintPreviewViewer();
gWbp = window.frames[1].docShell.initOrReusePrintPreviewViewer();
var listener = {
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
@ -43,12 +39,12 @@ function printpreview() {
prefs.setBoolPref('print.show_print_progress', false);
//XXX I would have thought this would work, instead I'm forced to use prefs service
gWbp.globalPrintSettings.showPrintProgress = false;
gWbp.printPreview(gWbp.globalPrintSettings, frameElts[0].contentWindow, listener);
gWbp.printPreview(gWbp.globalPrintSettings, window.frames[0], listener);
prefs.clearUserPref('print.show_print_progress');
}
function exitprintpreview() {
frameElts[1].contentWindow.docShell.exitPrintPreview();
window.frames[1].docShell.exitPrintPreview();
}
function finish() {
@ -90,11 +86,11 @@ function run2() {
setTimeout(run3, 0);
};
document.getElementById("i").addEventListener("load", loadhandler, true);
frameElts[0].contentWindow.location.reload();
window.frames[0].location.reload();
}
function run3() {
gWbp = frameElts[1].contentWindow.docShell.initOrReusePrintPreviewViewer();
gWbp = window.frames[1].docShell.initOrReusePrintPreviewViewer();
ok(gWbp.doingPrintPreview, "Should be doing print preview");
exitprintpreview();
setTimeout(run4, 0);
@ -113,7 +109,7 @@ function run4() {
}
function run5() {
gWbp = frameElts[1].contentWindow.docShell.initOrReusePrintPreviewViewer();
gWbp = window.frames[1].docShell.initOrReusePrintPreviewViewer();
ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore2");
//XXX this shouldn't be necessary, see bug 405555

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