Skip to content

Commit

Permalink
WIP zoom ing in on #640
Browse files Browse the repository at this point in the history
  • Loading branch information
Domiii committed Jan 11, 2022
1 parent 12445cc commit e4965a7
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion samples/__samplesInput__/patching/callbacks0.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
/**
* Test basic callback identity properties when dynamic callback patcher is involved.
*/

const assert = require('tools/assertCallbacks');

function cb() {
console.log('cb!');
}

var storedCb;

/**
* dbux disable
*/
function nativeCallStore(cb) {
assert.patched(cb);
storedCb = cb;
}

/**
* dbux disable
*/
function nativeCallCompare(cb) {
assert.patched(cb);
console.assert(cb === storedCb, '❌ Same callback passed in twice -> should be the same.');
}

(async function main() {
setTimeout(cb, 50);

assert.not.patched(cb);
assert.patched(Array.prototype.slice);


/**
* Call function with same cb twice:
* -> it should be recognized as the same cb, or else `removeEventListener`
* and many other callback management mechanisms cannot work correctly.
*/
nativeCallStore(cb);
nativeCallCompare(cb);

// TODO: more testing here, with checks for multi-patching
})();

0 comments on commit e4965a7

Please sign in to comment.