Commit 1c220d51 authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

[DevTools] Add basic tests for Network.*ExtraInfo events

Bug: 849483, 868407
Change-Id: I6ab375a857d248b68122222367ce908cb349b42c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1659528
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680184}
parent 45b9314e
Verifies that navigation requests have their raw headers shown in Network.*ExtraInfo events by checking cookie headers.
Response set-cookie header: name=value; Secure; SameSite=None; HttpOnly
Request cookie header: name=value
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
`Verifies that navigation requests have their raw headers shown in Network.*ExtraInfo events by checking cookie headers.\n`);
await dp.Network.enable();
const setCookieUrl = 'https://cookie.test:8443/inspector-protocol/network/resources/set-cookie-samesitenone.php';
const helloWorldUrl = 'https://cookie.test:8443/inspector-protocol/network/resources/hello-world.html';
const otherDomainUrl = 'https://thirdparty.test:8443/inspector-protocol/network/resources/hello-world.html';
const helper = (await testRunner.loadScript('resources/extra-info-helper.js'))(dp, session);
// set the cookie with a navigation request
const {responseExtraInfo} = await helper.navigateWithExtraInfo(setCookieUrl);
testRunner.log(`Response set-cookie header: ${responseExtraInfo.params.headers['set-cookie']}\n`);
// navigate to a different domain
await helper.navigateWithExtraInfo(otherDomainUrl);
// make a cross origin navigation request to the domain with the cookie
const {requestExtraInfo} = await helper.navigateWithExtraInfo(helloWorldUrl);
testRunner.log(`Request cookie header: ${requestExtraInfo.params.headers['Cookie']}`);
testRunner.completeTest();
})
Verifies that cross origin requests have their raw headers shown in Network.*ExtraInfo events by checking cookie headers.
Response set-cookie header: name=value; Secure; SameSite=None; HttpOnly
Request cookie header: name=value
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
`Verifies that cross origin requests have their raw headers shown in Network.*ExtraInfo events by checking cookie headers.\n`);
await dp.Network.enable();
const setCookieUrl = 'https://cookie.test:8443/inspector-protocol/network/resources/set-cookie-samesitenone.php';
const firstPartyUrl = 'https://cookie.test:8443/inspector-protocol/network/resources/hello-world.html';
const thirdPartyUrl = 'https://thirdparty.test:8443/inspector-protocol/network/resources/hello-world.html';
const helper = (await testRunner.loadScript('resources/extra-info-helper.js'))(dp, session);
// navigate to a third party domain
await helper.navigateWithExtraInfo(thirdPartyUrl);
// set the cookie with a subresource request
const {responseExtraInfo} = await helper.fetchWithExtraInfo(setCookieUrl);
testRunner.log(`Response set-cookie header: ${responseExtraInfo.params.headers['set-cookie']}\n`);
// make a cross origin subresource request to the domain with the cookie
const {requestExtraInfo} = await helper.fetchWithExtraInfo(firstPartyUrl);
testRunner.log(`Request cookie header: ${requestExtraInfo.params.headers['Cookie']}`);
testRunner.completeTest();
})
(function() {
class FetchExtraInfoHelper {
constructor(dp, session) {
this._dp = dp;
this._session = session;
}
async navigateWithExtraInfo(url) {
const requestExtraInfoPromise = this._dp.Network.onceRequestWillBeSentExtraInfo();
const responseExtraInfoPromise = this._dp.Network.onceResponseReceivedExtraInfo();
await this._session.navigate(url);
const requestExtraInfo = await requestExtraInfoPromise;
const responseExtraInfo = await responseExtraInfoPromise;
return {requestExtraInfo, responseExtraInfo};
}
async fetchWithExtraInfo(url) {
const requestExtraInfoPromise = this._dp.Network.onceRequestWillBeSentExtraInfo();
const responseExtraInfoPromise = this._dp.Network.onceResponseReceivedExtraInfo();
await this._session.evaluate(`fetch('${url}', {method: 'POST', credentials: 'include'})`);
const requestExtraInfo = await requestExtraInfoPromise;
const responseExtraInfo = await responseExtraInfoPromise;
return {requestExtraInfo, responseExtraInfo};
}
};
return (dp, session) => {
return new FetchExtraInfoHelper(dp, session);
};
})()
<?php
header('set-cookie: name=value; Secure; SameSite=None; HttpOnly')
?>
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