Skip to content

Commit

Permalink
chore(plugin-stealth): Mitigate other occurences of Chromium bug (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
berstend committed Jan 7, 2020
1 parent 6cd17ff commit 0b976f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class Plugin extends PuppeteerExtraPlugin {
const canPlayType = {
// Make toString() native
get(target, key) {
// Mitigate Chromium bug (#130)
if (typeof target[key] === 'function') {
return target[key].bind(target)
}
return Reflect.get(target, key)
},
// Intercept certain requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ class Plugin extends PuppeteerExtraPlugin {

const getParameterProxyHandler = {
get(target, key) {
// There's a slight difference in toString: Our version does not return a named function by default
if (key === 'toString') {
const dummyFn = function toString() {
return target.toString() // `function getParameter() { [native code] }`
}.bind(Function.prototype.toString) // eslint-disable-line
return dummyFn
}
try {
// Mitigate Chromium bug (#130)
if (typeof target[key] === 'function') {
return target[key].bind(target)
}
return Reflect.get(target, key)
} catch (err) {
err.stack = stripErrorStack(err.stack)
Expand Down

0 comments on commit 0b976f1

Please sign in to comment.