From ce54c285333bd8b48560809b0bee3838c103e75d Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 13 Dec 2024 03:32:55 +0000 Subject: [PATCH] Bug 1905239 - Add new parameters to HostEnsureCanCompileStrings hook. r=tschuster Currently, we do this via isRuntimeCodeGenEnabled whose single argument is equivalent to codeString in "Dynamic Code Brand Checks" spec [1]. We extend this hook to accept new parameters from that spec and adjust PerformEval and CreateDynamicFunction accordingly. We don't change the behavior for PerformShadowRealmEval [2] and WASM, i.e. we keep dummy parameters. [1] https://tc39.es/proposal-dynamic-code-brand-checks [2] https://github.com/tc39/proposal-shadowrealm/issues/414 Differential Revision: https://phabricator.services.mozilla.com/D229588 UltraBlame original commit: a282ae3a55f7f97440b424de73e66a3b39faee92 --- caps/nsScriptSecurityManager.cpp | 113 +- caps/nsScriptSecurityManager.h | 70 +- dom/workers/RuntimeService.cpp | 101 +- js/public/Principals.h | 78 +- js/src/builtin/Eval.cpp | 66 + js/src/builtin/ShadowRealm.cpp | 53 + .../testDynamicCodeBrandChecks.cpp | 1102 +++++++++++++++++ js/src/vm/JSContext.cpp | 84 +- js/src/vm/JSContext.h | 70 +- js/src/vm/JSFunction.cpp | 152 ++- js/src/wasm/WasmJS.cpp | 285 +++++ js/src/wasm/WasmModule.cpp | 53 + 12 files changed, 2184 insertions(+), 43 deletions(-) diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 07ad4cdddc43..adf8e4a8f4a6 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -530,6 +530,24 @@ ColumnNumber h " # +include +" +js +/ +GCVector +. +h +" +# +include +" +js +/ +Value +. +h +" +# define WEBAPPS_PERM_NAME " @@ -2061,7 +2079,67 @@ Handle JSString * > -aCode +aCodeString +JS +: +: +CompilationType +aCompilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +aParameterStrings +JS +: +: +Handle +< +JSString +* +> +aBodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +aParameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +aBodyArg +bool +* +aOutCanCompileStrings ) { MOZ_ASSERT @@ -2149,7 +2227,7 @@ scriptSample init ( cx -aCode +aCodeString ) ) ) @@ -2177,9 +2255,14 @@ scriptSample ) ) { -return +* +aOutCanCompileStrings += false ; +return +true +; } } nsCOMPtr @@ -2270,6 +2353,11 @@ if csp ) { +* +aOutCanCompileStrings += +true +; return true ; @@ -2378,6 +2466,11 @@ allowsEval " ) ; +* +aOutCanCompileStrings += +true +; return true ; @@ -2497,16 +2590,11 @@ scriptSample init ( cx -aCode +aCodeString ) ) ) { -JS_ClearPendingException -( -cx -) -; return false ; @@ -2566,9 +2654,14 @@ _ns ) ; } -return +* +aOutCanCompileStrings += evalOK ; +return +true +; } bool nsScriptSecurityManager diff --git a/caps/nsScriptSecurityManager.h b/caps/nsScriptSecurityManager.h index bbb3a584b023..051e2321b6e4 100644 --- a/caps/nsScriptSecurityManager.h +++ b/caps/nsScriptSecurityManager.h @@ -87,6 +87,10 @@ enum class RuntimeCode ; +enum +class +CompilationType +; } # define @@ -286,12 +290,12 @@ ContentSecurityPolicyPermitsJSAction ( JSContext * -cx +aCx JS : : RuntimeCode -kind +aKind JS : : @@ -300,7 +304,67 @@ Handle JSString * > -aCode +aCodeString +JS +: +: +CompilationType +aCompilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +aParameterStrings +JS +: +: +Handle +< +JSString +* +> +aBodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +aParameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +aBodyArg +bool +* +aOutCanCompileStrings ) ; static diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 077b9f52423c..45c7fe82dcab 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -161,6 +161,15 @@ include " js / +GCVector +. +h +" +# +include +" +js +/ Initialization . h @@ -179,6 +188,15 @@ include " js / +Value +. +h +" +# +include +" +js +/ WasmFeatures . h @@ -2421,7 +2439,67 @@ Handle JSString * > -aCode +aCodeString +JS +: +: +CompilationType +aCompilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +aParameterStrings +JS +: +: +Handle +< +JSString +* +> +aBodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +aParameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +aBodyArg +bool +* +aOutCanCompileStrings ) { WorkerPrivate @@ -2476,16 +2554,11 @@ scriptSample init ( aCx -aCode +aCodeString ) ) ) { -JS_ClearPendingException -( -aCx -) -; return false ; @@ -2509,9 +2582,14 @@ scriptSample ) ) { -return +* +aOutCanCompileStrings += false ; +return +true +; } evalOK = @@ -2641,9 +2719,14 @@ SuppressException ; } } -return +* +aOutCanCompileStrings += evalOK ; +return +true +; } void CTypesActivityCallback diff --git a/js/public/Principals.h b/js/public/Principals.h index d68f7c2ae1f8..0dfe7792f2b3 100644 --- a/js/public/Principals.h +++ b/js/public/Principals.h @@ -221,6 +221,16 @@ JS WASM } ; +enum +class +CompilationType +{ +DirectEval +IndirectEval +Function +Undefined +} +; } typedef bool @@ -240,8 +250,72 @@ kind JS : : -HandleString -code +Handle +< +JSString +* +> +codeString +JS +: +: +CompilationType +compilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +parameterStrings +JS +: +: +Handle +< +JSString +* +> +bodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +parameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +bodyArg +bool +* +outCanCompileStrings ) ; typedef diff --git a/js/src/builtin/Eval.cpp b/js/src/builtin/Eval.cpp index d30de400eb5d..03b34338adac 100644 --- a/js/src/builtin/Eval.cpp +++ b/js/src/builtin/Eval.cpp @@ -1394,6 +1394,36 @@ return true ; } +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -1410,9 +1440,45 @@ RuntimeCode : JS str +evalType += += +DIRECT_EVAL +? +JS +: +: +CompilationType +: +: +DirectEval +: +JS +: +: +CompilationType +: +: +IndirectEval +parameterStrings +str +parameterArgs +v +& +canCompileStrings ) ) { +return +false +; +} +if +( +! +canCompileStrings +) +{ JS_ReportErrorNumberASCII ( cx diff --git a/js/src/builtin/ShadowRealm.cpp b/js/src/builtin/ShadowRealm.cpp index 5d7ad410e363..56103b581e54 100644 --- a/js/src/builtin/ShadowRealm.cpp +++ b/js/src/builtin/ShadowRealm.cpp @@ -869,6 +869,36 @@ callerRealm evalRealm ) ; +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -885,7 +915,30 @@ RuntimeCode : JS sourceText +JS +: +: +CompilationType +: +: +Undefined +parameterStrings +nullptr +parameterArgs +NullHandleValue +& +canCompileStrings +) ) +{ +return +false +; +} +if +( +! +canCompileStrings ) { JS_ReportErrorNumberASCII diff --git a/js/src/jsapi-tests/testDynamicCodeBrandChecks.cpp b/js/src/jsapi-tests/testDynamicCodeBrandChecks.cpp index 117c2c3662f0..e04a87763f0c 100644 --- a/js/src/jsapi-tests/testDynamicCodeBrandChecks.cpp +++ b/js/src/jsapi-tests/testDynamicCodeBrandChecks.cpp @@ -583,3 +583,1105 @@ END_TEST ( testDynamicCodeBrandChecks_CustomHostGetCodeForEval ) +const +char +* +customTypesSnippet += +" +function +TrustedType +( +aTrustedCode +) +{ +this +. +trustedCode += +aTrustedCode +; +} +; +" +" +TrustedType +. +prototype +. +toString += +function +( +) +{ +return +this +. +trustedCode +; +} +; +" +" +function +CreateFakeTrustedType +( +aTrustedCode +aString +) +{ +" +" +let +fake += +new +TrustedType +( +aTrustedCode +) +; +" +" +fake +. +toString += +( +) += +> +{ +return +aString +; +} +; +" +" +return +fake +; +" +" +} +; +" +; +BEGIN_TEST +( +testDynamicCodeBrandChecks_CustomHostEnsureCanCompileStrings +) +{ +JSSecurityCallbacks +securityCallbacksWithCustomHostEnsureCanCompileStrings += +{ +StringifiedObjectsMatchTrustedCodeProperties +ExtractTrustedCodeStringProperty +nullptr +} +; +JS_SetSecurityCallbacks +( +cx +& +securityCallbacksWithCustomHostEnsureCanCompileStrings +) +; +JS +: +: +RootedValue +v +( +cx +) +; +EXEC +( +customTypesSnippet +) +; +EVAL +( +" +eval +( +' +5 +* +8 +' +) +; +" +& +v +) +; +CHECK +( +v +. +isNumber +( +) +& +& +v +. +toNumber +( +) += += +40 +) +; +EVAL +( +" +( +new +Function +( +' +a +' +' +b +' +' +return +a +* +b +' +) +) +( +6 +7 +) +; +" +& +v +) +; +CHECK +( +v +. +isNumber +( +) +& +& +v +. +toNumber +( +) += += +42 +) +; +EVAL +( +" +eval +( +new +TrustedType +( +' +5 +* +8 +' +) +) +; +" +& +v +) +; +CHECK +( +v +. +isNumber +( +) +& +& +v +. +toNumber +( +) += += +40 +) +; +EVAL +( +" +( +new +Function +( +new +TrustedType +( +' +a +' +) +new +TrustedType +( +' +b +' +) +new +" +" +TrustedType +( +' +return +a +* +b +' +) +) +) +( +6 +7 +) +; +" +& +v +) +; +CHECK +( +v +. +isNumber +( +) +& +& +v +. +toNumber +( +) += += +42 +) +; +CHECK +( +! +execDontReport +( +" +new +Function +( +CreateFakeTrustedType +( +' +a +' +' +c +' +) +' +b +' +' +return +b +' +) +; +" +__FILE__ +__LINE__ +) +) +; +CHECK +( +! +execDontReport +( +" +new +Function +( +' +a +' +CreateFakeTrustedType +( +' +b +' +' +c +' +) +' +return +a +' +) +; +" +__FILE__ +__LINE__ +) +) +; +CHECK +( +! +execDontReport +( +" +new +Function +( +' +a +' +' +b +' +CreateFakeTrustedType +( +' +return +a +" +" +* +b +' +' +return +a ++ +b +' +) +) +; +" +__FILE__ +__LINE__ +) +) +; +CHECK +( +! +execDontReport +( +" +new +Function +( +' +a +' +' +b +' +new +TrustedType +( +undefined +) +) +; +" +__FILE__ +__LINE__ +) +) +; +EVAL +( +" +eval +( +CreateFakeTrustedType +( +' +5 +* +8 +' +' +6 +* +7 +' +) +) +; +" +& +v +) +; +CHECK +( +v +. +isNumber +( +) +& +& +v +. +toNumber +( +) += += +40 +) +; +EVAL +( +" +eval +( +new +TrustedType +( +undefined +) +) +; +" +& +v +) +; +CHECK +( +v +. +isObject +( +) +) +; +JS +: +: +RootedObject +obj +( +cx +& +v +. +toObject +( +) +) +; +JS +: +: +RootedValue +trustedCode +( +cx +) +; +CHECK +( +JS_GetProperty +( +cx +obj +" +trustedCode +" +& +trustedCode +) +) +; +CHECK +( +trustedCode +. +isUndefined +( +) +) +; +return +true +; +} +static +bool +StringifiedObjectsMatchTrustedCodeProperties +( +JSContext +* +aCx +JS +: +: +RuntimeCode +aKind +JS +: +: +Handle +< +JSString +* +> +aCodeString +JS +: +: +CompilationType +aCompilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +aParameterStrings +JS +: +: +Handle +< +JSString +* +> +aBodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +aParameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +aBodyArg +bool +* +aOutCanCompileStrings +) +{ +bool +isTrusted += +true +; +auto +comparePropertyAndString += +[ +& +aCx +& +isTrusted +] +( +JS +: +: +Handle +< +JS +: +: +Value +> +aValue +JS +: +: +Handle +< +JSString +* +> +aString +) +{ +if +( +! +aValue +. +isObject +( +) +) +{ +return +true +; +} +JS +: +: +RootedObject +obj +( +aCx +& +aValue +. +toObject +( +) +) +; +JS +: +: +RootedString +trustedCode +( +aCx +) +; +if +( +! +ExtractTrustedCodeStringProperty +( +aCx +obj +& +trustedCode +) +) +{ +return +false +; +} +if +( +! +trustedCode +) +{ +JS_ReportErrorASCII +( +aCx +" +test +failed +trustedCode +property +is +undefined +" +) +; +return +false +; +} +bool +equals +; +if +( +! +EqualStrings +( +aCx +trustedCode +aString +& +equals +) +) +{ +return +false +; +} +if +( +! +equals +) +{ +isTrusted += +false +; +} +return +true +; +} +; +if +( +! +comparePropertyAndString +( +aBodyArg +aBodyString +) +) +{ +return +false +; +} +if +( +isTrusted +) +{ +MOZ_ASSERT +( +aParameterArgs +. +length +( +) += += +aParameterStrings +. +length +( +) +) +; +for +( +size_t +index += +0 +; +index +< +aParameterArgs +. +length +( +) +; +index ++ ++ +) +{ +if +( +! +comparePropertyAndString +( +aParameterArgs +[ +index +] +aParameterStrings +[ +index +] +) +) +{ +return +false +; +} +if +( +! +isTrusted +) +{ +break +; +} +} +} +* +aOutCanCompileStrings += +isTrusted +; +return +true +; +} +END_TEST +( +testDynamicCodeBrandChecks_CustomHostEnsureCanCompileStrings +) +BEGIN_TEST +( +testDynamicCodeBrandChecks_RejectObjectForEval +) +{ +JSSecurityCallbacks +securityCallbacksRejectObjectBody += +{ +DisallowObjectsAndFailOtherwise +ExtractTrustedCodeStringProperty +nullptr +} +; +JS_SetSecurityCallbacks +( +cx +& +securityCallbacksRejectObjectBody +) +; +JS +: +: +RootedValue +v +( +cx +) +; +EXEC +( +customTypesSnippet +) +; +CHECK +( +! +execDontReport +( +" +eval +( +' +5 +* +8 +) +) +" +__FILE__ +__LINE__ +) +) +; +CHECK +( +! +execDontReport +( +" +eval +( +new +TrustedType +( +' +5 +* +8 +' +) +) +" +__FILE__ +__LINE__ +) +) +; +return +true +; +} +static +bool +DisallowObjectsAndFailOtherwise +( +JSContext +* +aCx +JS +: +: +RuntimeCode +aKind +JS +: +: +Handle +< +JSString +* +> +aCodeString +JS +: +: +CompilationType +aCompilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +aParameterStrings +JS +: +: +Handle +< +JSString +* +> +aBodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +aParameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +aBodyArg +bool +* +aOutCanCompileStrings +) +{ +if +( +aBodyArg +. +isObject +( +) +) +{ +* +aOutCanCompileStrings += +false +; +return +true +; +} +JS_ReportErrorASCII +( +aCx +" +aBodyArg +is +not +an +Object +" +) +; +return +false +; +} +END_TEST +( +testDynamicCodeBrandChecks_RejectObjectForEval +) diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index b83fbddf55f4..ae16ad8bff63 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -6354,8 +6354,75 @@ JS : RuntimeCode kind -HandleString -code +JS +: +: +Handle +< +JSString +* +> +codeString +JS +: +: +CompilationType +compilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +parameterStrings +JS +: +: +Handle +< +JSString +* +> +bodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +parameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +bodyArg +bool +* +outCanCompileStrings ) { if @@ -6379,10 +6446,21 @@ allows ( this kind -code +codeString +compilationType +parameterStrings +bodyString +parameterArgs +bodyArg +outCanCompileStrings ) ; } +* +outCanCompileStrings += +true +; return true ; diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index ea8d94f8a2f2..c11776d598b2 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -3488,11 +3488,75 @@ JS : RuntimeCode kind -js +JS : : -HandleString -code +Handle +< +JSString +* +> +codeString +JS +: +: +CompilationType +compilationType +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JSString +* +> +> +parameterStrings +JS +: +: +Handle +< +JSString +* +> +bodyString +JS +: +: +Handle +< +JS +: +: +StackGCVector +< +JS +: +: +Value +> +> +parameterArgs +JS +: +: +Handle +< +JS +: +: +Value +> +bodyArg +bool +* +outCanCompileStrings ) ; bool diff --git a/js/src/vm/JSFunction.cpp b/js/src/vm/JSFunction.cpp index fcec3b837724..f9f28c4061b4 100644 --- a/js/src/vm/JSFunction.cpp +++ b/js/src/vm/JSFunction.cpp @@ -6551,6 +6551,31 @@ return false ; } +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; if ( args @@ -6579,6 +6604,30 @@ length - 1 ; +if +( +! +parameterStrings +. +reserve +( +n +) +| +| +! +parameterArgs +. +reserve +( +n +) +) +{ +return +false +; +} for ( unsigned @@ -6595,6 +6644,24 @@ i + ) { +if +( +! +parameterArgs +. +append +( +args +[ +i +] +) +) +{ +return +false +; +} str = ToString @@ -6622,6 +6689,21 @@ false if ( ! +parameterStrings +. +append +( +str +) +) +{ +return +false +; +} +if +( +! sb . append @@ -6739,6 +6821,21 @@ return false ; } +JS +: +: +RootedValue +bodyArg +( +cx +) +; +RootedString +bodyString +( +cx +) +; if ( args @@ -6750,16 +6847,8 @@ length 0 ) { -RootedString -body -( -cx -ToString -< -CanGC -> -( -cx +bodyArg += args [ args @@ -6770,13 +6859,22 @@ length - 1 ] -) +; +bodyString += +ToString +< +CanGC +> +( +cx +bodyArg ) ; if ( ! -body +bodyString | | ! @@ -6784,7 +6882,7 @@ sb . append ( -body +bodyString ) ) { @@ -6852,6 +6950,11 @@ return false ; } +bool +canCompileStrings += +false +; if ( ! @@ -6868,9 +6971,32 @@ RuntimeCode : JS functionText +JS +: +: +CompilationType +: +: +Function +parameterStrings +bodyString +parameterArgs +bodyArg +& +canCompileStrings ) ) { +return +false +; +} +if +( +! +canCompileStrings +) +{ JS_ReportErrorNumberASCII ( cx diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp index 252a3c173b7a..1d97abbbc984 100644 --- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -8549,6 +8549,36 @@ return false ; } +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -8565,7 +8595,30 @@ RuntimeCode : WASM nullptr +JS +: +: +CompilationType +: +: +Undefined +parameterStrings +nullptr +parameterArgs +NullHandleValue +& +canCompileStrings +) ) +{ +return +false +; +} +if +( +! +canCompileStrings ) { JS_ReportErrorNumberASCII @@ -23679,6 +23732,36 @@ argc vp ) ; +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -23695,7 +23778,35 @@ RuntimeCode : WASM nullptr +JS +: +: +CompilationType +: +: +Undefined +parameterStrings +nullptr +parameterArgs +NullHandleValue +& +canCompileStrings +) +) +{ +return +RejectWithPendingException +( +cx +promise +callArgs ) +; +} +if +( +! +canCompileStrings ) { JS_ReportErrorNumberASCII @@ -24129,6 +24240,36 @@ false } else { +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -24145,7 +24286,35 @@ RuntimeCode : WASM nullptr +JS +: +: +CompilationType +: +: +Undefined +parameterStrings +nullptr +parameterArgs +NullHandleValue +& +canCompileStrings +) +) +{ +return +RejectWithPendingException +( +cx +promise +callArgs ) +; +} +if +( +! +canCompileStrings ) { JS_ReportErrorNumberASCII @@ -26864,6 +27033,36 @@ argc vp ) ; +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -26880,7 +27079,35 @@ RuntimeCode : WASM nullptr +JS +: +: +CompilationType +: +: +Undefined +parameterStrings +nullptr +parameterArgs +NullHandleValue +& +canCompileStrings +) +) +{ +return +RejectWithPendingException +( +cx +resultPromise +callArgs ) +; +} +if +( +! +canCompileStrings ) { JS_ReportErrorNumberASCII @@ -27047,6 +27274,36 @@ argc vp ) ; +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -27063,9 +27320,37 @@ RuntimeCode : WASM nullptr +JS +: +: +CompilationType +: +: +Undefined +parameterStrings +nullptr +parameterArgs +NullHandleValue +& +canCompileStrings ) ) { +return +RejectWithPendingException +( +cx +resultPromise +callArgs +) +; +} +if +( +! +canCompileStrings +) +{ JS_ReportErrorNumberASCII ( cx diff --git a/js/src/wasm/WasmModule.cpp b/js/src/wasm/WasmModule.cpp index c0b0460cd3ea..e4cbce899aca 100644 --- a/js/src/wasm/WasmModule.cpp +++ b/js/src/wasm/WasmModule.cpp @@ -990,6 +990,36 @@ return nullptr ; } +JS +: +: +RootedVector +< +JSString +* +> +parameterStrings +( +cx +) +; +JS +: +: +RootedVector +< +Value +> +parameterArgs +( +cx +) +; +bool +canCompileStrings += +false +; if ( ! @@ -1006,9 +1036,32 @@ RuntimeCode : WASM nullptr +JS +: +: +CompilationType +: +: +Undefined +parameterStrings +nullptr +parameterArgs +NullHandleValue +& +canCompileStrings ) ) { +return +nullptr +; +} +if +( +! +canCompileStrings +) +{ JS_ReportErrorNumberASCII ( cx