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@7c4f6a5e48
Browse files Browse the repository at this point in the history
[1.8>1.9] [MERGE #4548 @akroshg] Passing correct module specifier when setting a parent

Merge pull request #4548 from akroshg:setparent

Reviewed-By: chakrabot <[email protected]>
  • Loading branch information
akroshg authored and chakrabot committed Jan 17, 2018
1 parent 300c5b8 commit bf5c71f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
48 changes: 48 additions & 0 deletions deps/chakrashim/core/bin/NativeTests/JsRTApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,54 @@ namespace JsRTApiTest

}

static JsErrorCode CALLBACK Success_FIMC1(_In_ JsModuleRecord referencingModule, _In_ JsValueRef specifier, _Outptr_result_maybenull_ JsModuleRecord* dependentModuleRecord)
{
JsModuleRecord moduleRecord = JS_INVALID_REFERENCE;
LPCWSTR specifierStr;
size_t length;

JsErrorCode errorCode = JsStringToPointer(specifier, &specifierStr, &length);
REQUIRE(errorCode == JsNoError);
REQUIRE(!wcscmp(specifierStr, _u("foo.js")));

JsValueRef specifier1 = nullptr;
REQUIRE(JsPointerToString(_u("./foo.js"), wcslen(_u("./foo.js")), &specifier1) == JsNoError);

errorCode = JsInitializeModuleRecord(referencingModule, specifier1, &moduleRecord);
REQUIRE(errorCode == JsNoError);
*dependentModuleRecord = moduleRecord;
successTest.childModule = moduleRecord;
return JsNoError;
}

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

REQUIRE(JsPointerToString(_u(""), 1, &specifier) == JsNoError);
REQUIRE(JsInitializeModuleRecord(nullptr, specifier, &requestModule) == JsNoError);
successTest.mainModule = requestModule;
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_FetchImportedModuleCallback, Success_FIMC1) == JsNoError);
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_FetchImportedModuleFromScriptCallback, Success_FIMC1) == JsNoError);
REQUIRE(JsSetModuleHostInfo(requestModule, JsModuleHostInfo_NotifyModuleReadyCallback, Succes_NMRC) == JsNoError);

JsValueRef errorObject = JS_INVALID_REFERENCE;
const char* fileContent = "import {x} from 'foo.js'";
JsErrorCode errorCode = JsParseModuleSource(requestModule, 0, (LPBYTE)fileContent,
(unsigned int)strlen(fileContent), JsParseModuleSourceFlags_DataIsUTF8, &errorObject);

CHECK(errorCode == JsNoError);
CHECK(errorObject == JS_INVALID_REFERENCE);
REQUIRE(successTest.childModule != JS_INVALID_REFERENCE);
}

TEST_CASE("ApiTest_PassingDifferentModuleSpecifierTest", "[ApiTest]")
{
JsRTApiTest::WithSetup(JsRuntimeAttributeEnableExperimentalFeatures, PassingDifferentModuleSpecifierTest);

}

ModuleResponseData reentrantParseData;
static JsErrorCode CALLBACK ReentrantParse_FIMC(_In_ JsModuleRecord referencingModule, _In_ JsValueRef specifier, _Outptr_result_maybenull_ JsModuleRecord* dependentModuleRecord)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ namespace Js
this->parentModuleList = RecyclerNew(recycler, ModuleRecordList, recycler);
}
bool contains = this->parentModuleList->Contains(parentRecord);
Assert(!contains);
if (!contains)
{
this->parentModuleList->Add(parentRecord);
Expand Down

0 comments on commit bf5c71f

Please sign in to comment.