Implement InlineClassicScript
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 09:01:40 +0000 (09:01 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 09:01:40 +0000 (09:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166925

Reviewed by Ryosuke Niwa.

Source/JavaScriptCore:

Add ScriptFetcher field for SourceOrigin.

* runtime/SourceOrigin.h:
(JSC::SourceOrigin::SourceOrigin):
(JSC::SourceOrigin::fetcher):

Source/WebCore:

As of r210585, ScriptFetcher functionality is decoupled from ScriptElement.
This patch is a further cleanup. We introduce InlineClassicScript, which is
similar to LoadableClassicScript / LoadableModuleScript. And we move ScriptFetcher
functionality from LoadableScript to CachedScriptFetcher, which is the base
class of InlineClassicScript and LoadableScript.

And we start setting this CachedScriptFetcher to the member of JSC::SourceOrigin.
This allows us to examine the ScriptFetcher from the SourceOrigin.
When dynamic-import operator is called, we need to get the ScriptFetcher from the
caller script SourceOrigin since the subsequent module loading needs to know the
metadata about fetching and ScriptFetcher delivers it.

No behavior change.

* CMakeLists.txt:
* bindings/js/CachedModuleScript.cpp:
(WebCore::CachedModuleScript::load):
* bindings/js/CachedModuleScript.h:
* bindings/js/CachedModuleScriptLoader.cpp:
(WebCore::CachedModuleScriptLoader::create):
(WebCore::CachedModuleScriptLoader::CachedModuleScriptLoader):
(WebCore::CachedModuleScriptLoader::load):
* bindings/js/CachedModuleScriptLoader.h:
* bindings/js/CachedScriptFetcher.cpp: Copied from Source/WebCore/dom/LoadableScript.cpp.
(WebCore::CachedScriptFetcher::requestScriptWithCache):
* bindings/js/CachedScriptFetcher.h: Copied from Source/JavaScriptCore/runtime/SourceOrigin.h.
(WebCore::CachedScriptFetcher::CachedScriptFetcher):
* bindings/js/CachedScriptSourceProvider.h:
(WebCore::CachedScriptSourceProvider::create):
(WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):
(WebCore::makeSource): Deleted.
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::loadModuleScriptInWorld):
(WebCore::ScriptController::loadModuleScript):
* bindings/js/ScriptController.h:
* bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::fetch):
(WebCore::ScriptModuleLoader::notifyFinished):
* bindings/js/ScriptSourceCode.h:
(WebCore::ScriptSourceCode::ScriptSourceCode):
(WebCore::ScriptSourceCode::m_url):
* dom/InlineClassicScript.cpp: Added.
(WebCore::InlineClassicScript::create):
* dom/InlineClassicScript.h: Added.
* dom/LoadableClassicScript.cpp:
(WebCore::LoadableClassicScript::execute):
* dom/LoadableScript.cpp:
(WebCore::LoadableScript::requestScriptWithCache): Deleted.
* dom/LoadableScript.h:
(WebCore::LoadableScript::LoadableScript):
(): Deleted.
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::prepareScript):
(WebCore::ScriptElement::requestModuleScript):
(WebCore::ScriptElement::executePendingScript):
* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::runScript):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::endElementNs):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210627 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/SourceOrigin.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/CachedModuleScript.cpp
Source/WebCore/bindings/js/CachedModuleScript.h
Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp
Source/WebCore/bindings/js/CachedModuleScriptLoader.h
Source/WebCore/bindings/js/CachedScriptFetcher.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/CachedScriptFetcher.h [new file with mode: 0644]
Source/WebCore/bindings/js/CachedScriptSourceProvider.h
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/js/ScriptController.h
Source/WebCore/bindings/js/ScriptModuleLoader.cpp
Source/WebCore/bindings/js/ScriptSourceCode.h
Source/WebCore/dom/InlineClassicScript.cpp [new file with mode: 0644]
Source/WebCore/dom/InlineClassicScript.h [new file with mode: 0644]
Source/WebCore/dom/LoadableClassicScript.cpp
Source/WebCore/dom/LoadableScript.cpp
Source/WebCore/dom/LoadableScript.h
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/html/parser/HTMLScriptRunner.cpp
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

index 9c4cb32..5622448 100644 (file)
@@ -1,3 +1,16 @@
+2017-01-12  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Implement InlineClassicScript
+        https://bugs.webkit.org/show_bug.cgi?id=166925
+
+        Reviewed by Ryosuke Niwa.
+
+        Add ScriptFetcher field for SourceOrigin.
+
+        * runtime/SourceOrigin.h:
+        (JSC::SourceOrigin::SourceOrigin):
+        (JSC::SourceOrigin::fetcher):
+
 2017-01-11  Andreas Kling  <akling@apple.com>
 
         Crash when WebCore's GC heap grows way too large.
index f42a0d3..7c3cdeb 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "ScriptFetcher.h"
 #include <wtf/text/WTFString.h>
 
 namespace JSC {
@@ -36,13 +37,22 @@ public:
     {
     }
 
+    explicit SourceOrigin(const String& string, Ref<ScriptFetcher>&& fetcher)
+        : m_string(string)
+        , m_fetcher(WTFMove(fetcher))
+    {
+    }
+
     SourceOrigin() = default;
 
     const String& string() const { return m_string; }
     bool isNull() const { return m_string.isNull(); }
 
+    ScriptFetcher* fetcher() const { return m_fetcher.get(); }
+
 private:
     String m_string;
+    RefPtr<ScriptFetcher> m_fetcher;
 };
 
 } // namespace JSC
index 0b7ae41..588b6bd 100644 (file)
@@ -1067,6 +1067,7 @@ set(WebCore_SOURCES
 
     bindings/js/CachedModuleScript.cpp
     bindings/js/CachedModuleScriptLoader.cpp
+    bindings/js/CachedScriptFetcher.cpp
     bindings/js/CallbackFunction.cpp
     bindings/js/CommonVM.cpp
     bindings/js/DOMWrapperWorld.cpp
@@ -1442,6 +1443,7 @@ set(WebCore_SOURCES
     dom/GenericEventQueue.cpp
     dom/IdTargetObserver.cpp
     dom/IdTargetObserverRegistry.cpp
+    dom/InlineClassicScript.cpp
     dom/InlineStyleSheetOwner.cpp
     dom/InputEvent.cpp
     dom/KeyboardEvent.cpp
index 31c1544..d07eec2 100644 (file)
@@ -1,3 +1,70 @@
+2017-01-12  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Implement InlineClassicScript
+        https://bugs.webkit.org/show_bug.cgi?id=166925
+
+        Reviewed by Ryosuke Niwa.
+
+        As of r210585, ScriptFetcher functionality is decoupled from ScriptElement.
+        This patch is a further cleanup. We introduce InlineClassicScript, which is
+        similar to LoadableClassicScript / LoadableModuleScript. And we move ScriptFetcher
+        functionality from LoadableScript to CachedScriptFetcher, which is the base
+        class of InlineClassicScript and LoadableScript.
+
+        And we start setting this CachedScriptFetcher to the member of JSC::SourceOrigin.
+        This allows us to examine the ScriptFetcher from the SourceOrigin.
+        When dynamic-import operator is called, we need to get the ScriptFetcher from the
+        caller script SourceOrigin since the subsequent module loading needs to know the
+        metadata about fetching and ScriptFetcher delivers it.
+
+        No behavior change.
+
+        * CMakeLists.txt:
+        * bindings/js/CachedModuleScript.cpp:
+        (WebCore::CachedModuleScript::load):
+        * bindings/js/CachedModuleScript.h:
+        * bindings/js/CachedModuleScriptLoader.cpp:
+        (WebCore::CachedModuleScriptLoader::create):
+        (WebCore::CachedModuleScriptLoader::CachedModuleScriptLoader):
+        (WebCore::CachedModuleScriptLoader::load):
+        * bindings/js/CachedModuleScriptLoader.h:
+        * bindings/js/CachedScriptFetcher.cpp: Copied from Source/WebCore/dom/LoadableScript.cpp.
+        (WebCore::CachedScriptFetcher::requestScriptWithCache):
+        * bindings/js/CachedScriptFetcher.h: Copied from Source/JavaScriptCore/runtime/SourceOrigin.h.
+        (WebCore::CachedScriptFetcher::CachedScriptFetcher):
+        * bindings/js/CachedScriptSourceProvider.h:
+        (WebCore::CachedScriptSourceProvider::create):
+        (WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):
+        (WebCore::makeSource): Deleted.
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::loadModuleScriptInWorld):
+        (WebCore::ScriptController::loadModuleScript):
+        * bindings/js/ScriptController.h:
+        * bindings/js/ScriptModuleLoader.cpp:
+        (WebCore::ScriptModuleLoader::fetch):
+        (WebCore::ScriptModuleLoader::notifyFinished):
+        * bindings/js/ScriptSourceCode.h:
+        (WebCore::ScriptSourceCode::ScriptSourceCode):
+        (WebCore::ScriptSourceCode::m_url):
+        * dom/InlineClassicScript.cpp: Added.
+        (WebCore::InlineClassicScript::create):
+        * dom/InlineClassicScript.h: Added.
+        * dom/LoadableClassicScript.cpp:
+        (WebCore::LoadableClassicScript::execute):
+        * dom/LoadableScript.cpp:
+        (WebCore::LoadableScript::requestScriptWithCache): Deleted.
+        * dom/LoadableScript.h:
+        (WebCore::LoadableScript::LoadableScript):
+        (): Deleted.
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::prepareScript):
+        (WebCore::ScriptElement::requestModuleScript):
+        (WebCore::ScriptElement::executePendingScript):
+        * html/parser/HTMLScriptRunner.cpp:
+        (WebCore::HTMLScriptRunner::runScript):
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::endElementNs):
+
 2017-01-11  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream, Mac] Render media stream audio buffers
index 0fec4b5..8374812 100644 (file)
@@ -43,16 +43,16 @@ Ref<CachedModuleScript> CachedModuleScript::create()
     return adoptRef(*new CachedModuleScript());
 }
 
-void CachedModuleScript::load(Document& document, const URL& rootURL, LoadableScript& loadableScript)
+void CachedModuleScript::load(Document& document, const URL& rootURL, CachedScriptFetcher& scriptFetcher)
 {
     if (auto* frame = document.frame())
-        frame->script().loadModuleScript(*this, rootURL.string(), loadableScript);
+        frame->script().loadModuleScript(*this, rootURL.string(), scriptFetcher);
 }
 
-void CachedModuleScript::load(Document& document, const ScriptSourceCode& sourceCode, LoadableScript& loadableScript)
+void CachedModuleScript::load(Document& document, const ScriptSourceCode& sourceCode, CachedScriptFetcher& scriptFetcher)
 {
     if (auto* frame = document.frame())
-        frame->script().loadModuleScript(*this, sourceCode, loadableScript);
+        frame->script().loadModuleScript(*this, sourceCode, scriptFetcher);
 }
 
 void CachedModuleScript::notifyLoadCompleted(UniquedStringImpl& moduleKey)
index 562d93d..ab8f90a 100644 (file)
@@ -52,8 +52,8 @@ public:
 
     static Ref<CachedModuleScript> create();
 
-    void load(Document&, const URL& rootURL, LoadableScript&);
-    void load(Document&, const ScriptSourceCode&, LoadableScript&);
+    void load(Document&, const URL& rootURL, CachedScriptFetcher&);
+    void load(Document&, const ScriptSourceCode&, CachedScriptFetcher&);
 
 private:
     void notifyClientFinished();
index 60bdd48..44e9fe7 100644 (file)
 #include "CachedModuleScriptLoader.h"
 
 #include "CachedScript.h"
+#include "CachedScriptFetcher.h"
 #include "DOMWrapperWorld.h"
 #include "Frame.h"
 #include "JSDOMBinding.h"
-#include "LoadableScript.h"
 #include "ResourceLoaderOptions.h"
 #include "ScriptController.h"
 #include "ScriptModuleLoader.h"
 
 namespace WebCore {
 
-Ref<CachedModuleScriptLoader> CachedModuleScriptLoader::create(CachedModuleScriptLoaderClient& client, DeferredPromise& promise)
+Ref<CachedModuleScriptLoader> CachedModuleScriptLoader::create(CachedModuleScriptLoaderClient& client, DeferredPromise& promise, CachedScriptFetcher& scriptFetcher)
 {
-    return adoptRef(*new CachedModuleScriptLoader(client, promise));
+    return adoptRef(*new CachedModuleScriptLoader(client, promise, scriptFetcher));
 }
 
-CachedModuleScriptLoader::CachedModuleScriptLoader(CachedModuleScriptLoaderClient& client, DeferredPromise& promise)
+CachedModuleScriptLoader::CachedModuleScriptLoader(CachedModuleScriptLoaderClient& client, DeferredPromise& promise, CachedScriptFetcher& scriptFetcher)
     : m_client(&client)
     , m_promise(&promise)
+    , m_scriptFetcher(scriptFetcher)
 {
 }
 
@@ -57,10 +58,10 @@ CachedModuleScriptLoader::~CachedModuleScriptLoader()
     }
 }
 
-bool CachedModuleScriptLoader::load(Document& document, LoadableScript& loadableScript, const URL& sourceURL)
+bool CachedModuleScriptLoader::load(Document& document, const URL& sourceURL)
 {
     ASSERT(!m_cachedScript);
-    m_cachedScript = loadableScript.requestScriptWithCache(document, sourceURL);
+    m_cachedScript = m_scriptFetcher->requestScriptWithCache(document, sourceURL);
     if (!m_cachedScript)
         return false;
 
index 32fde3b..04923f4 100644 (file)
@@ -35,20 +35,21 @@ namespace WebCore {
 
 class CachedModuleScriptLoaderClient;
 class CachedScript;
+class CachedScriptFetcher;
 class DeferredPromise;
 class Document;
 class JSDOMGlobalObject;
-class LoadableScript;
 class URL;
 
 class CachedModuleScriptLoader final : public RefCounted<CachedModuleScriptLoader>, private CachedResourceClient {
 public:
-    static Ref<CachedModuleScriptLoader> create(CachedModuleScriptLoaderClient&, DeferredPromise&);
+    static Ref<CachedModuleScriptLoader> create(CachedModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&);
 
     virtual ~CachedModuleScriptLoader();
 
-    bool load(Document&, LoadableScript&, const URL& sourceURL);
+    bool load(Document&, const URL& sourceURL);
 
+    CachedScriptFetcher& scriptFetcher() { return m_scriptFetcher.get(); }
     CachedScript* cachedScript() { return m_cachedScript.get(); }
 
     void clearClient()
@@ -58,12 +59,13 @@ public:
     }
 
 private:
-    CachedModuleScriptLoader(CachedModuleScriptLoaderClient&, DeferredPromise&);
+    CachedModuleScriptLoader(CachedModuleScriptLoaderClient&, DeferredPromise&, CachedScriptFetcher&);
 
     void notifyFinished(CachedResource&) final;
 
     CachedModuleScriptLoaderClient* m_client { nullptr };
     RefPtr<DeferredPromise> m_promise;
+    Ref<CachedScriptFetcher> m_scriptFetcher;
     CachedResourceHandle<CachedScript> m_cachedScript;
 };
 
diff --git a/Source/WebCore/bindings/js/CachedScriptFetcher.cpp b/Source/WebCore/bindings/js/CachedScriptFetcher.cpp
new file mode 100644 (file)
index 0000000..668e3cb
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CachedScriptFetcher.h"
+
+#include "CachedResourceLoader.h"
+#include "CachedScript.h"
+#include "ContentSecurityPolicy.h"
+#include "Document.h"
+#include "Settings.h"
+
+namespace WebCore {
+
+CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(Document& document, const URL& sourceURL) const
+{
+    auto* settings = document.settings();
+    if (settings && !settings->isScriptEnabled())
+        return nullptr;
+
+    ASSERT(document.contentSecurityPolicy());
+    bool hasKnownNonce = document.contentSecurityPolicy()->allowScriptWithNonce(m_nonce, m_isInUserAgentShadowTree);
+    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
+    options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
+
+    CachedResourceRequest request(ResourceRequest(sourceURL), options);
+    request.setAsPotentiallyCrossOrigin(m_crossOriginMode, document);
+    request.upgradeInsecureRequestIfNeeded(document);
+
+    request.setCharset(m_charset);
+    request.setInitiator(m_initiatorName);
+
+    return document.cachedResourceLoader().requestScript(WTFMove(request));
+}
+
+}
diff --git a/Source/WebCore/bindings/js/CachedScriptFetcher.h b/Source/WebCore/bindings/js/CachedScriptFetcher.h
new file mode 100644 (file)
index 0000000..3f8d889
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CachedResourceHandle.h"
+#include <runtime/ScriptFetcher.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class CachedScript;
+class Document;
+class URL;
+
+class CachedScriptFetcher : public JSC::ScriptFetcher {
+public:
+    CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL) const;
+
+protected:
+    CachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
+        : m_nonce(nonce)
+        , m_crossOriginMode(crossOriginMode)
+        , m_charset(charset)
+        , m_initiatorName(initiatorName)
+        , m_isInUserAgentShadowTree(isInUserAgentShadowTree)
+    {
+    }
+
+private:
+    String m_nonce;
+    String m_crossOriginMode;
+    String m_charset;
+    AtomicString m_initiatorName;
+    bool m_isInUserAgentShadowTree { false };
+};
+
+} // namespace WebCore
index d38cafb..47494e7 100644 (file)
@@ -28,6 +28,7 @@
 #include "CachedResourceClient.h"
 #include "CachedResourceHandle.h"
 #include "CachedScript.h"
+#include "CachedScriptFetcher.h"
 #include <parser/SourceCode.h>
 #include <parser/SourceProvider.h>
 
@@ -36,7 +37,7 @@ namespace WebCore {
 class CachedScriptSourceProvider : public JSC::SourceProvider, public CachedResourceClient {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static Ref<CachedScriptSourceProvider> create(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType) { return adoptRef(*new CachedScriptSourceProvider(cachedScript, sourceType)); }
+    static Ref<CachedScriptSourceProvider> create(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType, Ref<CachedScriptFetcher>&& scriptFetcher) { return adoptRef(*new CachedScriptSourceProvider(cachedScript, sourceType, WTFMove(scriptFetcher))); }
 
     virtual ~CachedScriptSourceProvider()
     {
@@ -47,8 +48,8 @@ public:
     StringView source() const override { return m_cachedScript->script(); }
 
 private:
-    CachedScriptSourceProvider(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType)
-        : SourceProvider(JSC::SourceOrigin { cachedScript->response().url() }, cachedScript->response().url(), TextPosition(), sourceType)
+    CachedScriptSourceProvider(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType, Ref<CachedScriptFetcher>&& scriptFetcher)
+        : SourceProvider(JSC::SourceOrigin { cachedScript->response().url(), WTFMove(scriptFetcher) }, cachedScript->response().url(), TextPosition(), sourceType)
         , m_cachedScript(cachedScript)
     {
         m_cachedScript->addClient(*this);
@@ -57,9 +58,4 @@ private:
     CachedResourceHandle<CachedScript> m_cachedScript;
 };
 
-inline JSC::SourceCode makeSource(CachedScript* cachedScript)
-{
-    return JSC::SourceCode(CachedScriptSourceProvider::create(cachedScript, JSC::SourceProviderSourceType::Program));
-}
-
 } // namespace WebCore
index 3237635..0eff40d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "BridgeJSC.h"
 #include "CachedModuleScript.h"
+#include "CachedScriptFetcher.h"
 #include "CommonVM.h"
 #include "ContentSecurityPolicy.h"
 #include "DocumentLoader.h"
@@ -186,36 +187,36 @@ JSValue ScriptController::evaluate(const ScriptSourceCode& sourceCode, Exception
     return evaluateInWorld(sourceCode, mainThreadNormalWorld(), exceptionDetails);
 }
 
-void ScriptController::loadModuleScriptInWorld(CachedModuleScript& moduleScript, const String& moduleName, LoadableScript& loadableScript, DOMWrapperWorld& world)
+void ScriptController::loadModuleScriptInWorld(CachedModuleScript& moduleScript, const String& moduleName, CachedScriptFetcher& scriptFetcher, DOMWrapperWorld& world)
 {
     JSLockHolder lock(world.vm());
 
     auto& shell = *windowShell(world);
     auto& state = *shell.window()->globalExec();
 
-    auto& promise = JSMainThreadExecState::loadModule(state, moduleName, JSC::JSScriptFetcher::create(state.vm(), { &loadableScript }));
+    auto& promise = JSMainThreadExecState::loadModule(state, moduleName, JSC::JSScriptFetcher::create(state.vm(), { &scriptFetcher }));
     setupModuleScriptHandlers(moduleScript, promise, world);
 }
 
-void ScriptController::loadModuleScript(CachedModuleScript& moduleScript, const String& moduleName, LoadableScript& loadableScript)
+void ScriptController::loadModuleScript(CachedModuleScript& moduleScript, const String& moduleName, CachedScriptFetcher& scriptFetcher)
 {
-    loadModuleScriptInWorld(moduleScript, moduleName, loadableScript, mainThreadNormalWorld());
+    loadModuleScriptInWorld(moduleScript, moduleName, scriptFetcher, mainThreadNormalWorld());
 }
 
-void ScriptController::loadModuleScriptInWorld(CachedModuleScript& moduleScript, const ScriptSourceCode& sourceCode, LoadableScript& loadableScript, DOMWrapperWorld& world)
+void ScriptController::loadModuleScriptInWorld(CachedModuleScript& moduleScript, const ScriptSourceCode& sourceCode, CachedScriptFetcher& scriptFetcher, DOMWrapperWorld& world)
 {
     JSLockHolder lock(world.vm());
 
     auto& shell = *windowShell(world);
     auto& state = *shell.window()->globalExec();
 
-    auto& promise = JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(state.vm(), { &loadableScript }));
+    auto& promise = JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(state.vm(), { &scriptFetcher }));
     setupModuleScriptHandlers(moduleScript, promise, world);
 }
 
-void ScriptController::loadModuleScript(CachedModuleScript& moduleScript, const ScriptSourceCode& sourceCode, LoadableScript& loadableScript)
+void ScriptController::loadModuleScript(CachedModuleScript& moduleScript, const ScriptSourceCode& sourceCode, CachedScriptFetcher& scriptFetcher)
 {
-    loadModuleScriptInWorld(moduleScript, sourceCode, loadableScript, mainThreadNormalWorld());
+    loadModuleScriptInWorld(moduleScript, sourceCode, scriptFetcher, mainThreadNormalWorld());
 }
 
 JSC::JSValue ScriptController::linkAndEvaluateModuleScriptInWorld(CachedModuleScript& moduleScript, DOMWrapperWorld& world)
index 9e20c2c..2e8768c 100644 (file)
@@ -52,10 +52,10 @@ class RootObject;
 namespace WebCore {
 
 class CachedModuleScript;
+class CachedScriptFetcher;
 class Frame;
 class HTMLDocument;
 class HTMLPlugInElement;
-class LoadableScript;
 class SecurityOrigin;
 class ScriptSourceCode;
 class Widget;
@@ -114,10 +114,10 @@ public:
     JSC::JSValue evaluate(const ScriptSourceCode&, ExceptionDetails* = nullptr);
     JSC::JSValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld&, ExceptionDetails* = nullptr);
 
-    void loadModuleScriptInWorld(CachedModuleScript&, const String& moduleName, LoadableScript&, DOMWrapperWorld&);
-    void loadModuleScript(CachedModuleScript&, const String& moduleName, LoadableScript&);
-    void loadModuleScriptInWorld(CachedModuleScript&, const ScriptSourceCode&, LoadableScript&, DOMWrapperWorld&);
-    void loadModuleScript(CachedModuleScript&, const ScriptSourceCode&, LoadableScript&);
+    void loadModuleScriptInWorld(CachedModuleScript&, const String& moduleName, CachedScriptFetcher&, DOMWrapperWorld&);
+    void loadModuleScript(CachedModuleScript&, const String& moduleName, CachedScriptFetcher&);
+    void loadModuleScriptInWorld(CachedModuleScript&, const ScriptSourceCode&, CachedScriptFetcher&, DOMWrapperWorld&);
+    void loadModuleScript(CachedModuleScript&, const ScriptSourceCode&, CachedScriptFetcher&);
 
     JSC::JSValue linkAndEvaluateModuleScriptInWorld(CachedModuleScript& , DOMWrapperWorld&);
     JSC::JSValue linkAndEvaluateModuleScript(CachedModuleScript&);
index 8dd24c3..62a8967 100644 (file)
@@ -159,9 +159,9 @@ JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalO
     }
 
     if (auto* frame = m_document.frame()) {
-        auto loader = CachedModuleScriptLoader::create(*this, deferred.get());
+        auto loader = CachedModuleScriptLoader::create(*this, deferred.get(), *static_cast<CachedScriptFetcher*>(JSC::jsCast<JSC::JSScriptFetcher*>(scriptFetcher)->fetcher()));
         m_loaders.add(loader.copyRef());
-        if (!loader->load(m_document, *static_cast<LoadableScript*>(JSC::jsCast<JSC::JSScriptFetcher*>(scriptFetcher)->fetcher()), completedURL)) {
+        if (!loader->load(m_document, completedURL)) {
             loader->clearClient();
             m_loaders.remove(WTFMove(loader));
             deferred->reject(frame->script().moduleLoaderAlreadyReportedErrorSymbol());
@@ -243,7 +243,7 @@ void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr
     }
 
     m_requestURLToResponseURLMap.add(cachedScript.url(), cachedScript.response().url());
-    ScriptSourceCode scriptSourceCode(&cachedScript, JSC::SourceProviderSourceType::Module);
+    ScriptSourceCode scriptSourceCode(&cachedScript, JSC::SourceProviderSourceType::Module, loader.scriptFetcher());
     promise->resolveWithCallback([] (JSC::ExecState& state, JSDOMGlobalObject&, JSC::SourceCode sourceCode) {
         return JSC::JSSourceCode::create(state.vm(), WTFMove(sourceCode));
     }, scriptSourceCode.jsSourceCode());
index 328add8..26bc5f3 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "CachedResourceHandle.h"
 #include "CachedScript.h"
+#include "CachedScriptFetcher.h"
 #include "CachedScriptSourceProvider.h"
 #include "URL.h"
 #include <parser/SourceProvider.h>
@@ -49,13 +50,20 @@ public:
     {
     }
 
-    explicit ScriptSourceCode(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType)
-        : m_provider(CachedScriptSourceProvider::create(cachedScript, sourceType))
+    ScriptSourceCode(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType, Ref<CachedScriptFetcher>&& scriptFetcher)
+        : m_provider(CachedScriptSourceProvider::create(cachedScript, sourceType, WTFMove(scriptFetcher)))
         , m_code(m_provider)
         , m_cachedScript(cachedScript)
     {
     }
 
+    ScriptSourceCode(const String& source, const URL& url, const TextPosition& startPosition, JSC::SourceProviderSourceType sourceType, Ref<CachedScriptFetcher>&& scriptFetcher)
+        : m_provider(JSC::StringSourceProvider::create(source, JSC::SourceOrigin { url.string(), WTFMove(scriptFetcher) }, url.string(), startPosition, sourceType))
+        , m_code(m_provider, startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt())
+        , m_url(url)
+    {
+    }
+
     bool isEmpty() const { return m_code.length() == 0; }
 
     const JSC::SourceCode& jsSourceCode() const { return m_code; }
diff --git a/Source/WebCore/dom/InlineClassicScript.cpp b/Source/WebCore/dom/InlineClassicScript.cpp
new file mode 100644 (file)
index 0000000..5e28ade
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InlineClassicScript.h"
+
+#include "Element.h"
+#include "ScriptElement.h"
+
+namespace WebCore {
+
+Ref<InlineClassicScript> InlineClassicScript::create(ScriptElement& scriptElement)
+{
+    auto& element = scriptElement.element();
+    return adoptRef(*new InlineClassicScript(
+        element.attributeWithoutSynchronization(HTMLNames::nonceAttr),
+        element.attributeWithoutSynchronization(HTMLNames::crossoriginAttr),
+        scriptElement.scriptCharset(),
+        element.localName(),
+        element.isInUserAgentShadowTree()));
+}
+
+}
diff --git a/Source/WebCore/dom/InlineClassicScript.h b/Source/WebCore/dom/InlineClassicScript.h
new file mode 100644 (file)
index 0000000..0e26535
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CachedScriptFetcher.h"
+
+namespace WebCore {
+
+class ScriptElement;
+
+class InlineClassicScript final : public CachedScriptFetcher {
+public:
+    static Ref<InlineClassicScript> create(ScriptElement&);
+
+private:
+    InlineClassicScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
+        : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
+    {
+    }
+};
+
+}
index 98cb06d..6119ab1 100644 (file)
@@ -104,7 +104,7 @@ void LoadableClassicScript::notifyFinished(CachedResource& resource)
 void LoadableClassicScript::execute(ScriptElement& scriptElement)
 {
     ASSERT(!error());
-    scriptElement.executeClassicScript(ScriptSourceCode(m_cachedScript.get(), JSC::SourceProviderSourceType::Program));
+    scriptElement.executeClassicScript(ScriptSourceCode(m_cachedScript.get(), JSC::SourceProviderSourceType::Program, *this));
 }
 
 bool LoadableClassicScript::load(Document& document, const URL& sourceURL)
index a3f0d14..1bdde1e 100644 (file)
@@ -60,25 +60,4 @@ void LoadableScript::notifyClientFinished()
         client->notifyFinished(*this);
 }
 
-CachedResourceHandle<CachedScript> LoadableScript::requestScriptWithCache(Document& document, const URL& sourceURL) const
-{
-    auto* settings = document.settings();
-    if (settings && !settings->isScriptEnabled())
-        return nullptr;
-
-    ASSERT(document.contentSecurityPolicy());
-    bool hasKnownNonce = document.contentSecurityPolicy()->allowScriptWithNonce(m_nonce, m_isInUserAgentShadowTree);
-    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-    options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
-
-    CachedResourceRequest request(ResourceRequest(sourceURL), options);
-    request.setAsPotentiallyCrossOrigin(m_crossOriginMode, document);
-    request.upgradeInsecureRequestIfNeeded(document);
-
-    request.setCharset(m_charset);
-    request.setInitiator(m_initiatorName);
-
-    return document.cachedResourceLoader().requestScript(WTFMove(request));
-}
-
 }
index 72704da..ca84e81 100644 (file)
 
 #pragma once
 
-#include "CachedResourceHandle.h"
+#include "CachedScriptFetcher.h"
 #include <runtime/ConsoleTypes.h>
-#include <runtime/JSScriptFetcher.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class CachedScript;
-class Document;
 class LoadableScriptClient;
 class ScriptElement;
-class URL;
 
-class LoadableScript : public JSC::ScriptFetcher {
+class LoadableScript : public CachedScriptFetcher {
 public:
     enum class ErrorType {
         CachedScript,
@@ -73,27 +69,15 @@ public:
     virtual bool isClassicScript() const { return false; }
     virtual bool isModuleScript() const { return false; }
 
-    CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL) const;
-
 protected:
     LoadableScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)
-        : m_nonce(nonce)
-        , m_crossOriginMode(crossOriginMode)
-        , m_charset(charset)
-        , m_initiatorName(initiatorName)
-        , m_isInUserAgentShadowTree(isInUserAgentShadowTree)
+        : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)
     {
     }
 
     void notifyClientFinished();
 
 private:
-    String m_nonce;
-    String m_crossOriginMode;
-    String m_charset;
-    AtomicString m_initiatorName;
-    bool m_isInUserAgentShadowTree { false };
-
     HashCountedSet<LoadableScriptClient*> m_clients;
 };
 
index b433fbc..5429caa 100644 (file)
@@ -38,6 +38,7 @@
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
 #include "IgnoreDestructiveWriteCountIncrementer.h"
+#include "InlineClassicScript.h"
 #include "LoadableClassicScript.h"
 #include "LoadableModuleScript.h"
 #include "MIMETypeRegistry.h"
@@ -275,7 +276,7 @@ bool ScriptElement::prepareScript(const TextPosition& scriptStartPosition, Legac
     } else {
         ASSERT(scriptType == ScriptType::Classic);
         TextPosition position = document.isInDocumentWrite() ? TextPosition() : scriptStartPosition;
-        executeClassicScript(ScriptSourceCode(scriptContent(), document.url(), position, JSC::SourceProviderSourceType::Program));
+        executeClassicScript(ScriptSourceCode(scriptContent(), document.url(), position, JSC::SourceProviderSourceType::Program, InlineClassicScript::create(*this)));
     }
 
     return true;
@@ -348,8 +349,10 @@ bool ScriptElement::requestModuleScript(const TextPosition& scriptStartPosition)
         return true;
     }
 
+    auto script = LoadableModuleScript::create(nonce, crossOriginMode, scriptCharset(), m_element.localName(), m_element.isInUserAgentShadowTree());
+
     TextPosition position = m_element.document().isInDocumentWrite() ? TextPosition() : scriptStartPosition;
-    ScriptSourceCode sourceCode(scriptContent(), m_element.document().url(), position, JSC::SourceProviderSourceType::Module);
+    ScriptSourceCode sourceCode(scriptContent(), m_element.document().url(), position, JSC::SourceProviderSourceType::Module, script.copyRef());
 
     ASSERT(m_element.document().contentSecurityPolicy());
     const auto& contentSecurityPolicy = *m_element.document().contentSecurityPolicy();
@@ -357,7 +360,6 @@ bool ScriptElement::requestModuleScript(const TextPosition& scriptStartPosition)
     if (!contentSecurityPolicy.allowInlineScript(m_element.document().url(), m_startLineNumber, sourceCode.source().toStringWithoutCopying(), hasKnownNonce))
         return false;
 
-    auto script = LoadableModuleScript::create(nonce, crossOriginMode, scriptCharset(), m_element.localName(), m_element.isInUserAgentShadowTree());
     script->load(m_element.document(), sourceCode);
     m_loadableScript = WTFMove(script);
     return true;
@@ -426,7 +428,7 @@ void ScriptElement::executePendingScript(PendingScript& pendingScript)
     else {
         ASSERT(!pendingScript.error());
         ASSERT_WITH_MESSAGE(scriptType() == ScriptType::Classic, "Module script always have a loadableScript pointer.");
-        executeClassicScript(ScriptSourceCode(scriptContent(), m_element.document().url(), pendingScript.startingPosition(), JSC::SourceProviderSourceType::Program));
+        executeClassicScript(ScriptSourceCode(scriptContent(), m_element.document().url(), pendingScript.startingPosition(), JSC::SourceProviderSourceType::Program, InlineClassicScript::create(*this)));
         dispatchLoadEvent();
     }
 }
index c1f42c2..c11ce59 100644 (file)
@@ -35,6 +35,7 @@
 #include "HTMLNames.h"
 #include "HTMLScriptRunnerHost.h"
 #include "IgnoreDestructiveWriteCountIncrementer.h"
+#include "InlineClassicScript.h"
 #include "Microtasks.h"
 #include "MutationObserver.h"
 #include "NestingLevelIncrementer.h"
@@ -258,7 +259,7 @@ void HTMLScriptRunner::runScript(ScriptElement& scriptElement, const TextPositio
         if (m_scriptNestingLevel == 1)
             m_parserBlockingScript = PendingScript::create(scriptElement, scriptStartPosition);
         else
-            scriptElement.executeClassicScript(ScriptSourceCode(scriptElement.element().textContent(), documentURLForScriptExecution(m_document), scriptStartPosition));
+            scriptElement.executeClassicScript(ScriptSourceCode(scriptElement.element().textContent(), documentURLForScriptExecution(m_document), scriptStartPosition, JSC::SourceProviderSourceType::Program, InlineClassicScript::create(scriptElement)));
     } else
         requestParsingBlockingScript(scriptElement);
 }
index f481005..471295d 100644 (file)
@@ -38,6 +38,7 @@
 #include "HTMLEntityParser.h"
 #include "HTMLHtmlElement.h"
 #include "HTMLTemplateElement.h"
+#include "InlineClassicScript.h"
 #include "Page.h"
 #include "PendingScript.h"
 #include "ProcessingInstruction.h"
@@ -877,7 +878,7 @@ void XMLDocumentParser::endElementNs()
         // the libxml2 and Qt XMLDocumentParser implementations.
 
         if (scriptElement.readyToBeParserExecuted())
-            scriptElement.executeClassicScript(ScriptSourceCode(scriptElement.scriptContent(), document()->url(), m_scriptStartPosition));
+            scriptElement.executeClassicScript(ScriptSourceCode(scriptElement.scriptContent(), document()->url(), m_scriptStartPosition, JSC::SourceProviderSourceType::Program, InlineClassicScript::create(scriptElement)));
         else if (scriptElement.willBeParserExecuted() && scriptElement.loadableScript()) {
             m_pendingScript = PendingScript::create(scriptElement, *scriptElement.loadableScript());
             m_pendingScript->setClient(*this);