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

Commit

Permalink
deps: update ChakraCore to chakra-core/ChakraCore@12a738b390
Browse files Browse the repository at this point in the history
[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 <[email protected]>
  • Loading branch information
akroshg authored and kfarnung committed Jan 17, 2018
1 parent 007bb82 commit 0095e23
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
41 changes: 41 additions & 0 deletions deps/chakrashim/core/bin/NativeTests/JsRTApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,47 @@ namespace JsRTApiTest

}

void SetModuleHostInfoTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
{
JsModuleRecord requestModule = JS_INVALID_REFERENCE;
JsValueRef specifier = nullptr;

REQUIRE(JsPointerToString(_u("mod1.js"), wcslen(_u("mod1.js")), &specifier) == JsNoError);
REQUIRE(JsInitializeModuleRecord(nullptr, specifier, &requestModule) == JsNoError);
JsValueRef error = nullptr, errorMsg = nullptr;
REQUIRE(JsPointerToString(_u("test error"), wcslen(_u("test error")), &errorMsg) == JsNoError);
REQUIRE(JsCreateError(errorMsg, &error) == JsNoError);

REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, error) == JsNoError);

JsValueRef errorOut = nullptr;
JsGetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, &errorOut);
REQUIRE(errorOut == error);

//REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, nullptr) == JsNoError);

REQUIRE(JsPointerToString(_u("mod2.js"), wcslen(_u("mod2.js")), &specifier) == JsNoError);
REQUIRE(JsInitializeModuleRecord(nullptr, specifier, &requestModule) == JsNoError);

successTest.mainModule = requestModule;
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_NotifyModuleReadyCallback, Succes_NMRC) == JsNoError);

// Parsing
JsValueRef errorObject1 = JS_INVALID_REFERENCE;
const char* fileContent = "var x = 10";
REQUIRE(JsParseModuleSource(requestModule, 0, (LPBYTE)fileContent,
(unsigned int)strlen(fileContent), JsParseModuleSourceFlags_DataIsUTF8, &errorObject1) == JsNoError);

// This should not pass
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_Exception, error) != JsNoError);
}

TEST_CASE("ApiTest_SetModuleHostInfoTest", "[ApiTest]")
{
JsRTApiTest::WithSetup(JsRuntimeAttributeEnableExperimentalFeatures, SetModuleHostInfoTest);

}

ModuleResponseData reentrantParseData;
static JsErrorCode CALLBACK ReentrantParse_FIMC(_In_ JsModuleRecord referencingModule, _In_ JsValueRef specifier, _Outptr_result_maybenull_ JsModuleRecord* dependentModuleRecord)
{
Expand Down
6 changes: 4 additions & 2 deletions deps/chakrashim/core/lib/Jsrt/Core/JsrtCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ JsSetModuleHostInfo(
switch (moduleHostInfo)
{
case JsModuleHostInfo_Exception:
moduleRecord->OnHostException(hostInfo);
break;
{
HRESULT hr = moduleRecord->OnHostException(hostInfo);
return (hr == NOERROR) ? JsNoError : JsErrorInvalidArgument;
}
case JsModuleHostInfo_HostDefined:
moduleRecord->SetHostDefined(hostInfo);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,6 @@ namespace Js
{
return E_INVALIDARG;
}
AssertMsg(!WasParsed(), "shouldn't be called after a module is parsed");
if (WasParsed())
{
return E_INVALIDARG;
Expand Down

0 comments on commit 0095e23

Please sign in to comment.