Created
April 14, 2017 19:53
-
-
Save Treora/7eb7aaf0fa73ca4c92f0db58b47cd4c9 to your computer and use it in GitHub Desktop.
Returning a Promise of a BlockingRequest object does not work if the Promise object is provided by babel-runtime (Firefox 52.0.2). When using background-source.js instead of background.js in manifest.json redirection of example.org does work fine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function failingListener() { | |
return Promise.resolve({ | |
redirectUrl: 'http://mozilla.org' | |
}) | |
} | |
function functioningListener() { | |
return { | |
redirectUrl: 'http://mozilla.org' | |
} | |
} | |
browser.webRequest.onBeforeRequest.addListener( | |
functioningListener, | |
{urls: ['*://*.example.com/*']}, | |
['blocking'] | |
) | |
browser.webRequest.onBeforeRequest.addListener( | |
failingListener, | |
{urls: ['*://*.example.org/*']}, | |
['blocking'] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "PromiseRedirectTest", | |
"version": "1.0", | |
"background": { | |
"scripts": ["background.js"] | |
}, | |
"permissions": [ | |
"<all_urls>", | |
"webRequest", | |
"webRequestBlocking" | |
], | |
"manifest_version": 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "PromiseRedirectTest", | |
"version": "1.0.0", | |
"description": "", | |
"scripts": { | |
"build": "browserify -o background.js background-source.js" | |
}, | |
"devDependencies": { | |
"babel-plugin-transform-regenerator": "^6.24.1", | |
"babel-plugin-transform-runtime": "^6.23.0", | |
"babel-preset-es2015": "^6.24.1", | |
"babelify": "^7.3.0", | |
"browserify": "^14.3.0" | |
}, | |
"dependencies": { | |
"babel-runtime": "^6.23.0" | |
}, | |
"browserify": { | |
"transform": [ | |
[ | |
"babelify", | |
{ | |
"presets": [ | |
"es2015" | |
], | |
"plugins": ["transform-regenerator", "transform-runtime"] | |
} | |
] | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment