diff options
Diffstat (limited to '')
3 files changed, 96 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h-kill.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h-kill.js new file mode 100644 index 0000000000..60b418023f --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h-kill.js @@ -0,0 +1,59 @@ +// This methods allows the killing of built-in functions, +// so the shim can take over with that implementation +var HLP = (function() { + "use strict"; + var kill; + + kill = function(_class, methods) { + /*if(!Array.isArray(methods)) + return;*/ + if(!_class.originals) + _class.originals = {}; + + for (var i = 0, len = methods.length; i < len; i++) { + var obj = methods[i]; + _class.originals[obj] = _class[obj]; + delete _class[obj]; + if (obj in _class) { + // try something more aggressive since V8 at least + // appears to ignore the delete. + _class[obj] = null; + if (_class[obj]) { + console.log("Couln't overwrite", obj, "of", _class); + } + } + } + }; + return { kill: kill }; +}()); + +HLP.kill(Function.prototype, [ + 'bind' +]); + +HLP.kill(Array, [ + 'isArray' +]); + +HLP.kill(String.prototype, [ + "trim" +]); + +HLP.kill(Object, [ + 'keys' +]); + +HLP.kill(Date, [ + 'now', 'parse' +]); + +HLP.kill(Date.prototype, [ + "toJSON", "toISOString" +]); + +HLP.kill(Array.prototype, [ + 'forEach', 'some', 'every', + 'indexOf', 'lastIndexOf', + 'map', 'filter', + 'reduce', 'reduceRight' +]); diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h-matchers.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h-matchers.js new file mode 100644 index 0000000000..dda7513a5f --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h-matchers.js @@ -0,0 +1,34 @@ +beforeEach(function() { + this.addMatchers({ + toExactlyMatch: function(expected) { + var a1, a2, + l, i, + key, + actual = this.actual; + + var getKeys = function(o) { + var a = []; + for(key in o) { + if(o.hasOwnProperty(key)) { + a.push(key); + } + } + return a; + } + a1 = getKeys(actual); + a2 = getKeys(expected); + + l = a1.length; + if(l !== a2.length) { + return false; + } + for(i = 0; i < l; i++) { + key = a1[i]; + expect(key).toEqual(a2[i]); + expect(actual[key]).toEqual(expected[key]); + } + + return true; + } + }) +}); diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h.js new file mode 100644 index 0000000000..ede51ef673 --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/components/es5-shim/tests/helpers/h.js @@ -0,0 +1,3 @@ +function implement() { + throw 'Not implemented'; +}
\ No newline at end of file |