blob: 4d8d66e52fbcb171ab1c90a7658d9d93c847d695 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
// NOTE: More cases should be tested and addressed by:
// <https://webkit.org/b/152294> Web Inspector: Parse InjectedScriptSource as a built-in to get guaranteed non-user-overriden built-ins
function triggerIteration() {
let callCount = 0;
const originalIterator = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator);
Object.defineProperty(Array.prototype, Symbol.iterator, {
get() {
++callCount;
return originalIterator.value;
}
});
let array = [];
debugger;
// Preview an object.
console.log({a:1, b:2, c:{}});
// Use Array Iterator at least once.
for (let x of array) { }
Object.defineProperty(Array.prototype, Symbol.iterator, originalIterator);
return callCount;
}
function test()
{
let suite = InspectorTest.createAsyncSuite("InjectedScript.Observable");
suite.addTestCase({
name: "InjectedScript.Observable:Array.prototype[Symbol.iterator]",
description: "Array iteration in Injected Script should not be observable",
test(resolve, reject) {
InspectorTest.evaluateInPage(`triggerIteration()`, (error, result) => {
InspectorTest.expectEqual(result, 1, "Array.prototype[Symbol.iterator] call count should be 1.");
resolve();
});
WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Paused, (event) => {
InspectorTest.pass("Paused.");
WI.debuggerManager.resume().catch(reject);
});
WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Resumed, (event) => {
InspectorTest.pass("Resumed.");
});
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Test that certain InjectedScriptSource operations are not observable by user code.</p>
</body>
</html>