Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit da8376c

Browse files
akroshgchakrabot
authored andcommitted
deps: update ChakraCore to chakra-core/ChakraCore@12a738b390
[1.8>1.9] [MERGE #4540 @akroshg] Module : SetModuleHostInfo's error propagation properly and useless assert removal. Merge pull request #4540 from akroshg:sethostinfo Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
1 parent 859e314 commit da8376c

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

deps/chakrashim/core/bin/NativeTests/JsRTApiTest.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,47 @@ namespace JsRTApiTest
21922192

21932193
}
21942194

2195+
void SetModuleHostInfoTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
2196+
{
2197+
JsModuleRecord requestModule = JS_INVALID_REFERENCE;
2198+
JsValueRef specifier = nullptr;
2199+
2200+
REQUIRE(JsPointerToString(_u("mod1.js"), wcslen(_u("mod1.js")), &specifier) == JsNoError);
2201+
REQUIRE(JsInitializeModuleRecord(nullptr, specifier, &requestModule) == JsNoError);
2202+
JsValueRef error = nullptr, errorMsg = nullptr;
2203+
REQUIRE(JsPointerToString(_u("test error"), wcslen(_u("test error")), &errorMsg) == JsNoError);
2204+
REQUIRE(JsCreateError(errorMsg, &error) == JsNoError);
2205+
2206+
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, error) == JsNoError);
2207+
2208+
JsValueRef errorOut = nullptr;
2209+
JsGetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, &errorOut);
2210+
REQUIRE(errorOut == error);
2211+
2212+
//REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, nullptr) == JsNoError);
2213+
2214+
REQUIRE(JsPointerToString(_u("mod2.js"), wcslen(_u("mod2.js")), &specifier) == JsNoError);
2215+
REQUIRE(JsInitializeModuleRecord(nullptr, specifier, &requestModule) == JsNoError);
2216+
2217+
successTest.mainModule = requestModule;
2218+
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_NotifyModuleReadyCallback, Succes_NMRC) == JsNoError);
2219+
2220+
// Parsing
2221+
JsValueRef errorObject1 = JS_INVALID_REFERENCE;
2222+
const char* fileContent = "var x = 10";
2223+
REQUIRE(JsParseModuleSource(requestModule, 0, (LPBYTE)fileContent,
2224+
(unsigned int)strlen(fileContent), JsParseModuleSourceFlags_DataIsUTF8, &errorObject1) == JsNoError);
2225+
2226+
// This should not pass
2227+
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, error) != JsNoError);
2228+
}
2229+
2230+
TEST_CASE("ApiTest_SetModuleHostInfoTest", "[ApiTest]")
2231+
{
2232+
JsRTApiTest::WithSetup(JsRuntimeAttributeEnableExperimentalFeatures, SetModuleHostInfoTest);
2233+
2234+
}
2235+
21952236
ModuleResponseData reentrantParseData;
21962237
static JsErrorCode CALLBACK ReentrantParse_FIMC(_In_ JsModuleRecord referencingModule, _In_ JsValueRef specifier, _Outptr_result_maybenull_ JsModuleRecord* dependentModuleRecord)
21972238
{

deps/chakrashim/core/lib/Jsrt/Core/JsrtCore.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ JsSetModuleHostInfo(
158158
switch (moduleHostInfo)
159159
{
160160
case JsModuleHostInfo_Exception:
161-
moduleRecord->OnHostException(hostInfo);
162-
break;
161+
{
162+
HRESULT hr = moduleRecord->OnHostException(hostInfo);
163+
return (hr == NOERROR) ? JsNoError : JsErrorInvalidArgument;
164+
}
163165
case JsModuleHostInfo_HostDefined:
164166
moduleRecord->SetHostDefined(hostInfo);
165167
break;

deps/chakrashim/core/lib/Runtime/Language/SourceTextModuleRecord.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,6 @@ namespace Js
960960
{
961961
return E_INVALIDARG;
962962
}
963-
AssertMsg(!WasParsed(), "shouldn't be called after a module is parsed");
964963
if (WasParsed())
965964
{
966965
return E_INVALIDARG;

0 commit comments

Comments
 (0)