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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 343 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); |
344 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get(); | 344 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get(); |
345 if (!contextDocument) | 345 if (!contextDocument) |
346 return true; | 346 return true; |
347 | 347 |
348 LocalFrame* frame = contextDocument->frame(); | 348 LocalFrame* frame = contextDocument->frame(); |
349 | 349 |
350 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy(); | 350 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy(); |
351 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo rldCSP()) | 351 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo rldCSP()) |
352 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc eAttr)) | 352 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc eAttr)) |
353 || csp->allowScriptWithHash(sourceCode.source()); | 353 || csp->allowScriptWithHash(sourceCode.source().toString()); |
354 | 354 |
355 if (!m_isExternalScript && (!shouldBypassMainWorldCSP && !csp->allowInlineSc ript(elementDocument->url(), m_startLineNumber, sourceCode.source()))) { | 355 if (!m_isExternalScript && (!shouldBypassMainWorldCSP && !csp->allowInlineSc ript(elementDocument->url(), m_startLineNumber, sourceCode.source().toString())) ) { |
356 return false; | 356 return false; |
357 } | 357 } |
358 | 358 |
359 if (m_isExternalScript) { | 359 if (m_isExternalScript) { |
360 ScriptResource* resource = m_resource ? m_resource.get() : sourceCode.re source(); | 360 ScriptResource* resource = m_resource ? m_resource.get() : sourceCode.re source(); |
361 if (resource && !resource->mimeTypeAllowedByNosniff()) { | 361 if (resource && !resource->mimeTypeAllowedByNosniff()) { |
362 contextDocument->addConsoleMessage(ConsoleMessage::create(SecurityMe ssageSource, ErrorMessageLevel, "Refused to execute script from '" + resource->u rl().elidedString() + "' because its MIME type ('" + resource->mimeType() + "') is not executable, and strict MIME type checking is enabled.")); | 362 contextDocument->addConsoleMessage(ConsoleMessage::create(SecurityMe ssageSource, ErrorMessageLevel, "Refused to execute script from '" + resource->u rl().elidedString() + "' because its MIME type ('" + resource->mimeType() + "') is not executable, and strict MIME type checking is enabled.")); |
363 return false; | 363 return false; |
364 } | 364 } |
365 | 365 |
(...skipping 27 matching lines...) Expand all Loading... | |
393 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3 | 393 // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-blo ck step 2.3 |
394 // with additional support for HTML imports. | 394 // with additional support for HTML imports. |
395 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); | 395 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncremente r(m_isExternalScript || isImportedScript ? contextDocument.get() : 0); |
396 | 396 |
397 if (isHTMLScriptLoader(m_element)) | 397 if (isHTMLScriptLoader(m_element)) |
398 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element)); | 398 contextDocument->pushCurrentScript(toHTMLScriptElement(m_element)); |
399 | 399 |
400 // Create a script from the script element node, using the script | 400 // Create a script from the script element node, using the script |
401 // block's source and the script block's type. | 401 // block's source and the script block's type. |
402 // Note: This is where the script is compiled and actually executed. | 402 // Note: This is where the script is compiled and actually executed. |
403 | |
hajimehoshi
2015/11/26 10:56:20
nit
| |
403 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime); | 404 frame->script().executeScriptInMainWorld(sourceCode, accessControlStatus, co mpilationFinishTime); |
404 | 405 |
405 if (isHTMLScriptLoader(m_element)) { | 406 if (isHTMLScriptLoader(m_element)) { |
406 ASSERT(contextDocument->currentScript() == m_element); | 407 ASSERT(contextDocument->currentScript() == m_element); |
407 contextDocument->popCurrentScript(); | 408 contextDocument->popCurrentScript(); |
408 } | 409 } |
409 | 410 |
410 return true; | 411 return true; |
411 } | 412 } |
412 | 413 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 if (isHTMLScriptLoader(element)) | 501 if (isHTMLScriptLoader(element)) |
501 return toHTMLScriptElement(element)->loader(); | 502 return toHTMLScriptElement(element)->loader(); |
502 | 503 |
503 if (isSVGScriptLoader(element)) | 504 if (isSVGScriptLoader(element)) |
504 return toSVGScriptElement(element)->loader(); | 505 return toSVGScriptElement(element)->loader(); |
505 | 506 |
506 return 0; | 507 return 0; |
507 } | 508 } |
508 | 509 |
509 } // namespace blink | 510 } // namespace blink |
OLD | NEW |