зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1389421 - Support nonce IDL property; r=ckerschb,smaug
We already support the actual functionality, but nobody added support for the IDL property to the .webidl file. Also added <style nonce> to the web-platform-tests reflection tests, since nobody updated that to the current spec either. This does not add support for .nonce to SVGScriptElement, because I couldn't find any standard that specified it. I updated the wpt tests to expect .nonce to work on HTMLScriptElement but not SVGScriptElement. MozReview-Commit-ID: F1K7WMfMoDi --HG-- extra : rebase_source : 247c63b63446dc0d60062bb9d9c61228c379b989
This commit is contained in:
Родитель
078e5787ea
Коммит
1b3b415680
|
@ -107,6 +107,14 @@ public:
|
|||
SetHTMLAttr(nsGkAtoms::rel, aRel, aRv);
|
||||
}
|
||||
nsDOMTokenList* RelList();
|
||||
void GetNonce(nsAString& aNonce) const
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::nonce, aNonce);
|
||||
}
|
||||
void SetNonce(const nsAString& aNonce, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::nonce, aNonce, aRv);
|
||||
}
|
||||
// XPCOM GetMedia is fine.
|
||||
void SetMedia(const nsAString& aMedia, ErrorResult& aRv)
|
||||
{
|
||||
|
|
|
@ -81,6 +81,14 @@ public:
|
|||
{
|
||||
SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
|
||||
}
|
||||
void GetNonce(nsAString& aNonce) const
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::nonce, aNonce);
|
||||
}
|
||||
void SetNonce(const nsAString& aNonce, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::nonce, aNonce, aRv);
|
||||
}
|
||||
void GetIntegrity(nsAString& aIntegrity)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::integrity, aIntegrity);
|
||||
|
|
|
@ -62,6 +62,14 @@ public:
|
|||
|
||||
bool Disabled();
|
||||
void SetDisabled(bool aDisabled);
|
||||
void GetNonce(nsAString& aNonce) const
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::nonce, aNonce);
|
||||
}
|
||||
void SetNonce(const nsAString& aNonce, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::nonce, aNonce, aRv);
|
||||
}
|
||||
void SetMedia(const nsAString& aMedia, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::media, aMedia, aError);
|
||||
|
|
|
@ -26,6 +26,8 @@ interface HTMLLinkElement : HTMLElement {
|
|||
readonly attribute DOMTokenList relList;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString media;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString nonce;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString hreflang;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
|
|
|
@ -26,6 +26,10 @@ interface HTMLScriptElement : HTMLElement {
|
|||
attribute DOMString? crossOrigin;
|
||||
[CEReactions, SetterThrows]
|
||||
attribute DOMString text;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString nonce;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString integrity;
|
||||
};
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
|
||||
|
@ -35,9 +39,3 @@ partial interface HTMLScriptElement {
|
|||
[CEReactions, SetterThrows]
|
||||
attribute DOMString htmlFor;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/webappsec/specs/subresourceintegrity/#htmlscriptelement-1
|
||||
partial interface HTMLScriptElement {
|
||||
[CEReactions, SetterThrows]
|
||||
attribute DOMString integrity;
|
||||
};
|
||||
|
|
|
@ -15,6 +15,8 @@ interface HTMLStyleElement : HTMLElement {
|
|||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString media;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString nonce;
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString type;
|
||||
[SetterThrows, Pure, Pref="layout.css.scoped-style.enabled"]
|
||||
attribute boolean scoped;
|
||||
|
|
|
@ -1,29 +1,8 @@
|
|||
[script-nonces-hidden-meta.tentative.html]
|
||||
type: testharness
|
||||
[Reading 'nonce' content attribute and IDL attribute.]
|
||||
expected: FAIL
|
||||
|
||||
[Cloned node retains nonce.]
|
||||
expected: FAIL
|
||||
|
||||
[Cloned node retains nonce when inserted.]
|
||||
expected: FAIL
|
||||
|
||||
[Writing 'nonce' content attribute.]
|
||||
expected: FAIL
|
||||
|
||||
[Document-written script's nonce value.]
|
||||
expected: FAIL
|
||||
|
||||
[createElement.nonce.]
|
||||
expected: FAIL
|
||||
|
||||
[setAttribute('nonce') overwrites '.nonce' upon insertion.]
|
||||
expected: FAIL
|
||||
|
||||
[createElement.setAttribute.]
|
||||
expected: FAIL
|
||||
|
||||
[Nonces leak via CSS side-channels.]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
[Cloned node retains nonce when inserted.]
|
||||
expected: FAIL
|
||||
|
||||
[Writing 'nonce' content attribute.]
|
||||
expected: FAIL
|
||||
|
||||
[Document-written script's nonce value.]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
[Document-written script's nonce value.]
|
||||
expected: FAIL
|
||||
|
||||
[createElement.setAttribute.]
|
||||
expected: FAIL
|
||||
|
||||
[Nonces don't leak via CSS side-channels.]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -2677,12 +2677,6 @@
|
|||
[HTMLElement interface: document.createElement("noscript") must inherit property "onmousewheel" with the proper type (58)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLStyleElement interface: attribute nonce]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLStyleElement interface: document.createElement("style") must inherit property "nonce" with the proper type (1)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMediaElement interface: document.createElement("video") must inherit property "audioTracks" with the proper type (38)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -3001,12 +2995,6 @@
|
|||
[HTMLElement interface: document.createElement("noscript") must inherit property "onmousewheel" with the proper type (59)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLLinkElement interface: attribute nonce]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLLinkElement interface: document.createElement("link") must inherit property "nonce" with the proper type (5)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLIFrameElement interface: attribute allowUserMedia]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -3256,15 +3244,9 @@
|
|||
[HTMLScriptElement interface: attribute noModule]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLScriptElement interface: attribute nonce]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLScriptElement interface: document.createElement("script") must inherit property "noModule" with the proper type (2)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLScriptElement interface: document.createElement("script") must inherit property "nonce" with the proper type (8)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLElement interface: document.createElement("noscript") must inherit property "forceSpellCheck" with the proper type (15)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -3289,9 +3271,6 @@
|
|||
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "styleSheets" with the proper type (29)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLLinkElement interface: document.createElement("link") must inherit property "nonce" with the proper type (6)]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLBodyElement interface: attribute onmessageerror]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -36,102 +36,6 @@
|
|||
[style.tabIndex: setAttribute() to object "3" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: typeof IDL attribute]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL get with DOM attribute unset]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to ""]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to undefined]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to 7]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to 1.5]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to true]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to false]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to object "[object Object\]"]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to NaN]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to -Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to "\\0"]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to null]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to object "test-toString"]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: setAttribute() to object "test-valueOf"]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to ""]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to undefined]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to 7]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to 1.5]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to true]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to false]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to object "[object Object\]"]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to NaN]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to -Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to "\\0"]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to null]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to object "test-toString"]
|
||||
expected: FAIL
|
||||
|
||||
[link.nonce: IDL set to object "test-valueOf"]
|
||||
expected: FAIL
|
||||
|
||||
[link.as: setAttribute() to "document"]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -604,102 +604,6 @@
|
|||
[menuitem.default: IDL set to object "test-valueOf"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: typeof IDL attribute]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL get with DOM attribute unset]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to ""]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to undefined]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to 7]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to 1.5]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to true]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to false]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to object "[object Object\]"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to NaN]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to -Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to "\\0"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to null]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to object "test-toString"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: setAttribute() to object "test-valueOf"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to ""]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to undefined]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to 7]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to 1.5]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to true]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to false]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to object "[object Object\]"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to NaN]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to -Infinity]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to "\\0"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to null]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to object "test-toString"]
|
||||
expected: FAIL
|
||||
|
||||
[script.nonce: IDL set to object "test-valueOf"]
|
||||
expected: FAIL
|
||||
|
||||
[script.noModule: typeof IDL attribute]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
test(t => {
|
||||
script.nonce = 'bar';
|
||||
assert_equals(script.nonce, 'bar');
|
||||
assert_equals(script.getAttribute('nonce'), 'foo');
|
||||
assert_equals(script.getAttribute('nonce'), 'bar');
|
||||
}, "Writing 'nonce' IDL attribute.");
|
||||
|
||||
// Fragment parser.
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
test(t => {
|
||||
script.nonce = 'bar';
|
||||
assert_equals(script.nonce, 'bar');
|
||||
assert_equals(script.getAttribute('nonce'), 'foo');
|
||||
assert_equals(script.getAttribute('nonce'), 'bar');
|
||||
}, "Writing 'nonce' IDL attribute.");
|
||||
|
||||
// Fragment parser.
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
assert_equals(script.nonce, 'abc');
|
||||
}, "Writing 'nonce' content attribute.");
|
||||
|
||||
// Set the IDL attribute to 'bar'
|
||||
// Set the IDL attribute to 'bar' (doesn't work on SVGScriptElement)
|
||||
test(t => {
|
||||
script.nonce = 'bar';
|
||||
assert_equals(script.nonce, 'bar');
|
||||
|
|
|
@ -73,7 +73,8 @@
|
|||
// Create node.
|
||||
test(t => {
|
||||
var s = document.createElement('svg');
|
||||
var innerScript = document.createElement('script');
|
||||
var innerScript = document.createElementNS('http://www.w3.org/2000/svg',
|
||||
'script');
|
||||
innerScript.innerText = script.innerText;
|
||||
innerScript.nonce = 'abc';
|
||||
s.appendChild(innerScript);
|
||||
|
|
|
@ -55,6 +55,7 @@ var metadataElements = {
|
|||
},
|
||||
style: {
|
||||
media: "string",
|
||||
nonce: "string",
|
||||
type: "string",
|
||||
},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче