+2017-10-20 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r223744, r223750, and r223751.
+ https://bugs.webkit.org/show_bug.cgi?id=178594
+
+ These caused consistent failures in test that existed and were
+ added in the patches. (Requested by mlewis13 on #webkit).
+
+ Reverted changesets:
+
+ "[JSC] ScriptFetcher should be notified directly from module
+ pipeline"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223744
+
+ "Unreviewed, fix changed line number in test expect files"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223750
+
+ "Unreviewed, follow up to reflect comments"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223751
+
2017-10-20 Zan Dobersek <zdobersek@igalia.com>
Unreviewed GTK+ gardening. Adding GTK+-specific baselines for a bunch
CONSOLE MESSAGE: Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
-CONSOLE MESSAGE: line 16: TypeError: Cross-origin script load denied by Cross-Origin Resource Sharing policy.
+CONSOLE MESSAGE: line 1: TypeError: Cross-origin script load denied by Cross-Origin Resource Sharing policy.
This tests whether a deferred script load caused by a redirect is properly allowed by a nonce.
-CONSOLE MESSAGE: line 16: TypeError: 'application/octet-stream' is not a valid JavaScript MIME type.
+CONSOLE MESSAGE: line 1: TypeError: 'application/octet-stream' is not a valid JavaScript MIME type.
Test module rejects scripts with no mime type.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-CONSOLE MESSAGE: line 19: Error: module is executed.
Test window.onerror will be fired when the inlined module throws an error.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+2017-10-20 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r223744, r223750, and r223751.
+ https://bugs.webkit.org/show_bug.cgi?id=178594
+
+ These caused consistent failures in test that existed and were
+ added in the patches. (Requested by mlewis13 on #webkit).
+
+ Reverted changesets:
+
+ "[JSC] ScriptFetcher should be notified directly from module
+ pipeline"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223744
+
+ "Unreviewed, fix changed line number in test expect files"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223750
+
+ "Unreviewed, follow up to reflect comments"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223751
+
2017-10-20 Yusuke Suzuki <utatane.tea@gmail.com>
Unreviewed, follow up to reflect comments
// For example, take the "jquery" and return the URL for the resource.
return this.resolve(moduleName, @undefined, fetcher).then((key) => {
return this.requestSatisfy(this.ensureRegistered(key), parameters, fetcher);
- }).then(
- (entry) => {
- this.notifyCompleted(fetcher, entry.key);
- return entry;
- },
- (error) => {
- this.notifyFailed(fetcher, error);
- throw error;
- });
+ }).then((entry) => {
+ return entry.key;
+ });
}
function linkAndEvaluateModule(key, fetcher)
{
"use strict";
- return this.loadModule(moduleName, parameters, fetcher).then((entry) => {
- return this.linkAndEvaluateModule(entry.key, fetcher);
+ return this.loadModule(moduleName, parameters, fetcher).then((key) => {
+ return this.linkAndEvaluateModule(key, fetcher);
});
}
return globalObject->moduleLoader()->loadAndEvaluateModule(exec, key, jsUndefined(), scriptFetcher);
}
-void loadModule(ExecState* exec, const String& moduleName, JSValue parameters, JSValue scriptFetcher)
+JSInternalPromise* loadModule(ExecState* exec, const String& moduleName, JSValue parameters, JSValue scriptFetcher)
{
VM& vm = exec->vm();
JSLockHolder lock(vm);
RELEASE_ASSERT(vm.atomicStringTable() == Thread::current().atomicStringTable());
RELEASE_ASSERT(!vm.isCollectorBusyOnCurrentThread());
- exec->vmEntryGlobalObject()->moduleLoader()->loadModule(exec, identifierToJSValue(vm, Identifier::fromString(exec, moduleName)), parameters, scriptFetcher);
+ return exec->vmEntryGlobalObject()->moduleLoader()->loadModule(exec, identifierToJSValue(vm, Identifier::fromString(exec, moduleName)), parameters, scriptFetcher);
}
-void loadModule(ExecState* exec, const SourceCode& source, JSValue scriptFetcher)
+JSInternalPromise* loadModule(ExecState* exec, const SourceCode& source, JSValue scriptFetcher)
{
VM& vm = exec->vm();
JSLockHolder lock(vm);
// Insert the given source code to the ModuleLoader registry as the fetched registry entry.
// FIXME: Introduce JSSourceCode object to wrap around this source.
globalObject->moduleLoader()->provideFetch(exec, key, source);
- RETURN_IF_EXCEPTION(scope, void());
+ RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
- globalObject->moduleLoader()->loadModule(exec, key, jsUndefined(), scriptFetcher);
+ return globalObject->moduleLoader()->loadModule(exec, key, jsUndefined(), scriptFetcher);
}
JSValue linkAndEvaluateModule(ExecState* exec, const Identifier& moduleKey, JSValue scriptFetcher)
JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const SourceCode&, JSValue scriptFetcher);
// Fetch the module source, and instantiate the module record.
-JS_EXPORT_PRIVATE void loadModule(ExecState*, const String& moduleName, JSValue parameters, JSValue scriptFetcher);
-JS_EXPORT_PRIVATE void loadModule(ExecState*, const SourceCode&, JSValue scriptFetcher);
+JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const String& moduleName, JSValue parameters, JSValue scriptFetcher);
+JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const SourceCode&, JSValue scriptFetcher);
// Link and evaluate the already linked module. This function is called in a sync manner.
JS_EXPORT_PRIVATE JSValue linkAndEvaluateModule(ExecState*, const Identifier& moduleKey, JSValue scriptFetcher);
#include "JSMap.h"
#include "JSModuleEnvironment.h"
#include "JSModuleRecord.h"
-#include "JSScriptFetcher.h"
#include "JSSourceCode.h"
#include "ModuleAnalyzer.h"
#include "ModuleLoaderPrototype.h"
return moduleRecord->getModuleNamespace(exec);
}
-static Identifier jsValueToModuleKey(ExecState* exec, JSValue value)
-{
- if (value.isSymbol())
- return Identifier::fromUid(jsCast<Symbol*>(value)->privateName());
- ASSERT(value.isString());
- return asString(value)->toIdentifier(exec);
-}
-
-JSValue JSModuleLoader::notifyCompleted(ExecState* exec, JSValue scriptFetcher, JSValue key)
-{
- auto* fetcherWrapper = jsDynamicCast<JSScriptFetcher*>(exec->vm(), scriptFetcher);
- if (!fetcherWrapper)
- return jsUndefined();
- auto* fetcher = fetcherWrapper->fetcher();
- if (!fetcher)
- return jsUndefined();
-
- auto moduleKey = jsValueToModuleKey(exec, key);
- fetcher->notifyLoadCompleted(*moduleKey.impl());
- return jsUndefined();
-}
-
-JSValue JSModuleLoader::notifyFailed(ExecState* exec, JSValue scriptFetcher, JSValue errorValue)
-{
- auto* fetcherWrapper = jsDynamicCast<JSScriptFetcher*>(exec->vm(), scriptFetcher);
- if (!fetcherWrapper)
- return jsUndefined();
- auto* fetcher = fetcherWrapper->fetcher();
- if (!fetcher)
- return jsUndefined();
- fetcher->notifyLoadFailed(exec, errorValue);
- return jsUndefined();
-}
-
} // namespace JSC
JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue parameters, JSValue scriptFetcher);
JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue scriptFetcher);
JSInternalPromise* requestImportModule(ExecState*, const Identifier&, JSValue parameters, JSValue scriptFetcher);
- JSValue notifyCompleted(ExecState*, JSValue scriptFetcher, JSValue key);
- JSValue notifyFailed(ExecState*, JSValue scriptFetcher, JSValue error);
// Platform dependent hooked APIs.
JSInternalPromise* importModule(ExecState*, JSString* moduleName, JSValue parameters, const SourceOrigin& referrer);
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeResolveSync(ExecState*);
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeFetch(ExecState*);
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeGetModuleNamespaceObject(ExecState*);
-static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeNotifyCompleted(ExecState*);
-static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeNotifyFailed(ExecState*);
}
resolve moduleLoaderPrototypeResolve DontEnum|Function 2
resolveSync moduleLoaderPrototypeResolveSync DontEnum|Function 2
fetch moduleLoaderPrototypeFetch DontEnum|Function 3
- notifyCompleted moduleLoaderPrototypeNotifyCompleted DontEnum|Function 2
- notifyFailed moduleLoaderPrototypeNotifyFailed DontEnum|Function 2
@end
*/
return JSValue::encode(jsUndefined());
}
-EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeNotifyCompleted(ExecState* exec)
-{
- VM& vm = exec->vm();
- JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(vm, exec->thisValue());
- if (!loader)
- return JSValue::encode(jsUndefined());
- return JSValue::encode(loader->notifyCompleted(exec, exec->argument(0), exec->argument(1)));
-}
-
-EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeNotifyFailed(ExecState* exec)
-{
- VM& vm = exec->vm();
- JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(vm, exec->thisValue());
- if (!loader)
- return JSValue::encode(jsUndefined());
- return JSValue::encode(loader->notifyFailed(exec, exec->argument(0), exec->argument(1)));
-}
-
// ------------------------------ Hook Functions ---------------------------
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeResolve(ExecState* exec)
#pragma once
-#include "JSCJSValue.h"
#include <wtf/RefCounted.h>
namespace JSC {
-class ExecState;
-
class ScriptFetcher : public RefCounted<ScriptFetcher> {
public:
virtual ~ScriptFetcher() { }
-
- virtual void notifyLoadCompleted(UniquedStringImpl&) { }
- virtual void notifyLoadFailed(ExecState*, JSValue) { }
};
} // namespace JSC
+2017-10-20 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r223744, r223750, and r223751.
+ https://bugs.webkit.org/show_bug.cgi?id=178594
+
+ These caused consistent failures in test that existed and were
+ added in the patches. (Requested by mlewis13 on #webkit).
+
+ Reverted changesets:
+
+ "[JSC] ScriptFetcher should be notified directly from module
+ pipeline"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223744
+
+ "Unreviewed, fix changed line number in test expect files"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223750
+
+ "Unreviewed, follow up to reflect comments"
+ https://bugs.webkit.org/show_bug.cgi?id=178340
+ https://trac.webkit.org/changeset/223751
+
2017-10-20 Zalan Bujtas <zalan@apple.com>
[FrameView::layout cleanup] Move can-enter-layout logic to a separate function
task.run(exec);
}
- static void loadModule(JSC::ExecState& state, const String& moduleName, JSC::JSValue parameters, JSC::JSValue scriptFetcher)
+ static JSC::JSInternalPromise& loadModule(JSC::ExecState& state, const String& moduleName, JSC::JSValue parameters, JSC::JSValue scriptFetcher)
{
JSMainThreadExecState currentState(&state);
- JSC::loadModule(&state, moduleName, parameters, scriptFetcher);
+ return *JSC::loadModule(&state, moduleName, parameters, scriptFetcher);
}
- static void loadModule(JSC::ExecState& state, const JSC::SourceCode& sourceCode, JSC::JSValue scriptFetcher)
+ static JSC::JSInternalPromise& loadModule(JSC::ExecState& state, const JSC::SourceCode& sourceCode, JSC::JSValue scriptFetcher)
{
JSMainThreadExecState currentState(&state);
- JSC::loadModule(&state, sourceCode, scriptFetcher);
+ return *JSC::loadModule(&state, sourceCode, scriptFetcher);
}
static JSC::JSValue linkAndEvaluateModule(JSC::ExecState& state, const JSC::Identifier& moduleKey, JSC::JSValue scriptFetcher, NakedPtr<JSC::Exception>& returnedException)
#include "JSMainThreadExecState.h"
#include "LoadableModuleScript.h"
#include "MainFrame.h"
+#include "ModuleFetchFailureKind.h"
#include "ModuleFetchParameters.h"
#include "NP_jsobject.h"
#include "Page.h"
#include <runtime/JSInternalPromise.h>
#include <runtime/JSLock.h>
#include <runtime/JSModuleRecord.h>
+#include <runtime/JSNativeStdFunction.h>
#include <runtime/JSScriptFetchParameters.h>
#include <runtime/JSScriptFetcher.h>
#include <wtf/MemoryPressureHandler.h>
auto& proxy = *windowProxy(world);
auto& state = *proxy.window()->globalExec();
- JSMainThreadExecState::loadModule(state, moduleName, JSC::JSScriptFetchParameters::create(state.vm(), WTFMove(topLevelFetchParameters)), JSC::JSScriptFetcher::create(state.vm(), { &moduleScript }));
+ auto& promise = JSMainThreadExecState::loadModule(state, moduleName, JSC::JSScriptFetchParameters::create(state.vm(), WTFMove(topLevelFetchParameters)), JSC::JSScriptFetcher::create(state.vm(), { &moduleScript }));
+ setupModuleScriptHandlers(moduleScript, promise, world);
}
void ScriptController::loadModuleScript(LoadableModuleScript& moduleScript, const String& moduleName, Ref<ModuleFetchParameters>&& topLevelFetchParameters)
auto& proxy = *windowProxy(world);
auto& state = *proxy.window()->globalExec();
- JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(state.vm(), { &moduleScript }));
+ auto& promise = JSMainThreadExecState::loadModule(state, sourceCode.jsSourceCode(), JSC::JSScriptFetcher::create(state.vm(), { &moduleScript }));
+ setupModuleScriptHandlers(moduleScript, promise, world);
}
void ScriptController::loadModuleScript(LoadableModuleScript& moduleScript, const ScriptSourceCode& sourceCode)
return &windowProxy;
}
+static Identifier jsValueToModuleKey(ExecState* exec, JSValue value)
+{
+ if (value.isSymbol())
+ return Identifier::fromUid(jsCast<Symbol*>(value)->privateName());
+ ASSERT(value.isString());
+ return asString(value)->toIdentifier(exec);
+}
+
+void ScriptController::setupModuleScriptHandlers(LoadableModuleScript& moduleScriptRef, JSInternalPromise& promise, DOMWrapperWorld& world)
+{
+ auto& proxy = *windowProxy(world);
+ auto& state = *proxy.window()->globalExec();
+
+ // It is not guaranteed that either fulfillHandler or rejectHandler is eventually called.
+ // For example, if the page load is canceled, the DeferredPromise used in the module loader pipeline will stop executing JS code.
+ // Thus the promise returned from this function could remain unresolved.
+
+ RefPtr<LoadableModuleScript> moduleScript(&moduleScriptRef);
+
+ auto& fulfillHandler = *JSNativeStdFunction::create(state.vm(), proxy.window(), 1, String(), [moduleScript](ExecState* exec) {
+ Identifier moduleKey = jsValueToModuleKey(exec, exec->argument(0));
+ moduleScript->notifyLoadCompleted(*moduleKey.impl());
+ return JSValue::encode(jsUndefined());
+ });
+
+ auto& rejectHandler = *JSNativeStdFunction::create(state.vm(), proxy.window(), 1, String(), [moduleScript](ExecState* exec) {
+ VM& vm = exec->vm();
+ JSValue errorValue = exec->argument(0);
+ if (errorValue.isObject()) {
+ auto* object = JSC::asObject(errorValue);
+ if (JSValue failureKindValue = object->getDirect(vm, static_cast<JSVMClientData&>(*vm.clientData).builtinNames().failureKindPrivateName())) {
+ // This is host propagated error in the module loader pipeline.
+ switch (static_cast<ModuleFetchFailureKind>(failureKindValue.asInt32())) {
+ case ModuleFetchFailureKind::WasErrored:
+ moduleScript->notifyLoadFailed(LoadableScript::Error {
+ LoadableScript::ErrorType::CachedScript,
+ std::nullopt
+ });
+ break;
+ case ModuleFetchFailureKind::WasCanceled:
+ moduleScript->notifyLoadWasCanceled();
+ break;
+ }
+ return JSValue::encode(jsUndefined());
+ }
+ }
+
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ moduleScript->notifyLoadFailed(LoadableScript::Error {
+ LoadableScript::ErrorType::CachedScript,
+ LoadableScript::ConsoleMessage {
+ MessageSource::JS,
+ MessageLevel::Error,
+ retrieveErrorMessage(*exec, vm, errorValue, scope),
+ }
+ });
+ return JSValue::encode(jsUndefined());
+ });
+
+ promise.then(&state, &fulfillHandler, &rejectHandler);
+}
+
TextPosition ScriptController::eventHandlerPosition() const
{
// FIXME: If we are not currently parsing, we should use our current location
private:
WEBCORE_EXPORT JSDOMWindowProxy* initScript(DOMWrapperWorld&);
+ void setupModuleScriptHandlers(LoadableModuleScript&, JSC::JSInternalPromise&, DOMWrapperWorld&);
void disconnectPlatformScriptObjects();
#include "Document.h"
#include "Frame.h"
-#include "JSDOMExceptionHandling.h"
-#include "ModuleFetchFailureKind.h"
#include "ModuleFetchParameters.h"
#include "ScriptController.h"
#include "ScriptElement.h"
-#include "WebCoreJSClientData.h"
-#include <heap/StrongInlines.h>
-#include <runtime/CatchScope.h>
namespace WebCore {
notifyClientFinished();
}
-void LoadableModuleScript::notifyLoadFailed(JSC::ExecState* exec, JSC::JSValue errorValue)
-{
- JSC::VM& vm = exec->vm();
- if (errorValue.isObject()) {
- auto* object = JSC::asObject(errorValue);
- if (JSC::JSValue failureKindValue = object->getDirect(vm, static_cast<JSVMClientData&>(*vm.clientData).builtinNames().failureKindPrivateName())) {
- // This is host propagated error in the module loader pipeline.
- switch (static_cast<ModuleFetchFailureKind>(failureKindValue.asInt32())) {
- case ModuleFetchFailureKind::WasErrored:
- notifyLoadFailed(LoadableScript::Error {
- LoadableScript::ErrorType::CachedScript,
- std::nullopt
- });
- break;
- case ModuleFetchFailureKind::WasCanceled:
- notifyLoadWasCanceled();
- break;
- }
- return;
- }
- }
-
- auto scope = DECLARE_CATCH_SCOPE(vm);
- notifyLoadFailed(LoadableScript::Error {
- LoadableScript::ErrorType::CachedScript,
- LoadableScript::ConsoleMessage {
- MessageSource::JS,
- MessageLevel::Error,
- retrieveErrorMessage(*exec, vm, errorValue, scope),
- }
- });
-}
-
void LoadableModuleScript::notifyLoadFailed(LoadableScript::Error&& error)
{
m_error = WTFMove(error);
void load(Document&, const URL& rootURL);
void load(Document&, const ScriptSourceCode&);
- UniquedStringImpl* moduleKey() const { return m_moduleKey.get(); }
+ void notifyLoadCompleted(UniquedStringImpl&);
+ void notifyLoadFailed(LoadableScript::Error&&);
+ void notifyLoadWasCanceled();
- void notifyLoadCompleted(UniquedStringImpl&) final;
- void notifyLoadFailed(JSC::ExecState*, JSC::JSValue) final;
+ UniquedStringImpl* moduleKey() const { return m_moduleKey.get(); }
private:
LoadableModuleScript(const String& nonce, const String& integrity, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree);
- void notifyLoadFailed(LoadableScript::Error&&);
- void notifyLoadWasCanceled();
-
Ref<ModuleFetchParameters> m_parameters;
RefPtr<UniquedStringImpl> m_moduleKey;
std::optional<LoadableScript::Error> m_error;