Commit 7d9a2a8a authored by Will Chen's avatar Will Chen Committed by Commit Bot

DevTools: observe secondary window (inspected page) to replicate test config

I discovered this because animation frames weren't being executed since the
test config wasn't properly replicated in the test_runner for secondary renderer.

Previously in the old test harness, this worked because DevTools was the
secondary window and LayoutTestDevToolsBindings observes the DevTools window and
implements RenderFrameCreated.

This includes a test that we previously couldn't migrate because rAF was never called.

Bug: 667560
Change-Id: I286f27af3e4b87ffff368f2284a9a3b373e9b269
Reviewed-on: https://chromium-review.googlesource.com/764853
Commit-Queue: Will Chen <chenwilliam@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516087}
parent 037fa7a4
......@@ -50,6 +50,11 @@ class LayoutTestDevToolsBindings::SecondaryObserver
bindings_ = nullptr;
}
// WebContentsObserver implementation.
void RenderFrameCreated(RenderFrameHost* render_frame_host) override {
BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host);
}
private:
LayoutTestDevToolsBindings* bindings_;
DISALLOW_COPY_AND_ASSIGN(SecondaryObserver);
......@@ -143,12 +148,12 @@ LayoutTestDevToolsBindings::LayoutTestDevToolsBindings(
SetPreferences(settings);
if (new_harness) {
secondary_observer_ = base::MakeUnique<SecondaryObserver>(this);
NavigationController::LoadURLParams params(
GetInspectedPageURL(frontend_url));
params.transition_type = ui::PageTransitionFromInt(
ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
inspected_contents->GetController().LoadURLWithParams(params);
secondary_observer_ = base::MakeUnique<SecondaryObserver>(this);
} else {
NavigateDevToolsFrontend();
}
......
......@@ -3,66 +3,66 @@ Tests asynchronous call stacks in debugger.
Set timer for test function.
Captured call stacks in no particular order:
Call stack:
0) animFrame1 (async-callstack.html:30)
0) animFrame1 (async-callstack.js:34)
[requestAnimationFrame]
0) timeout1 (async-callstack.html:19)
1) innerTestFunction (async-callstack.html:11)
0) timeout1 (async-callstack.js:22)
1) innerTestFunction (async-callstack.js:14)
[setTimeout]
0) testFunction (async-callstack.html:13)
0) testFunction (async-callstack.js:16)
[setTimeout]
0) scheduleTestFunction <omitted>
<... skipped remaining frames ...>
Call stack:
0) animFrame2 (async-callstack.html:47)
0) animFrame2 (async-callstack.js:51)
[requestAnimationFrame]
0) animFrame1 (async-callstack.html:32)
0) animFrame1 (async-callstack.js:36)
[requestAnimationFrame]
0) timeout1 (async-callstack.html:19)
1) innerTestFunction (async-callstack.html:11)
0) timeout1 (async-callstack.js:22)
1) innerTestFunction (async-callstack.js:14)
[setTimeout]
0) testFunction (async-callstack.html:13)
0) testFunction (async-callstack.js:16)
[setTimeout]
0) scheduleTestFunction <omitted>
<... skipped remaining frames ...>
Call stack:
0) interval1 (async-callstack.html:37)
1) innerInterval1 (async-callstack.html:24)
0) interval1 (async-callstack.js:41)
1) innerInterval1 (async-callstack.js:27)
[setInterval]
0) timeout1 (async-callstack.html:20)
1) innerTestFunction (async-callstack.html:11)
0) timeout1 (async-callstack.js:23)
1) innerTestFunction (async-callstack.js:14)
[setTimeout]
0) testFunction (async-callstack.html:13)
0) testFunction (async-callstack.js:16)
[setTimeout]
0) scheduleTestFunction <omitted>
<... skipped remaining frames ...>
Call stack:
0) timeout1 (async-callstack.html:18)
1) innerTestFunction (async-callstack.html:11)
0) timeout1 (async-callstack.js:21)
1) innerTestFunction (async-callstack.js:14)
[setTimeout]
0) testFunction (async-callstack.html:13)
0) testFunction (async-callstack.js:16)
[setTimeout]
0) scheduleTestFunction <omitted>
<... skipped remaining frames ...>
Call stack:
0) timeout2 (async-callstack.html:42)
0) timeout2 (async-callstack.js:46)
[setTimeout]
0) animFrame1 (async-callstack.html:31)
0) animFrame1 (async-callstack.js:35)
[requestAnimationFrame]
0) timeout1 (async-callstack.html:19)
1) innerTestFunction (async-callstack.html:11)
0) timeout1 (async-callstack.js:22)
1) innerTestFunction (async-callstack.js:14)
[setTimeout]
0) testFunction (async-callstack.html:13)
0) testFunction (async-callstack.js:16)
[setTimeout]
0) scheduleTestFunction <omitted>
<... skipped remaining frames ...>
Call stack:
0) timeout3 (async-callstack.html:61)
1) longTail0 (async-callstack.html:50)
0) timeout3 (async-callstack.js:65)
1) longTail0 (async-callstack.js:54)
[setTimeout]
0) longTail1 (:1)
[setTimeout]
......@@ -105,14 +105,14 @@ Call stack:
0) longTail20 (:20)
[setTimeout]
0) (:21)
1) animFrame2 (async-callstack.html:56)
1) animFrame2 (async-callstack.js:60)
[requestAnimationFrame]
0) animFrame1 (async-callstack.html:32)
0) animFrame1 (async-callstack.js:36)
[requestAnimationFrame]
0) timeout1 (async-callstack.html:19)
1) innerTestFunction (async-callstack.html:11)
0) timeout1 (async-callstack.js:22)
1) innerTestFunction (async-callstack.js:14)
[setTimeout]
0) testFunction (async-callstack.html:13)
0) testFunction (async-callstack.js:16)
[setTimeout]
0) scheduleTestFunction <omitted>
<... skipped remaining frames ...>
......
<html>
<head>
<script src="../../../inspector/inspector-test.js"></script>
<script src="../../../inspector/debugger-test.js"></script>
<script>
function testFunction()
{
function innerTestFunction()
{
timeout1();
}
setTimeout(innerTestFunction, 0);
}
function timeout1()
{
debugger;
requestAnimationFrame(animFrame1);
var id = setInterval(innerInterval1, 0);
function innerInterval1()
{
clearInterval(id);
interval1();
}
}
function animFrame1()
{
debugger;
setTimeout(timeout2, 0);
requestAnimationFrame(animFrame2);
}
function interval1()
{
debugger;
}
function timeout2()
{
debugger;
}
function animFrame2()
{
debugger;
function longTail0()
{
timeout3();
}
var funcs = [];
for (var i = 0; i < 20; ++i)
funcs.push("function longTail" + (i + 1) + "() { setTimeout(longTail" + i + ", 0); };");
funcs.push("setTimeout(longTail" + i + ", 0);");
eval(funcs.join("\n"));
}
function timeout3()
{
debugger;
}
var test = function() {
var totalDebuggerStatements = 6;
SourcesTestRunner.runAsyncCallStacksTest(totalDebuggerStatements);
};
</script>
</head>
<body onload="runTest()">
<p>
Tests asynchronous call stacks in debugger.
</p>
</body>
</html>
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests asynchronous call stacks in debugger.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.showPanel('sources');
await TestRunner.evaluateInPagePromise(`
function testFunction()
{
function innerTestFunction()
{
timeout1();
}
setTimeout(innerTestFunction, 0);
}
function timeout1()
{
debugger;
requestAnimationFrame(animFrame1);
var id = setInterval(innerInterval1, 0);
function innerInterval1()
{
clearInterval(id);
interval1();
}
}
function animFrame1()
{
console.log('animFrame1');
debugger;
setTimeout(timeout2, 0);
requestAnimationFrame(animFrame2);
}
function interval1()
{
debugger;
}
function timeout2()
{
debugger;
}
function animFrame2()
{
debugger;
function longTail0()
{
timeout3();
}
var funcs = [];
for (var i = 0; i < 20; ++i)
funcs.push("function longTail" + (i + 1) + "() { setTimeout(longTail" + i + ", 0); };");
funcs.push("setTimeout(longTail" + i + ", 0);");
eval(funcs.join("\\n"));
}
function timeout3()
{
debugger;
}
`);
var totalDebuggerStatements = 6;
SourcesTestRunner.runAsyncCallStacksTest(totalDebuggerStatements);
})();
Tests that debugger pause button works on Elements panel after a DOM node highlighting. Chromium bug 433366
Call stack:
0) callback (pause-on-elements-panel.js:18)
0) callback (pause-on-elements-panel.js:20)
PASS: Debugger paused.
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