Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
test for Greasemonkey #1904
// ==UserScript==
// @name callback stubber
// @namespace x
// @include http://localhost/cb.html
// @version 1
// @grant none
// ==/UserScript==
unsafeWindow.cb = function(a) { console.log('script cb', a); }
var obj = {
cb: function(a) { console.log('script obj.cb', a); }
unsafeWindow.obj = obj;
'click', obj.cb, false);
<!DOCTYPE html>
<meta charset="utf-8">
<title>Content Callback Test</title>
<button onclick="cb('direct')">Direct Call</button><br>
<button onclick="obj.cb('direct')">Direct Call (obj)</button></br>
<button id="event1">Event Listener</button><br>
<button id="event2">Event Listener (obj)</button><br>
function cb(a) {
console.log('in-page cb', a);
var obj = {
cb: function(a) {
console.log('in-page obj.cb', a);
'click', cb, false);
'click', obj.cb, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.