Skip to content

Commit

Permalink
Make the wrapAPIs function take the chrome object as a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Jul 1, 2018
1 parent 7ff6e8a commit 2904472
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/browser-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (typeof browser === "undefined") {
// contents of a function until the first time it's called, and since it will
// never actually need to be called, this allows the polyfill to be included
// in Firefox nearly for free.
const wrapAPIs = () => {
const wrapAPIs = extensionAPIs => {
// NOTE: apiMetadata is associated to the content of the api-metadata.json file
// at build time by replacing the following "include" with the content of the
// JSON file.
Expand Down Expand Up @@ -94,8 +94,8 @@ if (typeof browser === "undefined") {
*/
const makeCallback = (promise, metadata) => {
return (...callbackArgs) => {
if (chrome.runtime.lastError) {
promise.reject(chrome.runtime.lastError);
if (extensionAPIs.runtime.lastError) {
promise.reject(extensionAPIs.runtime.lastError);
} else if (metadata.singleCallbackArg || callbackArgs.length === 1) {
promise.resolve(callbackArgs[0]);
} else {
Expand Down Expand Up @@ -445,8 +445,8 @@ if (typeof browser === "undefined") {
});

const wrappedSendMessageCallback = ({reject, resolve}, reply) => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
if (extensionAPIs.runtime.lastError) {
reject(extensionAPIs.runtime.lastError);
} else if (reply && reply.__mozWebExtensionPolyfillReject__) {
// Convert back the JSON representation of the error into
// an Error instance.
Expand Down Expand Up @@ -483,12 +483,12 @@ if (typeof browser === "undefined") {
},
};

return wrapObject(chrome, staticWrappers, apiMetadata);
return wrapObject(extensionAPIs, staticWrappers, apiMetadata);
};

// The build process adds a UMD wrapper around this file, which makes the
// `module` variable available.
module.exports = wrapAPIs(); // eslint-disable-line no-undef
module.exports = wrapAPIs(chrome); // eslint-disable-line no-undef
} else {
module.exports = browser; // eslint-disable-line no-undef
}

0 comments on commit 2904472

Please sign in to comment.