Commit 41b43609 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[DevTools] Handle navigation in console.log

BUG=642496
R=dgozman@chromium.org

Committed: https://crrev.com/37faa2db833127ac9b6d461d8bc49952e557c743
Review-Url: https://codereview.chromium.org/2318853002
Cr-Original-Commit-Position: refs/heads/master@{#417958}
Cr-Commit-Position: refs/heads/master@{#422802}
parent 1c5204b6
<script>
function navigate()
{
anchor = document.createElement("a");
anchor.href = "about:blank";
anchor.click();
}
var a = new Date();
a.toString = () => navigate();
console.log(42, a);
</script>
\ No newline at end of file
<script>
function navigate()
{
anchor = document.createElement("a");
anchor.href = "about:blank";
anchor.click();
}
function logArray()
{
array = [];
array.__defineGetter__(0, () => navigate());
console.log(array);
}
function logDate()
{
var a = new Date();
a.toString = () => navigate();
console.log(a);
}
function logDateWithArg()
{
var a = new Date();
a.toString = () => navigate();
console.log(42, a);
}
</script>
\ No newline at end of file
CONSOLE MESSAGE: line 10: 42
CONSOLE MESSAGE: line 13:
CONSOLE MESSAGE: line 20: undefined
CONSOLE MESSAGE: line 27: 42
This tests how navigation is handled from inside debugger code (console.log).
{
error : {
code : -32000
message : Cannot find context with specified id
}
id : 0
}
{
error : {
code : -32000
message : Cannot find context with specified id
}
id : 0
}
{
error : {
code : -32000
message : Cannot find context with specified id
}
id : 0
}
<!doctype html>
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>
function appendIframe()
{
var frame = document.createElement("iframe");
frame.src = "resources/console-log-navigate.html";
document.body.appendChild(frame);
return new Promise((resolve) => frame.onload = resolve);
}
function createIframeAndRunTest()
{
var frame = document.createElement("iframe");
frame.id = "iframe";
frame.src = "resources/console-log-navigate-on-load.html";
frame.onload = () => runTest();
document.body.appendChild(frame);
}
function test()
{
InspectorTest.sendCommandPromise("Runtime.enable", {})
.then(() => checkExpression("logArray()"))
.then(() => checkExpression("logDate()"))
.then(() => checkExpression("logDateWithArg()"))
.then(() => InspectorTest.completeTest());
function checkExpression(expression)
{
var contextId;
InspectorTest.waitForEventPromise("Runtime.executionContextCreated")
.then((result) => contextId = result.params.context.id);
return InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: "appendIframe()", awaitPromise: true})
.then(() => InspectorTest.sendCommandPromise("Runtime.evaluate", { expression: expression, contextId: contextId }))
.then((r) => logObject(r));
}
function logObject(result)
{
result.id = 0;
InspectorTest.logObject(result);
}
}
</script>
</head>
<body onload="createIframeAndRunTest()">
This tests how navigation is handled from inside debugger code (console.log).
</body>
</html>
CONSOLE MESSAGE: line 13:
CONSOLE MESSAGE: line 20: undefined
CONSOLE MESSAGE: line 27: 42
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment