| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
| 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 286 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); |
| 287 if (!m_element->inDocument() || m_element->document() != elementDocument) | 287 if (!m_element->inDocument() || m_element->document() != elementDocument) |
| 288 return false; | 288 return false; |
| 289 | 289 |
| 290 ASSERT(!m_resource); | 290 ASSERT(!m_resource); |
| 291 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { | 291 if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) { |
| 292 FetchRequest request(ResourceRequest(elementDocument->completeURL(source
Url)), m_element->localName()); | 292 FetchRequest request(ResourceRequest(elementDocument->completeURL(source
Url)), m_element->localName()); |
| 293 | 293 |
| 294 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_elem
ent->fastGetAttribute(HTMLNames::crossoriginAttr)); | 294 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_elem
ent->fastGetAttribute(HTMLNames::crossoriginAttr)); |
| 295 if (crossOrigin != CrossOriginAttributeNotSet) | 295 if (crossOrigin != CrossOriginAttributeNotSet) |
| 296 request.setCrossOriginAccessControl(elementDocument->securityOrigin(
), crossOrigin); | 296 request.setCrossOriginAccessControl(elementDocument->getSecurityOrig
in(), crossOrigin); |
| 297 request.setCharset(scriptCharset()); | 297 request.setCharset(scriptCharset()); |
| 298 | 298 |
| 299 // Skip fetch-related CSP checks if the script element has a valid nonce
, or if dynamically | 299 // Skip fetch-related CSP checks if the script element has a valid nonce
, or if dynamically |
| 300 // injected script is whitelisted and this script is not parser-inserted
. | 300 // injected script is whitelisted and this script is not parser-inserted
. |
| 301 bool scriptPassesCSP = elementDocument->contentSecurityPolicy()->allowSc
riptWithNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)) || (!isParserIn
serted() && elementDocument->contentSecurityPolicy()->allowDynamic()); | 301 bool scriptPassesCSP = elementDocument->contentSecurityPolicy()->allowSc
riptWithNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)) || (!isParserIn
serted() && elementDocument->contentSecurityPolicy()->allowDynamic()); |
| 302 | 302 |
| 303 if (scriptPassesCSP) | 303 if (scriptPassesCSP) |
| 304 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); | 304 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); |
| 305 request.setDefer(defer); | 305 request.setDefer(defer); |
| 306 | 306 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 333 { | 333 { |
| 334 ASSERT(element); | 334 ASSERT(element); |
| 335 return isSVGScriptElement(*element); | 335 return isSVGScriptElement(*element); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void ScriptLoader::logScriptMimetype(ScriptResource* resource, LocalFrame* frame
, String mimetype) | 338 void ScriptLoader::logScriptMimetype(ScriptResource* resource, LocalFrame* frame
, String mimetype) |
| 339 { | 339 { |
| 340 bool text = mimetype.lower().startsWith("text/"); | 340 bool text = mimetype.lower().startsWith("text/"); |
| 341 bool application = mimetype.lower().startsWith("application/"); | 341 bool application = mimetype.lower().startsWith("application/"); |
| 342 bool expectedJs = MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimetype)
|| (text && isLegacySupportedJavaScriptLanguage(mimetype.substring(5))); | 342 bool expectedJs = MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimetype)
|| (text && isLegacySupportedJavaScriptLanguage(mimetype.substring(5))); |
| 343 bool sameOrigin = m_element->document().securityOrigin()->canRequest(m_resou
rce->url()); | 343 bool sameOrigin = m_element->document().getSecurityOrigin()->canRequest(m_re
source->url()); |
| 344 if (expectedJs) { | 344 if (expectedJs) { |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 UseCounter::Feature feature = sameOrigin ? (text ? UseCounter::SameOriginTex
tScript : application ? UseCounter::SameOriginApplicationScript : UseCounter::Sa
meOriginOtherScript) : (text ? UseCounter::CrossOriginTextScript : application ?
UseCounter::CrossOriginApplicationScript : UseCounter::CrossOriginOtherScript); | 347 UseCounter::Feature feature = sameOrigin ? (text ? UseCounter::SameOriginTex
tScript : application ? UseCounter::SameOriginApplicationScript : UseCounter::Sa
meOriginOtherScript) : (text ? UseCounter::CrossOriginTextScript : application ?
UseCounter::CrossOriginApplicationScript : UseCounter::CrossOriginOtherScript); |
| 348 UseCounter::count(frame, feature); | 348 UseCounter::count(frame, feature); |
| 349 } | 349 } |
| 350 | 350 |
| 351 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com
pilationFinishTime) | 351 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com
pilationFinishTime) |
| 352 { | 352 { |
| 353 ASSERT(m_alreadyStarted); | 353 ASSERT(m_alreadyStarted); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 398 |
| 399 AccessControlStatus accessControlStatus = NotSharableCrossOrigin; | 399 AccessControlStatus accessControlStatus = NotSharableCrossOrigin; |
| 400 if (!m_isExternalScript) { | 400 if (!m_isExternalScript) { |
| 401 accessControlStatus = SharableCrossOrigin; | 401 accessControlStatus = SharableCrossOrigin; |
| 402 } else if (sourceCode.resource()) { | 402 } else if (sourceCode.resource()) { |
| 403 if (sourceCode.resource()->response().wasFetchedViaServiceWorker()) { | 403 if (sourceCode.resource()->response().wasFetchedViaServiceWorker()) { |
| 404 if (sourceCode.resource()->response().serviceWorkerResponseType() ==
WebServiceWorkerResponseTypeOpaque) | 404 if (sourceCode.resource()->response().serviceWorkerResponseType() ==
WebServiceWorkerResponseTypeOpaque) |
| 405 accessControlStatus = OpaqueResource; | 405 accessControlStatus = OpaqueResource; |
| 406 else | 406 else |
| 407 accessControlStatus = SharableCrossOrigin; | 407 accessControlStatus = SharableCrossOrigin; |
| 408 } else if (sourceCode.resource()->passesAccessControlCheck(m_element->do
cument().securityOrigin())) { | 408 } else if (sourceCode.resource()->passesAccessControlCheck(m_element->do
cument().getSecurityOrigin())) { |
| 409 accessControlStatus = SharableCrossOrigin; | 409 accessControlStatus = SharableCrossOrigin; |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 const bool isImportedScript = contextDocument != elementDocument; | 413 const bool isImportedScript = contextDocument != elementDocument; |
| 414 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo
ck step 2.3 | 414 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo
ck step 2.3 |
| 415 // with additional support for HTML imports. | 415 // with additional support for HTML imports. |
| 416 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente
r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); | 416 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente
r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); |
| 417 | 417 |
| 418 if (isHTMLScriptLoader(m_element)) | 418 if (isHTMLScriptLoader(m_element)) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 if (isHTMLScriptLoader(element)) | 513 if (isHTMLScriptLoader(element)) |
| 514 return toHTMLScriptElement(element)->loader(); | 514 return toHTMLScriptElement(element)->loader(); |
| 515 | 515 |
| 516 if (isSVGScriptLoader(element)) | 516 if (isSVGScriptLoader(element)) |
| 517 return toSVGScriptElement(element)->loader(); | 517 return toSVGScriptElement(element)->loader(); |
| 518 | 518 |
| 519 return 0; | 519 return 0; |
| 520 } | 520 } |
| 521 | 521 |
| 522 } // namespace blink | 522 } // namespace blink |
| OLD | NEW |