Commit 5bc9086c authored by mkwst@chromium.org's avatar mkwst@chromium.org

SRI: Add the 'integrity' attribute, and a SubresourceIntegrity runtime flag.

This patch adds a new flag to begin experimentation with the Subresource
Integrity specification[1], and begins adding the minimal amount of
functionality so we can test that the flag is working. That turns out to
be the 'integrity' attribute on various HTML elements that we'll use
later in order to do the actual verification.

Intent to Implement at [2].

[1]: http://w3c.github.io/webappsec/specs/subresourceintegrity/
[2]: https://groups.google.com/a/chromium.org/d/msg/blink-dev/hTDUpMk_TV8/t_rjlkKfgGgJ

BUG=355467

Review URL: https://codereview.chromium.org/208423011

git-svn-id: svn://svn.chromium.org/blink/trunk@170313 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f9297724
...@@ -15,6 +15,7 @@ data ...@@ -15,6 +15,7 @@ data
declare declare
form form
hspace hspace
integrity
standby standby
type type
useMap useMap
...@@ -24,6 +25,7 @@ vspace ...@@ -24,6 +25,7 @@ vspace
willValidate willValidate
---------- ----------
EMBED also has: EMBED also has:
integrity
src src
type type
---------- ----------
......
Some elements should have `integrity` attributes. Others shouldn't.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS <a> has an 'integrity' attribute.
PASS <audio> has an 'integrity' attribute.
PASS <embed> has an 'integrity' attribute.
PASS <iframe> has an 'integrity' attribute.
PASS <img> has an 'integrity' attribute.
PASS <link> has an 'integrity' attribute.
PASS <object> has an 'integrity' attribute.
PASS <script> has an 'integrity' attribute.
PASS <source> has an 'integrity' attribute.
PASS <track> has an 'integrity' attribute.
PASS <video> has an 'integrity' attribute.
PASS <body> does not have an 'integrity' attribute.
PASS <div> does not have an 'integrity' attribute.
PASS <html> does not have an 'integrity' attribute.
PASS <meta> does not have an 'integrity' attribute.
PASS <span> does not have an 'integrity' attribute.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<script>
description("Some elements should have `integrity` attributes. Others shouldn't.");
var ASSERT_INTEGRITY = 1;
var ASSERT_NO_INTEGRITY = 0;
function checkElement(elementName, integrityDisposition) {
var el = document.createElement(elementName);
if (integrityDisposition == ASSERT_INTEGRITY) {
if ("integrity" in el)
testPassed("<" + elementName + "> has an 'integrity' attribute.");
else
testFailed("<" + elementName + "> does not have an 'integrity' attribute.");
} else {
if ("integrity" in el)
testFailed("<" + elementName + "> has an 'integrity' attribute.");
else
testPassed("<" + elementName + "> does not have an 'integrity' attribute.");
}
}
var shouldHaveIntegrity = [
'a',
'audio',
'embed',
'iframe',
'img',
'link',
'object',
'script',
'source',
'track',
'video',
];
var shouldNotHaveIntegrity = [
'body',
'div',
'html',
'meta',
'span',
];
for (var i = 0; i < shouldHaveIntegrity.length; i++)
checkElement(shouldHaveIntegrity[i], ASSERT_INTEGRITY);
for (var i = 0; i < shouldNotHaveIntegrity.length; i++)
checkElement(shouldNotHaveIntegrity[i], ASSERT_NO_INTEGRITY);
</script>
</body>
</html>
...@@ -32,6 +32,8 @@ interface HTMLAnchorElement : HTMLElement { ...@@ -32,6 +32,8 @@ interface HTMLAnchorElement : HTMLElement {
[Reflect] attribute DOMString type; [Reflect] attribute DOMString type;
readonly attribute DOMString text; readonly attribute DOMString text;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
HTMLAnchorElement implements URLUtils; HTMLAnchorElement implements URLUtils;
...@@ -126,6 +126,7 @@ id ...@@ -126,6 +126,7 @@ id
incremental incremental
indeterminate indeterminate
inputmode inputmode
integrity
is is
ismap ismap
itemid itemid
......
...@@ -33,4 +33,6 @@ ...@@ -33,4 +33,6 @@
[Custom] setter Node (DOMString name, Node value); [Custom] setter Node (DOMString name, Node value);
[CheckSecurity=Node, RaisesException] Document getSVGDocument(); [CheckSecurity=Node, RaisesException] Document getSVGDocument();
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -39,4 +39,6 @@ interface HTMLIFrameElement : HTMLElement { ...@@ -39,4 +39,6 @@ interface HTMLIFrameElement : HTMLElement {
readonly attribute Window contentWindow; readonly attribute Window contentWindow;
[CheckSecurity=Node, RaisesException] Document getSVGDocument(); [CheckSecurity=Node, RaisesException] Document getSVGDocument();
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -45,4 +45,6 @@ ...@@ -45,4 +45,6 @@
// Extensions // Extensions
readonly attribute long x; readonly attribute long x;
readonly attribute long y; readonly attribute long y;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -36,4 +36,6 @@ interface HTMLLinkElement : HTMLElement { ...@@ -36,4 +36,6 @@ interface HTMLLinkElement : HTMLElement {
readonly attribute StyleSheet sheet; readonly attribute StyleSheet sheet;
[RuntimeEnabled=HTMLImports] readonly attribute Document import; [RuntimeEnabled=HTMLImports] readonly attribute Document import;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -89,4 +89,6 @@ ...@@ -89,4 +89,6 @@
// The number of bytes consumed by the media decoder. // The number of bytes consumed by the media decoder.
[MeasureAs=PrefixedAudioDecodedByteCount] readonly attribute unsigned long webkitAudioDecodedByteCount; [MeasureAs=PrefixedAudioDecodedByteCount] readonly attribute unsigned long webkitAudioDecodedByteCount;
[MeasureAs=PrefixedVideoDecodedByteCount] readonly attribute unsigned long webkitVideoDecodedByteCount; [MeasureAs=PrefixedVideoDecodedByteCount] readonly attribute unsigned long webkitVideoDecodedByteCount;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -52,4 +52,6 @@ ...@@ -52,4 +52,6 @@
[Custom] setter Node (DOMString name, Node value); [Custom] setter Node (DOMString name, Node value);
[CheckSecurity=Node, RaisesException] Document getSVGDocument(); [CheckSecurity=Node, RaisesException] Document getSVGDocument();
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -28,4 +28,6 @@ interface HTMLScriptElement : HTMLElement { ...@@ -28,4 +28,6 @@ interface HTMLScriptElement : HTMLElement {
[Reflect] attribute DOMString type; [Reflect] attribute DOMString type;
[Reflect, ReflectOnly="anonymous"|"use-credentials", ReflectEmpty="anonymous", ReflectInvalid="anonymous"] attribute DOMString crossOrigin; [Reflect, ReflectOnly="anonymous"|"use-credentials", ReflectEmpty="anonymous", ReflectInvalid="anonymous"] attribute DOMString crossOrigin;
[Reflect, RuntimeEnabled=ExperimentalContentSecurityPolicyFeatures] attribute DOMString nonce; [Reflect, RuntimeEnabled=ExperimentalContentSecurityPolicyFeatures] attribute DOMString nonce;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -29,4 +29,6 @@ ...@@ -29,4 +29,6 @@
[Reflect, URL, PerWorldBindings, ActivityLogging=SetterForIsolatedWorlds] attribute DOMString src; [Reflect, URL, PerWorldBindings, ActivityLogging=SetterForIsolatedWorlds] attribute DOMString src;
attribute DOMString type; attribute DOMString type;
[DeprecateAs=HTMLSourceElementMedia] attribute DOMString media; [DeprecateAs=HTMLSourceElementMedia] attribute DOMString media;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -40,4 +40,6 @@ ...@@ -40,4 +40,6 @@
readonly attribute unsigned short readyState; readonly attribute unsigned short readyState;
readonly attribute TextTrack track; readonly attribute TextTrack track;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
}; };
...@@ -106,6 +106,7 @@ Srcset status=stable ...@@ -106,6 +106,7 @@ Srcset status=stable
Stream status=experimental Stream status=experimental
StyleScoped status=experimental StyleScoped status=experimental
SubpixelFontScaling status=experimental SubpixelFontScaling status=experimental
SubresourceIntegrity status=test
SVGPaintOrder status=stable SVGPaintOrder status=stable
// Enable optimizations to recalculate style on the fewest possible number of // Enable optimizations to recalculate style on the fewest possible number of
......
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