Skip to content

Instantly share code, notes, and snippets.

@uhyo
Created July 4, 2018 13:19
Show Gist options
  • Save uhyo/895e91d2b7a4434a8690145f53ee8277 to your computer and use it in GitHub Desktop.
Save uhyo/895e91d2b7a4434a8690145f53ee8277 to your computer and use it in GitHub Desktop.
Firefox EventTarget bug reproduction
console.log('Test 1: raw EventTarget');
const et = new EventTarget();
// add handler of 'foo' event
et.addEventListener('foo', (e)=> {
console.log('foo event emitted:', e.detail);
});
// dispatch 'foo' event
et.dispatchEvent(new CustomEvent('foo', { detail: 123 }));
console.log('Test 2: subclass of EventTarget');
class MyEventTarget extends EventTarget {}
const met = new MyEventTarget();
// add handler of 'foo' event
met.addEventListener('foo', (e)=> {
console.log('foo event emitted:', e.detail);
});
// dispatch 'foo' event
met.dispatchEvent(new CustomEvent('foo', { detail: 456 }));
{
"manifest_version": 2,
"name": "Firefox EventTarget bug reproduction",
"version": "1.0.0",
"description": "sample",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment