Skip to content

Commit

Permalink
Disable dynamic import and put it behind the flag.
Browse files Browse the repository at this point in the history
The host work is still pending so instead of showing this as a broken feature, it will be displayed as not supported feature.
  • Loading branch information
akroshg committed Nov 8, 2017
1 parent 739cde3 commit f7bcf68
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
44 changes: 44 additions & 0 deletions bin/NativeTests/JsRTApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,7 @@ namespace JsRTApiTest
JsRTApiTest::WithSetup(JsRuntimeAttributeEnableExperimentalFeatures, ReentrantParseModuleTest);
}


ModuleResponseData reentrantNoErrorParseData;
static JsErrorCode CALLBACK reentrantNoErrorParse_FIMC(_In_ JsModuleRecord referencingModule, _In_ JsValueRef specifier, _Outptr_result_maybenull_ JsModuleRecord* dependentModuleRecord)
{
Expand Down Expand Up @@ -2131,6 +2132,49 @@ namespace JsRTApiTest
JsRTApiTest::WithSetup(JsRuntimeAttributeEnableExperimentalFeatures, ReentrantNoErrorParseModuleTest);
}

static JsErrorCode CALLBACK 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);

if (wcscmp(specifierStr, _u("foo.js")) == 0)
{
errorCode = JsInitializeModuleRecord(referencingModule, specifier, &moduleRecord);
REQUIRE(errorCode == JsNoError);
*dependentModuleRecord = moduleRecord;
}
return JsNoError;
}

static JsErrorCode CALLBACK NMRC1(_In_opt_ JsModuleRecord referencingModule, _In_opt_ JsValueRef exceptionVar)
{
// NotifyModuleReadyCallback handling.

return JsNoError;
}

void SomebugTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
{
JsModuleRecord rec;
JsInitializeModuleRecord(nullptr, nullptr, &rec);
JsSetModuleHostInfo(rec, JsModuleHostInfo_FetchImportedModuleCallback, FIMC1);
JsSetModuleHostInfo(rec, JsModuleHostInfo_FetchImportedModuleFromScriptCallback, FIMC1);
JsSetModuleHostInfo(rec, JsModuleHostInfo_NotifyModuleReadyCallback, NMRC1);

JsValueRef F = JS_INVALID_REFERENCE;
JsErrorCode err = JsRunScript(_u("var j = import('foo.js').then(mod => { mod.bar(); })"), 0, _u(""), &F);

CHECK(err == JsNoError);
}

TEST_CASE("ApiTest_SomebugTest", "[ApiTest]")
{
JsRTApiTest::WithSetup(JsRuntimeAttributeEnableExperimentalFeatures, SomebugTest);

}
void ObjectHasOwnPropertyMethodTest(JsRuntimeAttributes attributes, JsRuntimeHandle runtime)
{
JsValueRef proto = JS_INVALID_REFERENCE;
Expand Down
6 changes: 6 additions & 0 deletions lib/Common/ConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ PHASE(All)
#define DEFAULT_CONFIG_ES7TrailingComma (true)
#define DEFAULT_CONFIG_ES7ValuesEntries (true)
#define DEFAULT_CONFIG_ESObjectGetOwnPropertyDescriptors (true)
#define DEFAULT_CONFIG_ESDynamicImport (false)

#define DEFAULT_CONFIG_ESSharedArrayBuffer (true)

Expand Down Expand Up @@ -1037,6 +1038,11 @@ FLAGPR (Boolean, ES6, ES7TrailingComma , "Enable ES7 trailing co
FLAGPR (Boolean, ES6, ES6IsConcatSpreadable , "Enable ES6 isConcatSpreadable Symbol" , DEFAULT_CONFIG_ES6IsConcatSpreadable)
FLAGPR (Boolean, ES6, ES6Math , "Enable ES6 Math extensions" , DEFAULT_CONFIG_ES6Math)

#ifndef COMPILE_DISABLE_ESDynamicImport
#define COMPILE_DISABLE_ESDynamicImport 0
#endif
FLAGPR_REGOVR_EXP(Boolean, ES6, ESDynamicImport , "Enable dynamic import" , DEFAULT_CONFIG_ESDynamicImport)

FLAGPR (Boolean, ES6, ES6Module , "Enable ES6 Modules" , DEFAULT_CONFIG_ES6Module)
FLAGPR (Boolean, ES6, ES6Object , "Enable ES6 Object extensions" , DEFAULT_CONFIG_ES6Object)
FLAGPR (Boolean, ES6, ES6Number , "Enable ES6 Number extensions" , DEFAULT_CONFIG_ES6Number)
Expand Down
7 changes: 6 additions & 1 deletion lib/Parser/Parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2646,6 +2646,11 @@ ParseNodePtr Parser::ParseImport()
// import()
if (m_token.tk == tkLParen)
{
if (!m_scriptContext->GetConfig()->IsESDynamicImportEnabled())
{
Error(ERRsyntax);
}

ParseNodePtr pnode = ParseImportCall<buildAST>();
BOOL fCanAssign;
IdentToken token;
Expand Down Expand Up @@ -3522,7 +3527,7 @@ LFunction :
break;

case tkIMPORT:
if (m_scriptContext->GetConfig()->IsES6ModuleEnabled())
if (m_scriptContext->GetConfig()->IsES6ModuleEnabled() && m_scriptContext->GetConfig()->IsESDynamicImportEnabled())
{
m_pscan->Scan();
ChkCurTokNoScan(tkLParen, ERRnoLparen);
Expand Down
1 change: 1 addition & 0 deletions lib/Runtime/Base/ThreadConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ FLAG_RELEASE(SkipSplitOnNoResult, SkipSplitOnNoResult)
FLAG_RELEASE(IsES7AsyncAndAwaitEnabled, ES7AsyncAwait)
FLAG_RELEASE(IsESObjectGetOwnPropertyDescriptorsEnabled, ESObjectGetOwnPropertyDescriptors)
FLAG_RELEASE(IsESSharedArrayBufferEnabled, ESSharedArrayBuffer)
FLAG_RELEASE(IsESDynamicImportEnabled, ESDynamicImport)
#ifdef ENABLE_PROJECTION
FLAG(AreWinRTDelegatesInterfaces, WinRTDelegateInterfaces)
FLAG_RELEASE(IsWinRTAdaptiveAppsEnabled, WinRTAdaptiveApps)
Expand Down
8 changes: 4 additions & 4 deletions test/es6/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1366,14 +1366,14 @@
<test>
<default>
<files>dynamic-module-functionality.js</files>
<compile-flags>-ES6Module -args summary -endargs</compile-flags>
<compile-flags>-ES6Module -ESDynamicImport -args summary -endargs</compile-flags>
<tags>exclude_sanitize_address</tags>
</default>
</test>
<test>
<default>
<files>dynamic-module-import-specifier.js</files>
<compile-flags>-MuteHostErrorMsg -ES6Module -args summary -endargs</compile-flags>
<compile-flags>-MuteHostErrorMsg -ESDynamicImport -ES6Module -args summary -endargs</compile-flags>
<tags>exclude_sanitize_address</tags>
</default>
</test>
Expand Down Expand Up @@ -1410,7 +1410,7 @@
<test>
<default>
<files>bug_OS12095746.js</files>
<compile-flags>-MuteHostErrorMsg -IgnoreScriptErrorCode -TraceHostCallback -ES6Module</compile-flags>
<compile-flags>-MuteHostErrorMsg -IgnoreScriptErrorCode -TraceHostCallback -ES6Module -ESDynamicImport</compile-flags>
<tags>exclude_dynapogo,exclude_sanitize_address,bugfix,exclude_drt</tags>
<baseline>bug_OS12095746.baseline</baseline>
</default>
Expand Down Expand Up @@ -1459,7 +1459,7 @@
<test>
<default>
<files>bug_issue_3076.js</files>
<compile-flags>-force:deferparse</compile-flags>
<compile-flags>-force:deferparse -ESDynamicImport </compile-flags>
<tags>BugFix,exclude_sanitize_address</tags>
</default>
</test>
Expand Down

0 comments on commit f7bcf68

Please sign in to comment.