Commit 3eb7b106 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Chromium LUCI CQ

Add a CDP test that a newly opened window is paused early enough

... for a user-agent override to be applied.

BUG=1070568

Change-Id: Ifba5b72b15d9edd2f14e9a0c7f9860e15fa6f3c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628313
Auto-Submit: Andrey Kosyakov <caseq@chromium.org>
Commit-Queue: Peter Kvitek <kvitekp@chromium.org>
Reviewed-by: default avatarPeter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845002}
parent 1d41c559
Tests that browser.Target.setAutoAttach() attaches to window.open targets.
Opened the window
Attached to window, waitingForDebugger=true
got: User-Agent: Lynx v0.1
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
`Tests that browser.Target.setAutoAttach() attaches to window.open targets.`);
const target = testRunner.browserP().Target;
await target.setDiscoverTargets({discover: true});
await target.setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true, flatten: true});
session.evaluate(`
window.myWindow = window.open('/inspector-protocol/emulation/resources/echo-headers.php');
undefined;
`);
testRunner.log('Opened the window');
const attachedEvent = await target.onceAttachedToTarget();
testRunner.log('Attached to window, waitingForDebugger=' + attachedEvent.params.waitingForDebugger);
const popupSession = new TestRunner.Session(testRunner, attachedEvent.params.sessionId);
const changedPromise = target.onceTargetInfoChanged();
popupSession.protocol.Page.enable();
await popupSession.protocol.Emulation.setUserAgentOverride({userAgent: 'Lynx v0.1'});
popupSession.protocol.Runtime.runIfWaitingForDebugger();
await popupSession.protocol.Page.onceLoadEventFired();
const textContent = await popupSession.evaluate(`document.body.textContent`);
const userAgent = textContent.split('\n').find(line => /^User-Agent:/.test(line));
testRunner.log(`got: ${userAgent}`);
testRunner.completeTest();
})
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