Changeset 247509 in webkit
- Timestamp:
- Jul 17, 2019 2:03:37 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 58 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r247501 r247509 1 2019-07-17 Rob Buis <rbuis@igalia.com> 2 3 Add referrerpolicy attribute support for <script> elements 4 https://bugs.webkit.org/show_bug.cgi?id=185550 5 6 Reviewed by Youenn Fablet. 7 8 Add tests for scripts with various referrerpolicy attribute values. 9 10 * http/tests/referrer-policy-script/no-referrer-when-downgrade/cross-origin-http-http-expected.txt: Added. 11 * http/tests/referrer-policy-script/no-referrer-when-downgrade/cross-origin-http-http.html: Added. 12 * http/tests/referrer-policy-script/no-referrer-when-downgrade/cross-origin-http.https-expected.txt: Added. 13 * http/tests/referrer-policy-script/no-referrer-when-downgrade/cross-origin-http.https.html: Added. 14 * http/tests/referrer-policy-script/no-referrer-when-downgrade/same-origin-expected.txt: Added. 15 * http/tests/referrer-policy-script/no-referrer-when-downgrade/same-origin.html: Added. 16 * http/tests/referrer-policy-script/no-referrer/cross-origin-http-http-expected.txt: Added. 17 * http/tests/referrer-policy-script/no-referrer/cross-origin-http-http.html: Added. 18 * http/tests/referrer-policy-script/no-referrer/cross-origin-http.https-expected.txt: Added. 19 * http/tests/referrer-policy-script/no-referrer/cross-origin-http.https.html: Added. 20 * http/tests/referrer-policy-script/no-referrer/same-origin-expected.txt: Added. 21 * http/tests/referrer-policy-script/no-referrer/same-origin.html: Added. 22 * http/tests/referrer-policy-script/origin-when-cross-origin/cross-origin-http-http-expected.txt: Added. 23 * http/tests/referrer-policy-script/origin-when-cross-origin/cross-origin-http-http.html: Added. 24 * http/tests/referrer-policy-script/origin-when-cross-origin/cross-origin-http.https-expected.txt: Added. 25 * http/tests/referrer-policy-script/origin-when-cross-origin/cross-origin-http.https.html: Added. 26 * http/tests/referrer-policy-script/origin-when-cross-origin/same-origin-expected.txt: Added. 27 * http/tests/referrer-policy-script/origin-when-cross-origin/same-origin.html: Added. 28 * http/tests/referrer-policy-script/origin/cross-origin-http-http-expected.txt: Added. 29 * http/tests/referrer-policy-script/origin/cross-origin-http-http.html: Added. 30 * http/tests/referrer-policy-script/origin/cross-origin-http.https-expected.txt: Added. 31 * http/tests/referrer-policy-script/origin/cross-origin-http.https.html: Added. 32 * http/tests/referrer-policy-script/origin/same-origin-expected.txt: Added. 33 * http/tests/referrer-policy-script/origin/same-origin.html: Added. 34 * http/tests/referrer-policy-script/same-origin/cross-origin-http-http-expected.txt: Added. 35 * http/tests/referrer-policy-script/same-origin/cross-origin-http-http.html: Added. 36 * http/tests/referrer-policy-script/same-origin/cross-origin-http.https-expected.txt: Added. 37 * http/tests/referrer-policy-script/same-origin/cross-origin-http.https.html: Added. 38 * http/tests/referrer-policy-script/same-origin/same-origin-expected.txt: Added. 39 * http/tests/referrer-policy-script/same-origin/same-origin.html: Added. 40 * http/tests/referrer-policy-script/strict-origin-when-cross-origin/cross-origin-http-http-expected.txt: Added. 41 * http/tests/referrer-policy-script/strict-origin-when-cross-origin/cross-origin-http-http.html: Added. 42 * http/tests/referrer-policy-script/strict-origin-when-cross-origin/cross-origin-http.https-expected.txt: Added. 43 * http/tests/referrer-policy-script/strict-origin-when-cross-origin/cross-origin-http.https.html: Added. 44 * http/tests/referrer-policy-script/strict-origin-when-cross-origin/same-origin-expected.txt: Added. 45 * http/tests/referrer-policy-script/strict-origin-when-cross-origin/same-origin.html: Added. 46 * http/tests/referrer-policy-script/strict-origin/cross-origin-http-http-expected.txt: Added. 47 * http/tests/referrer-policy-script/strict-origin/cross-origin-http-http.html: Added. 48 * http/tests/referrer-policy-script/strict-origin/cross-origin-http.https-expected.txt: Added. 49 * http/tests/referrer-policy-script/strict-origin/cross-origin-http.https.html: Added. 50 * http/tests/referrer-policy-script/strict-origin/same-origin-expected.txt: Added. 51 * http/tests/referrer-policy-script/strict-origin/same-origin.html: Added. 52 * http/tests/referrer-policy-script/unsafe-url/cross-origin-http-http-expected.txt: Added. 53 * http/tests/referrer-policy-script/unsafe-url/cross-origin-http-http.html: Added. 54 * http/tests/referrer-policy-script/unsafe-url/cross-origin-http.https-expected.txt: Added. 55 * http/tests/referrer-policy-script/unsafe-url/cross-origin-http.https.html: Added. 56 * http/tests/referrer-policy-script/unsafe-url/same-origin-expected.txt: Added. 57 * http/tests/referrer-policy-script/unsafe-url/same-origin.html: Added. 58 * http/tests/referrer-policy/resources/script.php: Added. 59 * platform/win/TestExpectations: 60 1 61 2019-07-16 Myles C. Maxfield <mmaxfield@apple.com> 2 62 -
trunk/LayoutTests/platform/win/TestExpectations
r247481 r247509 4312 4312 webkit.org/b/195461 http/tests/referrer-policy-iframe/unsafe-url/cross-origin-http.https.html [ Failure ] 4313 4313 4314 webkit.org/b/195461 http/tests/referrer-policy-script [ Skip ] 4315 4314 4316 # webkit.org/b/196463 4315 4317 [ Win10 ] fast/css/font-family-pictograph.html [ Failure ] -
trunk/Source/WebCore/ChangeLog
r247505 r247509 1 2019-07-17 Rob Buis <rbuis@igalia.com> 2 3 Add referrerpolicy attribute support for <script> elements 4 https://bugs.webkit.org/show_bug.cgi?id=185550 5 6 Reviewed by Youenn Fablet. 7 8 This patch adds 'referrerpolicy' attribute support for script elements. 9 If set, the value is restricted to the ReferrerPolicy enum, and 10 if valid it is used for the script fetch. 11 If not set or invalid, the current behavior is kept. 12 13 Tests: http/tests/referrer-policy-script/no-referrer-when-downgrade/cross-origin-http-http.html 14 http/tests/referrer-policy-script/no-referrer-when-downgrade/cross-origin-http.https.html 15 http/tests/referrer-policy-script/no-referrer-when-downgrade/same-origin.html 16 http/tests/referrer-policy-script/no-referrer/cross-origin-http-http.html 17 http/tests/referrer-policy-script/no-referrer/cross-origin-http.https.html 18 http/tests/referrer-policy-script/no-referrer/same-origin.html 19 http/tests/referrer-policy-script/origin-when-cross-origin/cross-origin-http-http.html 20 http/tests/referrer-policy-script/origin-when-cross-origin/cross-origin-http.https.html 21 http/tests/referrer-policy-script/origin-when-cross-origin/same-origin.html 22 http/tests/referrer-policy-script/origin/cross-origin-http-http.html 23 http/tests/referrer-policy-script/origin/cross-origin-http.https.html 24 http/tests/referrer-policy-script/origin/same-origin.html 25 http/tests/referrer-policy-script/same-origin/cross-origin-http-http.html 26 http/tests/referrer-policy-script/same-origin/cross-origin-http.https.html 27 http/tests/referrer-policy-script/same-origin/same-origin.html 28 http/tests/referrer-policy-script/strict-origin-when-cross-origin/cross-origin-http-http.html 29 http/tests/referrer-policy-script/strict-origin-when-cross-origin/cross-origin-http.https.html 30 http/tests/referrer-policy-script/strict-origin-when-cross-origin/same-origin.html 31 http/tests/referrer-policy-script/strict-origin/cross-origin-http-http.html 32 http/tests/referrer-policy-script/strict-origin/cross-origin-http.https.html 33 http/tests/referrer-policy-script/strict-origin/same-origin.html 34 http/tests/referrer-policy-script/unsafe-url/cross-origin-http-http.html 35 http/tests/referrer-policy-script/unsafe-url/cross-origin-http.https.html 36 http/tests/referrer-policy-script/unsafe-url/same-origin.html 37 38 * bindings/js/CachedScriptFetcher.cpp: 39 (WebCore::CachedScriptFetcher::requestScriptWithCache const): 40 * bindings/js/CachedScriptFetcher.h: 41 (WebCore::CachedScriptFetcher::CachedScriptFetcher): 42 * dom/InlineClassicScript.h: 43 * dom/LoadableClassicScript.cpp: 44 (WebCore::LoadableClassicScript::create): 45 * dom/LoadableClassicScript.h: 46 * dom/LoadableModuleScript.cpp: 47 (WebCore::LoadableModuleScript::create): 48 (WebCore::LoadableModuleScript::LoadableModuleScript): 49 * dom/LoadableModuleScript.h: 50 * dom/LoadableScript.h: 51 (WebCore::LoadableScript::LoadableScript): 52 * dom/ScriptElement.cpp: 53 (WebCore::ScriptElement::requestClassicScript): 54 (WebCore::ScriptElement::requestModuleScript): 55 * dom/ScriptElement.h: 56 * dom/ScriptElementCachedScriptFetcher.h: 57 (WebCore::ScriptElementCachedScriptFetcher::ScriptElementCachedScriptFetcher): 58 * html/HTMLIFrameElement.cpp: 59 (WebCore::HTMLIFrameElement::referrerPolicyForBindings const): 60 * html/HTMLScriptElement.cpp: 61 (WebCore::HTMLScriptElement::setReferrerPolicyForBindings): 62 (WebCore::HTMLScriptElement::referrerPolicyForBindings const): 63 (WebCore::HTMLScriptElement::referrerPolicy const): 64 * html/HTMLScriptElement.h: 65 * html/HTMLScriptElement.idl: 66 * html/parser/CSSPreloadScanner.cpp: 67 (WebCore::CSSPreloadScanner::emitRule): 68 * html/parser/HTMLPreloadScanner.cpp: 69 (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): 70 (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): 71 * html/parser/HTMLResourcePreloader.cpp: 72 (WebCore::PreloadRequest::resourceRequest): 73 * html/parser/HTMLResourcePreloader.h: 74 (WebCore::PreloadRequest::PreloadRequest): 75 * platform/ReferrerPolicy.cpp: 76 (WebCore::referrerPolicyToString): 77 * platform/ReferrerPolicy.h: 78 * svg/SVGScriptElement.h: 79 1 80 2019-07-16 Christopher Reid <chris.reid@sony.com> 2 81 -
trunk/Source/WebCore/bindings/js/CachedScriptFetcher.cpp
r235617 r247509 57 57 options.sameOriginDataURLFlag = SameOriginDataURLFlag::Set; 58 58 options.integrity = WTFMove(integrity); 59 options.referrerPolicy = m_referrerPolicy; 59 60 60 61 auto request = createPotentialAccessControlRequest(sourceURL, document, crossOriginMode, WTFMove(options)); -
trunk/Source/WebCore/bindings/js/CachedScriptFetcher.h
r246490 r247509 27 27 28 28 #include "CachedResourceHandle.h" 29 #include "ReferrerPolicy.h" 29 30 #include <JavaScriptCore/ScriptFetcher.h> 30 31 #include <wtf/text/WTFString.h> … … 42 43 43 44 protected: 44 CachedScriptFetcher(const String& nonce, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree)45 CachedScriptFetcher(const String& nonce, ReferrerPolicy referrerPolicy, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 45 46 : m_nonce(nonce) 46 47 , m_charset(charset) 47 48 , m_initiatorName(initiatorName) 48 49 , m_isInUserAgentShadowTree(isInUserAgentShadowTree) 50 , m_referrerPolicy(referrerPolicy) 49 51 { 50 52 } … … 62 64 AtomString m_initiatorName; 63 65 bool m_isInUserAgentShadowTree { false }; 66 ReferrerPolicy m_referrerPolicy { ReferrerPolicy::EmptyString }; 64 67 }; 65 68 -
trunk/Source/WebCore/dom/InlineClassicScript.h
r246490 r247509 41 41 private: 42 42 InlineClassicScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 43 : ScriptElementCachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)43 : ScriptElementCachedScriptFetcher(nonce, ReferrerPolicy::EmptyString, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree) 44 44 { 45 45 } -
trunk/Source/WebCore/dom/LoadableClassicScript.cpp
r246490 r247509 36 36 namespace WebCore { 37 37 38 Ref<LoadableClassicScript> LoadableClassicScript::create(const String& nonce, const String& integrityMetadata, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree)38 Ref<LoadableClassicScript> LoadableClassicScript::create(const String& nonce, const String& integrityMetadata, ReferrerPolicy policy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 39 39 { 40 return adoptRef(*new LoadableClassicScript(nonce, integrityMetadata, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree));40 return adoptRef(*new LoadableClassicScript(nonce, integrityMetadata, policy, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)); 41 41 } 42 42 -
trunk/Source/WebCore/dom/LoadableClassicScript.h
r246490 r247509 30 30 #include "CachedScript.h" 31 31 #include "LoadableScript.h" 32 #include "ReferrerPolicy.h" 32 33 #include <wtf/TypeCasts.h> 33 34 … … 41 42 virtual ~LoadableClassicScript(); 42 43 43 static Ref<LoadableClassicScript> create(const String& nonce, const String& integrity, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree);44 static Ref<LoadableClassicScript> create(const String& nonce, const String& integrity, ReferrerPolicy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree); 44 45 bool isLoaded() const final; 45 46 Optional<Error> error() const final; … … 56 57 57 58 private: 58 LoadableClassicScript(const String& nonce, const String& integrity, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree)59 : LoadableScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)59 LoadableClassicScript(const String& nonce, const String& integrity, ReferrerPolicy policy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 60 : LoadableScript(nonce, policy, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree) 60 61 , m_integrity(integrity) 61 62 { -
trunk/Source/WebCore/dom/LoadableModuleScript.cpp
r246490 r247509 35 35 namespace WebCore { 36 36 37 Ref<LoadableModuleScript> LoadableModuleScript::create(const String& nonce, const String& integrity, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree)37 Ref<LoadableModuleScript> LoadableModuleScript::create(const String& nonce, const String& integrity, ReferrerPolicy policy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 38 38 { 39 return adoptRef(*new LoadableModuleScript(nonce, integrity, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree));39 return adoptRef(*new LoadableModuleScript(nonce, integrity, policy, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)); 40 40 } 41 41 42 LoadableModuleScript::LoadableModuleScript(const String& nonce, const String& integrity, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree)43 : LoadableScript(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)42 LoadableModuleScript::LoadableModuleScript(const String& nonce, const String& integrity, ReferrerPolicy policy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 43 : LoadableScript(nonce, policy, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree) 44 44 , m_parameters(ModuleFetchParameters::create(integrity)) 45 45 { -
trunk/Source/WebCore/dom/LoadableModuleScript.h
r246490 r247509 38 38 virtual ~LoadableModuleScript(); 39 39 40 static Ref<LoadableModuleScript> create(const String& nonce, const String& integrity, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree);40 static Ref<LoadableModuleScript> create(const String& nonce, const String& integrity, ReferrerPolicy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree); 41 41 42 42 bool isLoaded() const final; … … 61 61 62 62 private: 63 LoadableModuleScript(const String& nonce, const String& integrity, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree);63 LoadableModuleScript(const String& nonce, const String& integrity, ReferrerPolicy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree); 64 64 65 65 Ref<ModuleFetchParameters> m_parameters; -
trunk/Source/WebCore/dom/LoadableScript.h
r246490 r247509 69 69 70 70 protected: 71 LoadableScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree)72 : ScriptElementCachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)71 LoadableScript(const String& nonce, ReferrerPolicy policy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 72 : ScriptElementCachedScriptFetcher(nonce, policy, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree) 73 73 { 74 74 } -
trunk/Source/WebCore/dom/ScriptElement.cpp
r240237 r247509 285 285 m_element.attributeWithoutSynchronization(HTMLNames::nonceAttr), 286 286 m_element.document().settings().subresourceIntegrityEnabled() ? m_element.attributeWithoutSynchronization(HTMLNames::integrityAttr).string() : emptyString(), 287 referrerPolicy(), 287 288 m_element.attributeWithoutSynchronization(HTMLNames::crossoriginAttr), 288 289 scriptCharset(), … … 336 337 nonce, 337 338 m_element.document().settings().subresourceIntegrityEnabled() ? m_element.attributeWithoutSynchronization(HTMLNames::integrityAttr).string() : emptyString(), 339 referrerPolicy(), 338 340 crossOriginMode, 339 341 scriptCharset(), … … 345 347 } 346 348 347 auto script = LoadableModuleScript::create(nonce, emptyString(), crossOriginMode, scriptCharset(), m_element.localName(), m_element.isInUserAgentShadowTree());349 auto script = LoadableModuleScript::create(nonce, emptyString(), referrerPolicy(), crossOriginMode, scriptCharset(), m_element.localName(), m_element.isInUserAgentShadowTree()); 348 350 349 351 TextPosition position = m_element.document().isInDocumentWrite() ? TextPosition() : scriptStartPosition; -
trunk/Source/WebCore/dom/ScriptElement.h
r239427 r247509 24 24 #include "ContainerNode.h" 25 25 #include "LoadableScript.h" 26 #include "ReferrerPolicy.h" 26 27 #include "UserGestureIndicator.h" 27 28 #include <wtf/MonotonicTime.h> … … 114 115 virtual bool hasSourceAttribute() const = 0; 115 116 virtual bool hasNoModuleAttribute() const = 0; 117 virtual ReferrerPolicy referrerPolicy() const = 0; 116 118 117 119 Element& m_element; -
trunk/Source/WebCore/dom/ScriptElementCachedScriptFetcher.h
r246490 r247509 40 40 41 41 protected: 42 ScriptElementCachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree)43 : CachedScriptFetcher(nonce, charset, initiatorName, isInUserAgentShadowTree)42 ScriptElementCachedScriptFetcher(const String& nonce, ReferrerPolicy policy, const String& crossOriginMode, const String& charset, const AtomString& initiatorName, bool isInUserAgentShadowTree) 43 : CachedScriptFetcher(nonce, policy, charset, initiatorName, isInUserAgentShadowTree) 44 44 , m_crossOriginMode(crossOriginMode) 45 45 { -
trunk/Source/WebCore/html/HTMLIFrameElement.cpp
r246490 r247509 120 120 String HTMLIFrameElement::referrerPolicyForBindings() const 121 121 { 122 switch (referrerPolicy()) { 123 case ReferrerPolicy::NoReferrer: 124 return "no-referrer"_s; 125 case ReferrerPolicy::UnsafeUrl: 126 return "unsafe-url"_s; 127 case ReferrerPolicy::Origin: 128 return "origin"_s; 129 case ReferrerPolicy::OriginWhenCrossOrigin: 130 return "origin-when-cross-origin"_s; 131 case ReferrerPolicy::SameOrigin: 132 return "same-origin"_s; 133 case ReferrerPolicy::StrictOrigin: 134 return "strict-origin"_s; 135 case ReferrerPolicy::StrictOriginWhenCrossOrigin: 136 return "strict-origin-when-cross-origin"_s; 137 case ReferrerPolicy::NoReferrerWhenDowngrade: 138 return "no-referrer-when-downgrade"_s; 139 case ReferrerPolicy::EmptyString: 140 return { }; 141 } 142 ASSERT_NOT_REACHED(); 143 return { }; 122 return referrerPolicyToString(referrerPolicy()); 144 123 } 145 124 -
trunk/Source/WebCore/html/HTMLScriptElement.cpp
r246490 r247509 185 185 } 186 186 187 } 187 void HTMLScriptElement::setReferrerPolicyForBindings(const AtomString& value) 188 { 189 setAttributeWithoutSynchronization(referrerpolicyAttr, value); 190 } 191 192 String HTMLScriptElement::referrerPolicyForBindings() const 193 { 194 return referrerPolicyToString(referrerPolicy()); 195 } 196 197 ReferrerPolicy HTMLScriptElement::referrerPolicy() const 198 { 199 if (RuntimeEnabledFeatures::sharedFeatures().referrerPolicyAttributeEnabled()) 200 return parseReferrerPolicy(attributeWithoutSynchronization(referrerpolicyAttr), ReferrerPolicySource::ReferrerPolicyAttribute).valueOr(ReferrerPolicy::EmptyString); 201 return ReferrerPolicy::EmptyString; 202 } 203 204 } -
trunk/Source/WebCore/html/HTMLScriptElement.h
r246490 r247509 45 45 WEBCORE_EXPORT String crossOrigin() const; 46 46 47 void setReferrerPolicyForBindings(const AtomString&); 48 String referrerPolicyForBindings() const; 49 ReferrerPolicy referrerPolicy() const final; 50 47 51 using HTMLElement::ref; 48 52 using HTMLElement::deref; -
trunk/Source/WebCore/html/HTMLScriptElement.idl
r238748 r247509 32 32 [CEReactions=NotNeeded, Reflect] attribute boolean noModule; 33 33 [CEReactions=NotNeeded, Reflect, EnabledBySetting=SubresourceIntegrity] attribute DOMString integrity; 34 [EnabledAtRuntime=ReferrerPolicyAttribute, ImplementedAs=referrerPolicyForBindings, CEReactions=NotNeeded] attribute DOMString referrerPolicy; 34 35 }; -
trunk/Source/WebCore/html/parser/CSSPreloadScanner.cpp
r233668 r247509 202 202 URL baseElementURL; // FIXME: This should be passed in from the HTMLPreloadScanner via scan(): without it we will get relative URLs wrong. 203 203 // FIXME: Should this be including the charset in the preload request? 204 m_requests->append(std::make_unique<PreloadRequest>("css", url, baseElementURL, CachedResource::Type::CSSStyleSheet, String(), PreloadRequest::ModuleScript::No ));204 m_requests->append(std::make_unique<PreloadRequest>("css", url, baseElementURL, CachedResource::Type::CSSStyleSheet, String(), PreloadRequest::ModuleScript::No, ReferrerPolicy::EmptyString)); 205 205 } 206 206 m_state = Initial; -
trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp
r246490 r247509 162 162 return nullptr; 163 163 164 auto request = std::make_unique<PreloadRequest>(initiatorFor(m_tagId), m_urlToLoad, predictedBaseURL, type.value(), m_mediaAttribute, m_moduleScript );164 auto request = std::make_unique<PreloadRequest>(initiatorFor(m_tagId), m_urlToLoad, predictedBaseURL, type.value(), m_mediaAttribute, m_moduleScript, m_referrerPolicy); 165 165 request->setCrossOriginMode(m_crossOriginMode); 166 166 request->setNonce(m_nonceAttribute); … … 237 237 m_moduleScript = equalLettersIgnoringASCIICase(attributeValue, "module") ? PreloadRequest::ModuleScript::Yes : PreloadRequest::ModuleScript::No; 238 238 break; 239 } else if (match(attributeName, nonceAttr)) 239 } else if (match(attributeName, nonceAttr)) { 240 240 m_nonceAttribute = attributeValue; 241 break; 242 } else if (match(attributeName, referrerpolicyAttr)) { 243 m_referrerPolicy = parseReferrerPolicy(attributeValue, ReferrerPolicySource::ReferrerPolicyAttribute).valueOr(ReferrerPolicy::EmptyString); 244 break; 245 } 241 246 processImageAndScriptAttribute(attributeName, attributeValue); 242 247 break; … … 371 376 float m_deviceScaleFactor; 372 377 PreloadRequest::ModuleScript m_moduleScript { PreloadRequest::ModuleScript::No }; 378 ReferrerPolicy m_referrerPolicy { ReferrerPolicy::EmptyString }; 373 379 }; 374 380 -
trunk/Source/WebCore/html/parser/HTMLResourcePreloader.cpp
r235617 r247509 60 60 crossOriginMode = "omit"_s; 61 61 } 62 if (m_resourceType == CachedResource::Type::Script) 63 options.referrerPolicy = m_referrerPolicy; 62 64 auto request = createPotentialAccessControlRequest(completeURL(document), document, crossOriginMode, WTFMove(options)); 63 65 request.setInitiator(m_initiator); -
trunk/Source/WebCore/html/parser/HTMLResourcePreloader.h
r232613 r247509 38 38 No, 39 39 }; 40 PreloadRequest(const String& initiator, const String& resourceURL, const URL& baseURL, CachedResource::Type resourceType, const String& mediaAttribute, ModuleScript moduleScript )40 PreloadRequest(const String& initiator, const String& resourceURL, const URL& baseURL, CachedResource::Type resourceType, const String& mediaAttribute, ModuleScript moduleScript, const ReferrerPolicy& referrerPolicy) 41 41 : m_initiator(initiator) 42 42 , m_resourceURL(resourceURL) … … 45 45 , m_mediaAttribute(mediaAttribute) 46 46 , m_moduleScript(moduleScript) 47 , m_referrerPolicy(referrerPolicy) 47 48 { 48 49 } … … 69 70 String m_nonceAttribute; 70 71 ModuleScript m_moduleScript; 72 ReferrerPolicy m_referrerPolicy; 71 73 }; 72 74 -
trunk/Source/WebCore/platform/ReferrerPolicy.cpp
r242776 r247509 90 90 } 91 91 92 String referrerPolicyToString(const ReferrerPolicy& referrerPolicy) 93 { 94 switch (referrerPolicy) { 95 case ReferrerPolicy::NoReferrer: 96 return "no-referrer"_s; 97 case ReferrerPolicy::UnsafeUrl: 98 return "unsafe-url"_s; 99 case ReferrerPolicy::Origin: 100 return "origin"_s; 101 case ReferrerPolicy::OriginWhenCrossOrigin: 102 return "origin-when-cross-origin"_s; 103 case ReferrerPolicy::SameOrigin: 104 return "same-origin"_s; 105 case ReferrerPolicy::StrictOrigin: 106 return "strict-origin"_s; 107 case ReferrerPolicy::StrictOriginWhenCrossOrigin: 108 return "strict-origin-when-cross-origin"_s; 109 case ReferrerPolicy::NoReferrerWhenDowngrade: 110 return "no-referrer-when-downgrade"_s; 111 case ReferrerPolicy::EmptyString: 112 return { }; 113 } 114 ASSERT_NOT_REACHED(); 115 return { }; 116 } 117 92 118 } // namespace WebCore -
trunk/Source/WebCore/platform/ReferrerPolicy.h
r242776 r247509 51 51 enum class ReferrerPolicySource : uint8_t { MetaTag, HTTPHeader, ReferrerPolicyAttribute }; 52 52 Optional<ReferrerPolicy> parseReferrerPolicy(StringView, ReferrerPolicySource); 53 String referrerPolicyToString(const ReferrerPolicy&); 53 54 54 55 } -
trunk/Source/WebCore/svg/SVGScriptElement.h
r246490 r247509 66 66 bool hasDeferAttribute() const final { return false; } 67 67 bool hasNoModuleAttribute() const final { return false; } 68 ReferrerPolicy referrerPolicy() const final { return ReferrerPolicy::EmptyString; } 68 69 bool hasSourceAttribute() const final { return hasAttribute(SVGNames::hrefAttr) || hasAttribute(XLinkNames::hrefAttr); } 69 70
Note: See TracChangeset
for help on using the changeset viewer.