E2E test for report-only CSP issues

New E2E test to verify that the status of the violation is blocked or report-only.

DISABLE_THIRD_PARTY_CHECK=<Introduce report-only field in CDP issues>

Bug: chromium:1139223, chromium:1124712
Change-Id: Ibf01624a069fb83013a8fa162235d307bc3e07ff
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2485086
Commit-Queue: Alfonso Castaño <alcastano@google.com>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
This commit is contained in:
Alfonso Castaño
2020-10-21 13:56:45 +00:00
committed by Commit Bot
parent dd231366a4
commit b60a4fdffc
5 changed files with 48 additions and 1 deletions
+9
View File
@@ -15,6 +15,8 @@ export const AFFECTED_ELEMENT_ICON = '.affected-resource-csp-info-node';
export const ELEMENT_REVEAL_ICON = '.element-reveal-icon';
export const ELEMENTS_PANEL_SELECTOR = '.panel[aria-label="elements"]';
export const SOURCES_LINK = '.affected-source-location > span';
export const BLOCKED_STATUS = '.affected-resource-blocked-status';
export const REPORT_ONLY_STATUS = '.affected-resource-report-only-status';
export async function navigateToIssuesTab() {
await openPanelViaMoreTools('Issues');
@@ -32,6 +34,13 @@ export async function assertIssueTitle(issueMessage: string) {
assert.strictEqual(selectedIssueMessage, issueMessage);
}
export async function assertStatus(status: 'blocked'|'report-only') {
const classStatus = status === 'blocked' ? BLOCKED_STATUS : REPORT_ONLY_STATUS;
const issueMessageElement = await waitFor(classStatus);
const selectedIssueMessage = await issueMessageElement.evaluate(node => node.textContent);
assert.strictEqual(selectedIssueMessage, status);
}
export async function expandCategory() {
const categoryElement = await waitFor(CATEGORY);
const isCategoryExpanded = await categoryElement.evaluate(node => node.classList.contains('expanded'));
+4 -1
View File
@@ -5,7 +5,10 @@
import("../../../third_party/typescript/typescript.gni")
node_ts_library("issues") {
sources = [ "group-by-categories_test.ts" ]
sources = [
"group-by-categories_test.ts",
"report-only_test.ts",
]
deps = [
"../../shared",
+22
View File
@@ -0,0 +1,22 @@
// Copyright 2020 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.
import {goToResource} from '../../shared/helper.js';
import {describe, it} from '../../shared/mocha-extensions.js';
import {assertStatus, expandIssue, navigateToIssuesTab} from '../helpers/issues-helpers.js';
describe('The Issues tab report-only issues', async () => {
it('should report the violation as blocked', async () => {
await goToResource('elements/element-reveal-inline-issue.html');
await navigateToIssuesTab();
await expandIssue();
await assertStatus('blocked');
});
it('should report the violation as report-only', async () => {
await goToResource('network/csp-report-only.rawresponse');
await navigateToIssuesTab();
await expandIssue();
await assertStatus('report-only');
});
});
+1
View File
@@ -7,6 +7,7 @@ import("../../../../scripts/build/ninja/copy.gni")
copy_to_gen("network") {
sources = [
"cacheable.rawresponse",
"csp-report-only.rawresponse",
"last-modified.html",
"last-modified.rawresponse",
"resources-from-cache.html",
@@ -0,0 +1,12 @@
200
Content-Security-Policy-Report-Only: style-src 'self'
Date: Sun, 10 Oct 2010 23:26:07 GMT
Server: Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g
Last-Modified: Sun, 26 Sep 2010 22:04:35 GMT
ETag: "csp-report-only.rawresponse"
Accept-Ranges: bytes
Content-Length: 58
Connection: close
Content-Type: text/html; charset=utf-8
<html><body><img src="" style="width:200px"></body></html>