Commit 955ac63c authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Add a test for sessions to headless_browsertests.

This test was originally part of
https://chromium-review.googlesource.com/c/chromium/src/+/1783717
and added there because the earlier version of the change
introduced a regression; but the test seems worthwhile
regardless of where we do the session id surgery and I figure
we may as well submit the test now.

Change-Id: If7935aa4b4d46f898233d8cee9cadca0b7835f06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845669Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703904}
parent 3cdeb5dc
Tests headless session basics.
SUCCESS: Target.createTarget returned sessionId.
// Copyright 2019 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) {
testRunner.log('Tests headless session basics.\n');
// HeadlessDevToolsSession handles Target.createTarget. So, it's responsible
// for adding the sessionId into its return value. This test uses the
// low-level browser protocol connection, attached to a browser target,
// and creates a browser context. In the subsequent Target.createTarget
// call, we observe that the return value carries the expected sessionId.
testRunner.browserP().Target.attachToBrowserTarget();
const sessionId =
(await testRunner.browserP().Target.onceAttachedToTarget())
.params.sessionId;
const session = new TestRunner.Session(testRunner, sessionId);
const browserContextId =
(await session.protocol.Target.createBrowserContext()).browserContextId;
const returnValue = (await session.protocol.Target.createTarget({
'browserContextId': browserContextId,
'enableBeginFrameControl': true, 'height': 1, 'url': 'about:blank',
'width': 1}));
// If HeadlessDevToolsSession fails to put the sessionId into the response,
// this log line will be missing.
if (returnValue.sessionId && returnValue.sessionId.length > 0) {
testRunner.log('SUCCESS: Target.createTarget returned sessionId.\n');
}
testRunner.completeTest();
})
......@@ -264,6 +264,9 @@ HEADLESS_PROTOCOL_TEST(MAYBE_VirtualTimeTimerSuspend,
#undef MAYBE_VirtualTimeTimerOrder
#undef MAYBE_VirtualTimeTimerSuspend
HEADLESS_PROTOCOL_TEST(HeadlessSessionBasicsTest,
"sessions/headless-session-basics.js")
class HeadlessProtocolCompositorBrowserTest
: public HeadlessProtocolBrowserTest {
public:
......
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