Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp

Issue 2835133004: [ES6 modules] Unit test ScriptModule::Evaluate (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp
index 183efbb9184e256e9aed482e8236c98646a7b595..c85ee63a6171279316690b5e5d4d73bf55c81469 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp
@@ -4,9 +4,13 @@
#include "bindings/core/v8/ScriptModule.h"
+#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/ScriptSourceCode.h"
+#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8BindingForTesting.h"
#include "bindings/core/v8/V8PerContextData.h"
#include "core/dom/ScriptModuleResolver.h"
+#include "core/frame/LocalFrame.h"
#include "core/testing/DummyModulator.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -194,6 +198,28 @@ TEST(ScriptModuleTest, instantiateWithDeps) {
EXPECT_EQ("b", resolver->Specifiers()[1]);
}
+TEST(ScriptModuleTest, Evaluate) {
+ V8TestingScope scope;
+
+ auto modulator = new ScriptModuleTestModulator();
+ Modulator::SetModulator(scope.GetScriptState(), modulator);
+
+ ScriptModule module = ScriptModule::Compile(
+ scope.GetIsolate(), "export const a = 42; window.foo = 'bar';", "foo.js",
+ kSharableCrossOrigin);
+ ASSERT_FALSE(module.IsNull());
+ ScriptValue exception = module.Instantiate(scope.GetScriptState());
+ ASSERT_TRUE(exception.IsEmpty());
+
+ module.Evaluate(scope.GetScriptState());
+ v8::Local<v8::Value> value = scope.GetFrame()
+ .GetScriptController()
+ .ExecuteScriptInMainWorldAndReturnValue(
+ ScriptSourceCode("window.foo"));
+ ASSERT_TRUE(value->IsString());
+ EXPECT_EQ("bar", ToCoreString(v8::Local<v8::String>::Cast(value)));
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698