From aa8e92e9a57b344a9502305014aabfde8603d51f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 6 Nov 2013 08:51:16 -0800 Subject: [PATCH] Update qunit-clib to avoid issues with non-writable `context.clearTimeout`. --- test/test.js | 2 +- vendor/qunit-clib/qunit-clib.js | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/test.js b/test/test.js index 95d36e583..e2bb99cf5 100644 --- a/test/test.js +++ b/test/test.js @@ -1531,7 +1531,7 @@ } }); - asyncTest('should call `trailing` with the correct `arguments` and `this` binding', 2, function() { + asyncTest('should execute the `trailing` call with the correct arguments and `this` binding', 2, function() { if (!(isRhino && isModularize)) { var args, count = 0, diff --git a/vendor/qunit-clib/qunit-clib.js b/vendor/qunit-clib/qunit-clib.js index 61439a671..f6e1c20b6 100644 --- a/vendor/qunit-clib/qunit-clib.js +++ b/vendor/qunit-clib/qunit-clib.js @@ -309,10 +309,23 @@ slice = Array.prototype.slice, timer = new java.util.Timer; - context.clearInterval = - context.clearTimeout = clearTimer; - context.setInterval = setInterval; - context.setTimeout = setTimeout; + (function() { + var getDescriptor = Object.getOwnPropertyDescriptor || function() { + return { 'writable': true }; + }; + + var descriptor; + if ((!context.clearInterval || ((descriptor = getDescriptor(context, 'clearInterval')) && (descriptor.writable || descriptor.set))) && + (!context.setInterval || ((descriptor = getDescriptor(context, 'setInterval')) && (descriptor.writable || descriptor.set)))) { + context.clearInterval = clearTimer; + context.setInterval = setInterval; + } + if ((!context.clearTimeout || ((descriptor = getDescriptor(context, 'clearTimeout')) && (descriptor.writable || descriptor.set))) && + (!context.setTimeout || ((descriptor = getDescriptor(context, 'setTimeout')) && (descriptor.writable || descriptor.set)))) { + context.clearTimeout = clearTimer; + context.setTimeout = setTimeout; + } + }()); } catch(e) { } // expose shortcuts