summaryrefslogtreecommitdiffstats
path: root/remote/marionette/driver.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--remote/marionette/driver.sys.mjs52
1 files changed, 38 insertions, 14 deletions
diff --git a/remote/marionette/driver.sys.mjs b/remote/marionette/driver.sys.mjs
index 6b5b1cf082..95b1352ab3 100644
--- a/remote/marionette/driver.sys.mjs
+++ b/remote/marionette/driver.sys.mjs
@@ -29,7 +29,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
MarionettePrefs: "chrome://remote/content/marionette/prefs.sys.mjs",
modal: "chrome://remote/content/shared/Prompt.sys.mjs",
navigate: "chrome://remote/content/marionette/navigate.sys.mjs",
- permissions: "chrome://remote/content/marionette/permissions.sys.mjs",
+ permissions: "chrome://remote/content/shared/Permissions.sys.mjs",
pprint: "chrome://remote/content/shared/Format.sys.mjs",
print: "chrome://remote/content/shared/PDF.sys.mjs",
PromptListener:
@@ -1373,9 +1373,20 @@ GeckoDriver.prototype.switchToFrame = async function (cmd) {
byFrame = el;
}
- const { browsingContext } = await this.getActor({ top }).switchToFrame(
- byFrame || id
- );
+ // If the current context changed during the switchToFrame call, attempt to
+ // call switchToFrame again until the browsing context remains stable.
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=1786640#c11
+ let browsingContext;
+ for (let i = 0; i < 5; i++) {
+ const currentBrowsingContext = this.currentSession.contentBrowsingContext;
+ ({ browsingContext } = await this.getActor({ top }).switchToFrame(
+ byFrame || id
+ ));
+
+ if (currentBrowsingContext == this.currentSession.contentBrowsingContext) {
+ break;
+ }
+ }
this.currentSession.contentBrowsingContext = browsingContext;
};
@@ -3346,22 +3357,16 @@ GeckoDriver.prototype.setPermission = async function (cmd) {
const { descriptor, state, oneRealm = false } = cmd.parameters;
const browsingContext = lazy.assert.open(this.getBrowsingContext());
- // XXX: We currently depend on camera/microphone tests throwing UnsupportedOperationError,
- // the fix is ongoing in bug 1609427.
- if (["camera", "microphone"].includes(descriptor.name)) {
- throw new lazy.error.UnsupportedOperationError(
- "setPermission: camera and microphone permissions are currently unsupported"
- );
- }
+ lazy.permissions.validatePermission(descriptor.name);
- // XXX: Allowing this permission causes timing related Android crash, see also bug 1878741
+ // Bug 1878741: Allowing this permission causes timing related Android crash.
if (descriptor.name === "notifications") {
if (Services.prefs.getBoolPref("notification.prompt.testing", false)) {
// Okay, do nothing. The notifications module will work without permission.
return;
}
throw new lazy.error.UnsupportedOperationError(
- "setPermission: expected notification.prompt.testing to be set"
+ `Setting "descriptor.name" "notifications" expected "notification.prompt.testing" preference to be set`
);
}
@@ -3378,7 +3383,26 @@ GeckoDriver.prototype.setPermission = async function (cmd) {
lazy.assert.boolean(oneRealm);
- lazy.permissions.set(params.type, params.state, oneRealm, browsingContext);
+ if (!lazy.MarionettePrefs.setPermissionEnabled) {
+ throw new lazy.error.UnsupportedOperationError(
+ "'Set Permission' is not available"
+ );
+ }
+
+ let origin = browsingContext.currentURI.prePath;
+
+ // storage-access is a special case.
+ if (descriptor.name === "storage-access") {
+ origin = browsingContext.top.currentURI.prePath;
+
+ params = {
+ type: lazy.permissions.getStorageAccessPermissionsType(
+ browsingContext.currentWindowGlobal.documentURI
+ ),
+ };
+ }
+
+ lazy.permissions.set(params, state, origin);
};
/**