Skip to content

Instantly share code, notes, and snippets.

@webmaster128
Last active July 17, 2019 15:17
Show Gist options
  • Save webmaster128/3b0572211cbaf491f3fbc730fd9237c6 to your computer and use it in GitHub Desktop.
Save webmaster128/3b0572211cbaf491f3fbc730fd9237c6 to your computer and use it in GitHub Desktop.
// create some methods in the background script that can be called from the UI
window.getBinary = () => new Uint8Array([1, 2, 3]);
window.getUint8ArrayConstructor = () => Uint8Array;
const binary = chrome.extension.getBackgroundPage().getBinary();
console.log(binary instanceof Uint8Array); // false 🤯
const constructor = chrome.extension.getBackgroundPage().getUint8ArrayConstructor();
console.log(binary instanceof constructor); // true
console.log(constructor === Uint8Array); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment