mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
browser(firefox): fix addBinding on pages with CSP (#6470)
This commit is contained in:
parent
2d4538c23d
commit
f1a65820f4
@ -1,2 +1,2 @@
|
||||
1246
|
||||
Changed: pavel.feldman@gmail.com Fri 07 May 2021 09:10:22 PM PDT
|
||||
1247
|
||||
Changed: dgozman@gmail.com Sat May 8 17:46:11 PDT 2021
|
||||
|
||||
@ -471,7 +471,18 @@ class Frame {
|
||||
}, this.domWindow(), {
|
||||
defineAs: name,
|
||||
});
|
||||
this.domWindow().eval(script);
|
||||
if (this._executionContext)
|
||||
this._evaluateScriptSafely(this._executionContext, script);
|
||||
}
|
||||
|
||||
_evaluateScriptSafely(executionContext, script) {
|
||||
try {
|
||||
let result = executionContext.evaluateScript(script);
|
||||
if (result && result.objectId)
|
||||
executionContext.disposeObject(result.objectId);
|
||||
} catch (e) {
|
||||
dump(`ERROR: ${e.message}\n${e.stack}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
_onGlobalObjectCleared() {
|
||||
@ -489,27 +500,15 @@ class Frame {
|
||||
});
|
||||
for (const [name, script] of this._frameTree._bindings)
|
||||
this._addBinding(name, script);
|
||||
for (const script of this._frameTree._scriptsToEvaluateOnNewDocument.values()) {
|
||||
try {
|
||||
const result = this._executionContext.evaluateScript(script);
|
||||
if (result && result.objectId)
|
||||
this._executionContext.disposeObject(result.objectId);
|
||||
} catch (e) {
|
||||
dump(`ERROR: ${e.message}\n${e.stack}\n`);
|
||||
}
|
||||
}
|
||||
for (const script of this._frameTree._scriptsToEvaluateOnNewDocument.values())
|
||||
this._evaluateScriptSafely(this._executionContext, script);
|
||||
|
||||
for (const world of this._isolatedWorlds.values())
|
||||
this._runtime.destroyExecutionContext(world);
|
||||
this._isolatedWorlds.clear();
|
||||
for (const {script, worldName} of this._frameTree._isolatedWorlds.values()) {
|
||||
const context = worldName ? this.createIsolatedWorld(worldName) : this.executionContext();
|
||||
try {
|
||||
let result = context.evaluateScript(script);
|
||||
if (result && result.objectId)
|
||||
context.disposeObject(result.objectId);
|
||||
} catch (e) {
|
||||
}
|
||||
this._evaluateScriptSafely(context, script);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
1256
|
||||
Changed: pavel.feldman@gmail.com Fri 07 May 2021 09:00:05 PM PDT
|
||||
1257
|
||||
Changed: dgozman@gmail.com Sat May 8 17:46:11 PDT 2021
|
||||
|
||||
@ -471,7 +471,18 @@ class Frame {
|
||||
}, this.domWindow(), {
|
||||
defineAs: name,
|
||||
});
|
||||
this.domWindow().eval(script);
|
||||
if (this._executionContext)
|
||||
this._evaluateScriptSafely(this._executionContext, script);
|
||||
}
|
||||
|
||||
_evaluateScriptSafely(executionContext, script) {
|
||||
try {
|
||||
let result = executionContext.evaluateScript(script);
|
||||
if (result && result.objectId)
|
||||
executionContext.disposeObject(result.objectId);
|
||||
} catch (e) {
|
||||
dump(`ERROR: ${e.message}\n${e.stack}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
_onGlobalObjectCleared() {
|
||||
@ -489,27 +500,15 @@ class Frame {
|
||||
});
|
||||
for (const [name, script] of this._frameTree._bindings)
|
||||
this._addBinding(name, script);
|
||||
for (const script of this._frameTree._scriptsToEvaluateOnNewDocument.values()) {
|
||||
try {
|
||||
const result = this._executionContext.evaluateScript(script);
|
||||
if (result && result.objectId)
|
||||
this._executionContext.disposeObject(result.objectId);
|
||||
} catch (e) {
|
||||
dump(`ERROR: ${e.message}\n${e.stack}\n`);
|
||||
}
|
||||
}
|
||||
for (const script of this._frameTree._scriptsToEvaluateOnNewDocument.values())
|
||||
this._evaluateScriptSafely(this._executionContext, script);
|
||||
|
||||
for (const world of this._isolatedWorlds.values())
|
||||
this._runtime.destroyExecutionContext(world);
|
||||
this._isolatedWorlds.clear();
|
||||
for (const {script, worldName} of this._frameTree._isolatedWorlds.values()) {
|
||||
const context = worldName ? this.createIsolatedWorld(worldName) : this.executionContext();
|
||||
try {
|
||||
let result = context.evaluateScript(script);
|
||||
if (result && result.objectId)
|
||||
context.disposeObject(result.objectId);
|
||||
} catch (e) {
|
||||
}
|
||||
this._evaluateScriptSafely(context, script);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user