3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
8 var _originalFunctionCall = Function.prototype.call;
9 var _originalFunctionApply = Function.prototype.apply;
11 var _overriddenFunctionCall = function() {
13 console.error("FAIL: Function.prototype.call should not be called!");
14 var result = _originalFunctionCall.apply(this, arguments);
19 var _overriddenFunctionApply = function(thisArg, argsArray) {
21 console.error("FAIL: Function.prototype.apply should not be called!");
22 var result = _originalFunctionApply.call(this, thisArg, argsArray);
29 Function.prototype.call = _originalFunctionCall;
30 Function.prototype.apply = _originalFunctionApply;
35 Function.prototype.call = _overriddenFunctionCall;
36 Function.prototype.apply = _overriddenFunctionApply;
42 function throwGetter()
44 console.error("FAIL: Should not be called!");
45 throw new Error("FAIL");
48 function testOverriddenArrayPushAndMathMax()
50 Object.defineProperty(Array.prototype, "push", {
53 Object.defineProperty(Math, "max", {
59 function testOverriddenConstructorName()
62 obj.constructor = { name: "foo" };
66 function testThrowConstructorName()
69 Object.defineProperty(obj, "constructor", {
75 function testOverriddenIsFinite()
77 window.isFinite = throwGetter;
87 InspectorTest.runTestSuite([
88 function evaluateInConsole(next)
91 "testOverriddenArrayPushAndMathMax()",
92 "testOverriddenConstructorName()",
93 "testThrowConstructorName()",
94 "testOverriddenIsFinite()"
99 var expr = expressions.shift();
101 InspectorTest.runAfterPendingDispatches(next);
104 InspectorTest.evaluateInConsole(expr, iterate);
109 function testRuntimeAgentCallFunctionOn(next)
111 RuntimeAgent.evaluate("({ a : 1, b : 2 })", step1);
113 function step1(error, result, wasThrown)
117 return this.a + this.b;
119 RuntimeAgent.callFunctionOn(result.objectId, sum.toString(), step2);
122 function step2(error, result, wasThrown)
124 InspectorTest.assertEquals(3, result.value);
129 function dumpConsoleMessages(next)
131 InspectorTest.dumpConsoleMessages();
139 <body onload="runTest()">
141 Tests that overriding global methods (like Array.prototype.push, Math.max) will not break the inspector.