Skip to content

Commit f15238d

Browse files
authored
Fixes microsoft#1030 - Add CSP disposition field
1 parent 28298bd commit f15238d

File tree

4 files changed

+120
-5
lines changed

4 files changed

+120
-5
lines changed

baselines/dom.generated.d.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,14 +1693,16 @@ interface ScrollToOptions extends ScrollOptions {
16931693
interface SecurityPolicyViolationEventInit extends EventInit {
16941694
blockedURI?: string;
16951695
columnNumber?: number;
1696-
documentURI?: string;
1697-
effectiveDirective?: string;
1696+
disposition: SecurityPolicyViolationEventDisposition;
1697+
documentURI: string;
1698+
effectiveDirective: string;
16981699
lineNumber?: number;
1699-
originalPolicy?: string;
1700+
originalPolicy: string;
17001701
referrer?: string;
1702+
sample?: string;
17011703
sourceFile?: string;
1702-
statusCode?: number;
1703-
violatedDirective?: string;
1704+
statusCode: number;
1705+
violatedDirective: string;
17041706
}
17051707

17061708
interface ShadowRootInit {
@@ -2620,6 +2622,25 @@ declare var CDATASection: {
26202622
new(): CDATASection;
26212623
};
26222624

2625+
interface CSPViolationReportBody extends ReportBody {
2626+
readonly blockedURL: string | null;
2627+
readonly columnNumber: number | null;
2628+
readonly disposition: SecurityPolicyViolationEventDisposition;
2629+
readonly documentURL: string;
2630+
readonly effectiveDirective: string;
2631+
readonly lineNumber: number | null;
2632+
readonly originalPolicy: string;
2633+
readonly referrer: string | null;
2634+
readonly sample: string | null;
2635+
readonly sourceFile: string | null;
2636+
readonly statusCode: number;
2637+
}
2638+
2639+
declare var CSPViolationReportBody: {
2640+
prototype: CSPViolationReportBody;
2641+
new(): CSPViolationReportBody;
2642+
};
2643+
26232644
/** A single condition CSS at-rule, which consists of a condition and a statement block. It is a child of CSSGroupingRule. */
26242645
interface CSSConditionRule extends CSSGroupingRule {
26252646
conditionText: string;
@@ -14660,11 +14681,13 @@ declare var ScriptProcessorNode: {
1466014681
interface SecurityPolicyViolationEvent extends Event {
1466114682
readonly blockedURI: string;
1466214683
readonly columnNumber: number;
14684+
readonly disposition: SecurityPolicyViolationEventDisposition;
1466314685
readonly documentURI: string;
1466414686
readonly effectiveDirective: string;
1466514687
readonly lineNumber: number;
1466614688
readonly originalPolicy: string;
1466714689
readonly referrer: string;
14690+
readonly sample: string;
1466814691
readonly sourceFile: string;
1466914692
readonly statusCode: number;
1467014693
readonly violatedDirective: string;
@@ -19833,6 +19856,7 @@ type ScrollBehavior = "auto" | "smooth";
1983319856
type ScrollLogicalPosition = "center" | "end" | "nearest" | "start";
1983419857
type ScrollRestoration = "auto" | "manual";
1983519858
type ScrollSetting = "" | "up";
19859+
type SecurityPolicyViolationEventDisposition = "enforce" | "report";
1983619860
type SelectionMode = "end" | "preserve" | "select" | "start";
1983719861
type ServiceWorkerState = "activated" | "activating" | "installed" | "installing" | "parsed" | "redundant";
1983819862
type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";

baselines/webworker.generated.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,21 @@ interface RsaPssParams extends Algorithm {
501501
saltLength: number;
502502
}
503503

504+
interface SecurityPolicyViolationEventInit extends EventInit {
505+
blockedURI?: string;
506+
columnNumber?: number;
507+
disposition: SecurityPolicyViolationEventDisposition;
508+
documentURI: string;
509+
effectiveDirective: string;
510+
lineNumber?: number;
511+
originalPolicy: string;
512+
referrer?: string;
513+
sample?: string;
514+
sourceFile?: string;
515+
statusCode: number;
516+
violatedDirective: string;
517+
}
518+
504519
interface StorageEstimate {
505520
quota?: number;
506521
usage?: number;
@@ -2851,6 +2866,27 @@ declare var Response: {
28512866
redirect(url: string, status?: number): Response;
28522867
};
28532868

2869+
/** Inherits from Event, and represents the event object of an event sent on a document or worker when its content security policy is violated. */
2870+
interface SecurityPolicyViolationEvent extends Event {
2871+
readonly blockedURI: string;
2872+
readonly columnNumber: number;
2873+
readonly disposition: SecurityPolicyViolationEventDisposition;
2874+
readonly documentURI: string;
2875+
readonly effectiveDirective: string;
2876+
readonly lineNumber: number;
2877+
readonly originalPolicy: string;
2878+
readonly referrer: string;
2879+
readonly sample: string;
2880+
readonly sourceFile: string;
2881+
readonly statusCode: number;
2882+
readonly violatedDirective: string;
2883+
}
2884+
2885+
declare var SecurityPolicyViolationEvent: {
2886+
prototype: SecurityPolicyViolationEvent;
2887+
new(type: string, eventInitDict?: SecurityPolicyViolationEventInit): SecurityPolicyViolationEvent;
2888+
};
2889+
28542890
interface ServiceWorkerEventMap extends AbstractWorkerEventMap {
28552891
"statechange": Event;
28562892
}
@@ -5983,6 +6019,7 @@ type RequestMode = "cors" | "navigate" | "no-cors" | "same-origin";
59836019
type RequestRedirect = "error" | "follow" | "manual";
59846020
type ResizeQuality = "high" | "low" | "medium" | "pixelated";
59856021
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
6022+
type SecurityPolicyViolationEventDisposition = "enforce" | "report";
59866023
type ServiceWorkerState = "activated" | "activating" | "installed" | "installing" | "parsed" | "redundant";
59876024
type ServiceWorkerUpdateViaCache = "all" | "imports" | "none";
59886025
type VisibilityState = "hidden" | "visible";
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[Exposed=Window]
2+
interface CSPViolationReportBody : ReportBody {
3+
readonly attribute USVString documentURL;
4+
readonly attribute USVString? referrer;
5+
readonly attribute USVString? blockedURL;
6+
readonly attribute DOMString effectiveDirective;
7+
readonly attribute DOMString originalPolicy;
8+
readonly attribute USVString? sourceFile;
9+
readonly attribute DOMString? sample;
10+
readonly attribute SecurityPolicyViolationEventDisposition disposition;
11+
readonly attribute unsigned short statusCode;
12+
readonly attribute unsigned long? lineNumber;
13+
readonly attribute unsigned long? columnNumber;
14+
};
15+
16+
enum SecurityPolicyViolationEventDisposition {
17+
"enforce", "report"
18+
};
19+
20+
[Exposed=(Window,Worker)]
21+
interface SecurityPolicyViolationEvent : Event {
22+
constructor(DOMString type, optional SecurityPolicyViolationEventInit eventInitDict = {});
23+
readonly attribute USVString documentURI;
24+
readonly attribute USVString referrer;
25+
readonly attribute USVString blockedURI;
26+
readonly attribute DOMString effectiveDirective;
27+
readonly attribute DOMString violatedDirective; // historical alias of effectiveDirective
28+
readonly attribute DOMString originalPolicy;
29+
readonly attribute USVString sourceFile;
30+
readonly attribute DOMString sample;
31+
readonly attribute SecurityPolicyViolationEventDisposition disposition;
32+
readonly attribute unsigned short statusCode;
33+
readonly attribute unsigned long lineNumber;
34+
readonly attribute unsigned long columnNumber;
35+
};
36+
37+
dictionary SecurityPolicyViolationEventInit : EventInit {
38+
required USVString documentURI;
39+
USVString referrer = "";
40+
USVString blockedURI = "";
41+
required DOMString violatedDirective;
42+
required DOMString effectiveDirective;
43+
required DOMString originalPolicy;
44+
USVString sourceFile = "";
45+
DOMString sample = "";
46+
required SecurityPolicyViolationEventDisposition disposition;
47+
required unsigned short statusCode;
48+
unsigned long lineNumber = 0;
49+
unsigned long columnNumber = 0;
50+
};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@
176176
"url": "https://www.w3.org/TR/CSS22/visudet.html",
177177
"title": "CSS2 Visual formatting details"
178178
},
179+
{
180+
"url": "https://www.w3.org/TR/CSP3/",
181+
"title": "Content Security Policy"
182+
},
179183
{
180184
"url": "https://w3c.github.io/deviceorientation/",
181185
"title": "DeviceOrientation Event"

0 commit comments

Comments
 (0)