haikuwebkit/JSTests/modules/namespace-re-export.js

2 lines
55 B
JavaScript
Raw Permalink Normal View History

Clean up SourceProvider and add caller relative load script to jsc.cpp https://bugs.webkit.org/show_bug.cgi?id=214205 Reviewed by Yusuke Suzuki. JSTests: There are two main changes here. The first is converting most invocations of load to also pass "caller relative" as the second parameter. This lets those tests be run from any working directory rather than only the same directory as the test script. The second change is to prohibit "bare-name" specifiers in our CLI's module loader. This matches pretty much all other module loaders, including WebCore and our Obj-C API. * modules/aliased-names.js: * modules/aliasing/drink.js: * modules/caching-should-not-make-ambiguous.js: * modules/default-error/main.js: * modules/execution-order-cyclic/5.js: * modules/execution-order-dag/5.js: * modules/execution-order-tree/5.js: * modules/indirect-export-error/indirect-export-default-2.js: * modules/namespace-ambiguous/ambiguous-2.js: * modules/namespace-ambiguous/ambiguous.js: * modules/namespace-re-export.js: * modules/uncacheable-when-see-star.js: * stress/global-const-redeclaration-setting-2.js: * stress/global-const-redeclaration-setting-3.js: * stress/global-const-redeclaration-setting-4.js: * stress/global-const-redeclaration-setting-5.js: * stress/global-const-redeclaration-setting.js: * stress/global-lexical-redeclare-variable.js: * stress/global-lexical-redefine-const.js: * stress/global-lexical-variable-tdz.js: * stress/global-lexical-variable-unresolved-property.js: * stress/global-property-into-variable-get-from-scope.js: * stress/import-with-empty-string.js: * stress/jsonp-literal-parser-semicolon-is-not-assignment.js: * stress/op_add.js: * stress/op_bitand.js: * stress/op_bitor.js: * stress/op_bitxor.js: * stress/op_div-ConstVar.js: * stress/op_div-VarConst.js: * stress/op_div-VarVar.js: * stress/op_lshift-ConstVar.js: * stress/op_lshift-VarConst.js: * stress/op_lshift-VarVar.js: * stress/op_mod-ConstVar.js: * stress/op_mod-VarConst.js: * stress/op_mod-VarVar.js: * stress/op_mul-ConstVar.js: * stress/op_mul-VarConst.js: * stress/op_mul-VarVar.js: * stress/op_negate.js: * stress/op_postdec.js: * stress/op_postinc.js: * stress/op_predec.js: * stress/op_preinc.js: * stress/op_rshift-ConstVar.js: * stress/op_rshift-VarConst.js: * stress/op_rshift-VarVar.js: * stress/op_sub-ConstVar.js: * stress/op_sub-VarConst.js: * stress/op_sub-VarVar.js: * stress/op_urshift-ConstVar.js: * stress/op_urshift-VarConst.js: * stress/op_urshift-VarVar.js: * stress/regress-159779-1.js: (makeUseRegressionTest): * stress/regress-159779-2.js: (makeUseRegressionTest): * stress/resources/typedarray-constructor-helper-functions.js: * stress/resources/typedarray-test-helper-functions.js: * stress/sampling-profiler-anonymous-function.js: * stress/sampling-profiler-basic.js: * stress/sampling-profiler-bound-function-name.js: * stress/sampling-profiler-deep-stack.js: * stress/sampling-profiler-display-name.js: * stress/sampling-profiler-internal-function-name.js: * stress/sampling-profiler-microtasks.js: * stress/sampling-profiler-wasm-name-section.js: * stress/sampling-profiler-wasm.js: * stress/shadow-chicken-disabled.js: * stress/shadow-chicken-enabled.js: * stress/typedarray-constructor.js: * stress/typedarray-copyWithin.js: * stress/typedarray-every.js: * stress/typedarray-fill.js: * stress/typedarray-filter.js: * stress/typedarray-find.js: * stress/typedarray-findIndex.js: * stress/typedarray-forEach.js: * stress/typedarray-from.js: * stress/typedarray-includes.js: * stress/typedarray-indexOf.js: * stress/typedarray-lastIndexOf.js: * stress/typedarray-map.js: * stress/typedarray-of.js: * stress/typedarray-reduce.js: * stress/typedarray-reduceRight.js: * stress/typedarray-set.js: * stress/typedarray-slice.js: * stress/typedarray-some.js: * stress/typedarray-sort.js: * stress/typedarray-subarray.js: * wasm/Builder.js: * wasm/Builder_WebAssemblyBinary.js: * wasm/LowLevelBinary.js: * wasm/README.md: * wasm/WASM.js: * wasm/regress/selectf64.js: * wasm/spec-harness.js: (import.string_appeared_here.then): LayoutTests/imported/w3c: Rebaseline module loader error messages against the new string. * web-platform-tests/html/semantics/scripting-1/the-script-element/module/specifier-error-expected.txt: Source/JavaScriptCore: This patch originally was just to add an optional parameter to our load function so that any relative path is computed with respect to calling script. Rather than computing the path relative to the current working directory. The main advantage of this is now you can run all the JSTests/stress scripts from anywhere rather than only from the stress directory. This also matches jsc.cpp's module loader implementation. To make this possible a surprising number of changes were needed. Specifically, it was much easier to get this to work if we converted SourceOrigin's url to a WTF::URL rather than just a WTF::String. At the same time it became clear that SourceProvider's m_sourceURL is really not a URL but more of a file name, which can sometimes be a URL. It's possible that we don't need m_sourceURL at all but we should do that in a different patch. Additionally, jsc.cpp now uses WTF::URL for handling file paths. This is cleaner than managing trying to do it ourselves and should work across all the ports. Lastly, the JSC CLI no longer accepts "bare-name" specifiers. i.e. all specifiers must start with "/", "./", or "../". This matches what we do in our Obj-C API and in WebCore. While fixing tests I also noticed that the error message was almost useless since it didn't tell you what the specifier or referrer in question so that information is now part of the user visible error. * API/JSAPIGlobalObject.mm: (JSC::computeValidImportSpecifier): (JSC::JSAPIGlobalObject::moduleLoaderImportModule): * API/JSBase.cpp: (JSEvaluateScript): (JSCheckScriptSyntax): * API/JSObjectRef.cpp: (JSObjectMakeFunction): * API/JSScript.mm: (-[JSScript sourceCode]): * API/JSScriptRef.cpp: * API/glib/JSCContext.cpp: (jsc_context_check_syntax): * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::BuiltinExecutables): * debugger/DebuggerLocation.cpp: (JSC::DebuggerLocation::DebuggerLocation): * debugger/DebuggerLocation.h: (JSC::DebuggerLocation::DebuggerLocation): * inspector/ScriptDebugServer.cpp: (Inspector::ScriptDebugServer::sourceParsed): * jsc.cpp: (currentWorkingDirectory): (absolutePath): (GlobalObject::moduleLoaderImportModule): (GlobalObject::moduleLoaderResolve): (jscSource): (fetchModuleFromLocalFileSystem): (GlobalObject::moduleLoaderFetch): (functionLoad): (functionCallerSourceOrigin): (functionDollarAgentStart): (functionCheckModuleSyntax): (runWithOptions): (runInteractive): (ModuleName::startsWithRoot const): Deleted. (ModuleName::ModuleName): Deleted. (extractDirectoryName): Deleted. (resolvePath): Deleted. * parser/Nodes.h: (JSC::ScopeNode::source const): (JSC::ScopeNode::sourceURL const): Deleted. * parser/SourceCode.h: (JSC::makeSource): * parser/SourceCodeKey.h: (JSC::SourceCodeKey::host const): * parser/SourceProvider.cpp: (JSC::SourceProvider::SourceProvider): * parser/SourceProvider.h: (JSC::SourceProvider::sourceURL const): (JSC::StringSourceProvider::create): (JSC::StringSourceProvider::StringSourceProvider): (JSC::SourceProvider::url const): Deleted. * runtime/CachedTypes.cpp: (JSC::CachedSourceOrigin::encode): (JSC::CachedSourceOrigin::decode const): (JSC::CachedSourceProviderShape::encode): (JSC::CachedStringSourceProvider::decode const): (JSC::CachedWebAssemblySourceProvider::decode const): * runtime/Error.cpp: (JSC::addErrorInfo): * runtime/FunctionConstructor.cpp: (JSC::constructFunctionSkippingEvalEnabledCheck): * runtime/ScriptExecutable.h: (JSC::ScriptExecutable::sourceURL const): * runtime/SourceOrigin.h: (JSC::SourceOrigin::SourceOrigin): (JSC::SourceOrigin::url const): (JSC::SourceOrigin::string const): (JSC::SourceOrigin::isNull const): * runtime/ThrowScope.cpp: (JSC::ThrowScope::throwException): * runtime/ThrowScope.h: (JSC::ThrowScope::throwException): (JSC::throwVMException): * tools/FunctionOverrides.cpp: (JSC::initializeOverrideInfo): * tools/JSDollarVM.cpp: (JSC::doPrint): (JSC::functionCrash): Source/WebCore: Refactor WebCore <-> JSC binding layer now that JSC uses WTF::URLs for SourceOrigins. Also, improve module loading error messages to include the specifier and referrer when producing errors around bare-name specifiers. New error message behavior is already tested so existing tests have been updated. * bindings/js/CachedScriptSourceProvider.h: (WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider): * bindings/js/JSEventListener.cpp: (WebCore::JSEventListener::handleEvent): * bindings/js/JSEventListener.h: (WebCore::JSEventListener::sourceURL const): * bindings/js/JSLazyEventListener.cpp: (WebCore::JSLazyEventListener::JSLazyEventListener): (WebCore::JSLazyEventListener::initializeJSFunction const): (WebCore::JSLazyEventListener::create): * bindings/js/JSLazyEventListener.h: * bindings/js/ScriptController.cpp: (WebCore::ScriptController::evaluateInWorld): (WebCore::ScriptController::evaluateModule): (WebCore::ScriptController::callInWorld): * bindings/js/ScriptController.h: (WebCore::ScriptController::sourceURL const): * bindings/js/ScriptModuleLoader.cpp: (WebCore::resolveModuleSpecifier): (WebCore::rejectPromise): * bindings/js/ScriptSourceCode.h: (WebCore::ScriptSourceCode::ScriptSourceCode): (WebCore::ScriptSourceCode::url const): Source/WebKitLegacy/mac: Use the source origin's URL for the debugger since it's the true URL for the script. * WebView/WebScriptDebugger.mm: (WebScriptDebugger::sourceParsed): Source/WTF: Using a URL as a boolean in a conditional should be a compile error. Currently, it "works" because it actually calls `operator NSURL*()`... which is likely NOT what you wanted. Until we decide what it means to have a URL in a conditional it will be a compile error. * wtf/URL.cpp: (WTF::URL::fileSystemPath const): * wtf/URL.h: LayoutTests: js-test-pre needs to strip the parts of file urls between file:/// and LayoutTests because that is dependent on the system running the tests. Tests using these harnesses may not be using a server to host the test files. Rebaseline module loader error messages against the new string. * http/tests/resources/js-test-pre.js: (escapeHTMLAndStripFileURLs): (testFailed): (escapeHTML): Deleted. (testPassed): Deleted. * js/dom/modules/import-incorrect-relative-specifier-expected.txt: * js/dom/modules/module-incorrect-relative-specifier-expected.txt: * resources/js-test-pre.js: (escapeHTMLAndStripFileURLs): (testFailed): (escapeHTML): Deleted. (testPassed): Deleted. Canonical link: https://commits.webkit.org/227069@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-13 17:35:35 +00:00
import "./namespace-re-export/namespace-re-export.js";