| 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 | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| 11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
| 13 * | 13 * |
| 14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
| 18 * | 18 * |
| 19 * You should have received a copy of the GNU Library General Public License | 19 * You should have received a copy of the GNU Library General Public License |
| 20 * along with this library; see the file COPYING.LIB. If not, write to | 20 * along with this library; see the file COPYING.LIB. If not, write to |
| 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "core/dom/ScriptLoader.h" | 25 #include "core/dom/ScriptLoader.h" |
| 26 | 26 |
| 27 #include "bindings/core/v8/ScriptController.h" | 27 #include "bindings/core/v8/ScriptController.h" |
| 28 #include "bindings/core/v8/ScriptSourceCode.h" | 28 #include "bindings/core/v8/ScriptSourceCode.h" |
| 29 #include "bindings/core/v8/V8Binding.h" | |
| 30 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 31 #include "core/SVGNames.h" | 30 #include "core/SVGNames.h" |
| 31 #include "core/dom/ClassicPendingScript.h" |
| 32 #include "core/dom/ClassicScript.h" | 32 #include "core/dom/ClassicScript.h" |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/DocumentParserTiming.h" | 34 #include "core/dom/DocumentParserTiming.h" |
| 35 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" | 35 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" |
| 36 #include "core/dom/Script.h" | 36 #include "core/dom/Script.h" |
| 37 #include "core/dom/ScriptElementBase.h" | 37 #include "core/dom/ScriptElementBase.h" |
| 38 #include "core/dom/ScriptRunner.h" | 38 #include "core/dom/ScriptRunner.h" |
| 39 #include "core/dom/ScriptableDocumentParser.h" | 39 #include "core/dom/ScriptableDocumentParser.h" |
| 40 #include "core/dom/Text.h" | 40 #include "core/dom/Text.h" |
| 41 #include "core/events/Event.h" | 41 #include "core/events/Event.h" |
| 42 #include "core/frame/LocalFrame.h" | 42 #include "core/frame/LocalFrame.h" |
| 43 #include "core/frame/SubresourceIntegrity.h" | 43 #include "core/frame/SubresourceIntegrity.h" |
| 44 #include "core/frame/csp/ContentSecurityPolicy.h" | 44 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 45 #include "core/html/CrossOriginAttribute.h" | 45 #include "core/html/CrossOriginAttribute.h" |
| 46 #include "core/html/imports/HTMLImport.h" | 46 #include "core/html/imports/HTMLImport.h" |
| 47 #include "core/html/parser/HTMLParserIdioms.h" | 47 #include "core/html/parser/HTMLParserIdioms.h" |
| 48 #include "platform/WebFrameScheduler.h" | 48 #include "platform/WebFrameScheduler.h" |
| 49 #include "platform/loader/fetch/AccessControlStatus.h" | 49 #include "platform/loader/fetch/AccessControlStatus.h" |
| 50 #include "platform/loader/fetch/FetchParameters.h" | 50 #include "platform/loader/fetch/FetchParameters.h" |
| 51 #include "platform/loader/fetch/MemoryCache.h" | |
| 52 #include "platform/loader/fetch/ResourceFetcher.h" | 51 #include "platform/loader/fetch/ResourceFetcher.h" |
| 53 #include "platform/network/mime/MIMETypeRegistry.h" | 52 #include "platform/network/mime/MIMETypeRegistry.h" |
| 54 #include "platform/weborigin/SecurityOrigin.h" | 53 #include "platform/weborigin/SecurityOrigin.h" |
| 55 #include "platform/wtf/StdLibExtras.h" | 54 #include "platform/wtf/StdLibExtras.h" |
| 56 #include "platform/wtf/text/StringBuilder.h" | 55 #include "platform/wtf/text/StringBuilder.h" |
| 57 #include "platform/wtf/text/StringHash.h" | 56 #include "platform/wtf/text/StringHash.h" |
| 58 #include "public/platform/WebCachePolicy.h" | 57 #include "public/platform/WebCachePolicy.h" |
| 59 | 58 |
| 60 namespace blink { | 59 namespace blink { |
| 61 | 60 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 WebCachePolicy::kReturnCacheDataDontLoad) { | 585 WebCachePolicy::kReturnCacheDataDontLoad) { |
| 587 document_write_intervention_ = | 586 document_write_intervention_ = |
| 588 DocumentWriteIntervention::kDoNotFetchDocWrittenScript; | 587 DocumentWriteIntervention::kDoNotFetchDocWrittenScript; |
| 589 } | 588 } |
| 590 | 589 |
| 591 return true; | 590 return true; |
| 592 } | 591 } |
| 593 | 592 |
| 594 PendingScript* ScriptLoader::CreatePendingScript() { | 593 PendingScript* ScriptLoader::CreatePendingScript() { |
| 595 CHECK(resource_); | 594 CHECK(resource_); |
| 596 return PendingScript::Create(element_, resource_); | 595 return ClassicPendingScript::Create(element_, resource_); |
| 597 } | 596 } |
| 598 | 597 |
| 599 bool ScriptLoader::ExecuteScript(const Script* script) { | 598 bool ScriptLoader::ExecuteScript(const Script* script) { |
| 600 double script_exec_start_time = MonotonicallyIncreasingTime(); | 599 double script_exec_start_time = MonotonicallyIncreasingTime(); |
| 601 bool result = DoExecuteScript(script); | 600 bool result = DoExecuteScript(script); |
| 602 | 601 |
| 603 // NOTE: we do not check m_willBeParserExecuted here, since | 602 // NOTE: we do not check m_willBeParserExecuted here, since |
| 604 // m_willBeParserExecuted is false for inline scripts, and we want to | 603 // m_willBeParserExecuted is false for inline scripts, and we want to |
| 605 // include inline script execution time as part of parser blocked script | 604 // include inline script execution time as part of parser blocked script |
| 606 // execution time. | 605 // execution time. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 return true; | 691 return true; |
| 693 | 692 |
| 694 // 7. "Decrement the ignore-destructive-writes counter of neutralized doc, | 693 // 7. "Decrement the ignore-destructive-writes counter of neutralized doc, |
| 695 // if it was incremented in the earlier step." | 694 // if it was incremented in the earlier step." |
| 696 // Implemented as the scope out of IgnoreDestructiveWriteCountIncrementer. | 695 // Implemented as the scope out of IgnoreDestructiveWriteCountIncrementer. |
| 697 } | 696 } |
| 698 | 697 |
| 699 void ScriptLoader::Execute() { | 698 void ScriptLoader::Execute() { |
| 700 DCHECK(!will_be_parser_executed_); | 699 DCHECK(!will_be_parser_executed_); |
| 701 DCHECK(async_exec_type_ != ScriptRunner::kNone); | 700 DCHECK(async_exec_type_ != ScriptRunner::kNone); |
| 702 DCHECK(pending_script_->GetResource()); | 701 DCHECK(pending_script_->IsExternal()); |
| 703 bool error_occurred = false; | 702 bool error_occurred = false; |
| 704 Script* script = pending_script_->GetSource(KURL(), error_occurred); | 703 Script* script = pending_script_->GetSource(KURL(), error_occurred); |
| 704 const bool wasCanceled = pending_script_->WasCanceled(); |
| 705 DetachPendingScript(); | 705 DetachPendingScript(); |
| 706 if (error_occurred) { | 706 if (error_occurred) { |
| 707 DispatchErrorEvent(); | 707 DispatchErrorEvent(); |
| 708 } else if (!resource_->WasCanceled()) { | 708 } else if (!wasCanceled) { |
| 709 if (ExecuteScript(script)) | 709 if (ExecuteScript(script)) |
| 710 DispatchLoadEvent(); | 710 DispatchLoadEvent(); |
| 711 else | 711 else |
| 712 DispatchErrorEvent(); | 712 DispatchErrorEvent(); |
| 713 } | 713 } |
| 714 resource_ = nullptr; | 714 resource_ = nullptr; |
| 715 } | 715 } |
| 716 | 716 |
| 717 void ScriptLoader::PendingScriptFinished(PendingScript* pending_script) { | 717 void ScriptLoader::PendingScriptFinished(PendingScript* pending_script) { |
| 718 DCHECK(!will_be_parser_executed_); | 718 DCHECK(!will_be_parser_executed_); |
| 719 DCHECK_EQ(pending_script_, pending_script); | 719 DCHECK_EQ(pending_script_, pending_script); |
| 720 DCHECK_EQ(pending_script->GetResource(), resource_); | |
| 721 | 720 |
| 722 // We do not need this script in the memory cache. The primary goals of | 721 // We do not need this script in the memory cache. The primary goals of |
| 723 // sending this fetch request are to let the third party server know | 722 // sending this fetch request are to let the third party server know |
| 724 // about the document.write scripts intervention and populate the http | 723 // about the document.write scripts intervention and populate the http |
| 725 // cache for subsequent uses. | 724 // cache for subsequent uses. |
| 726 if (document_write_intervention_ == | 725 if (document_write_intervention_ == |
| 727 DocumentWriteIntervention::kFetchDocWrittenScriptDeferIdle) { | 726 DocumentWriteIntervention::kFetchDocWrittenScriptDeferIdle) { |
| 728 GetMemoryCache()->Remove(pending_script_->GetResource()); | 727 DCHECK_EQ(pending_script_->GetScriptType(), ScriptType::kClassic); |
| 728 pending_script_->RemoveFromMemoryCache(); |
| 729 pending_script_->StopWatchingForLoad(); | 729 pending_script_->StopWatchingForLoad(); |
| 730 return; | 730 return; |
| 731 } | 731 } |
| 732 | 732 |
| 733 DCHECK(async_exec_type_ != ScriptRunner::kNone); | 733 DCHECK(async_exec_type_ != ScriptRunner::kNone); |
| 734 | 734 |
| 735 Document* context_document = element_->GetDocument().ContextDocument(); | 735 Document* context_document = element_->GetDocument().ContextDocument(); |
| 736 if (!context_document) { | 736 if (!context_document) { |
| 737 DetachPendingScript(); | 737 DetachPendingScript(); |
| 738 return; | 738 return; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 // then abort these steps at this point. The script is not executed. | 781 // then abort these steps at this point. The script is not executed. |
| 782 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || | 782 return DeprecatedEqualIgnoringCase(event_attribute, "onload") || |
| 783 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); | 783 DeprecatedEqualIgnoringCase(event_attribute, "onload()"); |
| 784 } | 784 } |
| 785 | 785 |
| 786 String ScriptLoader::ScriptContent() const { | 786 String ScriptLoader::ScriptContent() const { |
| 787 return element_->TextFromChildren(); | 787 return element_->TextFromChildren(); |
| 788 } | 788 } |
| 789 | 789 |
| 790 } // namespace blink | 790 } // namespace blink |
| OLD | NEW |