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

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

Issue 2695713015: WIP: Reland CompiledScript, prototype compiling in a separate task.
Patch Set: allow fetchFinished to finish when there is no frame Created 3 years, 10 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
Index: third_party/WebKit/Source/bindings/core/v8/ScriptControllerTest.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptControllerTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptControllerTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..850f86eb5fd56655b0f13f09fd1f833355cec09c
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptControllerTest.cpp
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "bindings/core/v8/ScriptController.h"
+
+#include "bindings/core/v8/ScriptSourceCode.h"
+#include "bindings/core/v8/V8BindingForTesting.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+namespace {
+
+TEST(ScriptControllerTest, CompileAndExecuteScriptInMainWorld) {
+ V8TestingScope scope;
+ ScriptController& script = scope.frame().script();
+ CompiledScript* compiled = script.compileScriptInMainWorld(
+ ScriptSourceCode("x = 42;"), NotSharableCrossOrigin);
+ script.executeScriptInMainWorld(*compiled);
+ v8::Local<v8::Value> value =
+ script.executeScriptInMainWorldAndReturnValue(ScriptSourceCode("x"));
+ EXPECT_EQ(42, value->Int32Value());
+}
+
+TEST(ScriptControllerTest, CompileAndExecuteScriptInMainWorldInterleaved) {
+ V8TestingScope scope;
+ ScriptController& script = scope.frame().script();
+ CompiledScript* compiled = script.compileScriptInMainWorld(
+ ScriptSourceCode("x *= 2;"), NotSharableCrossOrigin);
+ CompiledScript* compiled2 = script.compileScriptInMainWorld(
+ ScriptSourceCode("x = 21;"), NotSharableCrossOrigin);
+ script.executeScriptInMainWorld(*compiled2);
+ script.executeScriptInMainWorld(*compiled);
+ v8::Local<v8::Value> value =
+ script.executeScriptInMainWorldAndReturnValue(ScriptSourceCode("x"));
+ EXPECT_EQ(42, value->Int32Value());
+}
+
+} // namespace
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp ('k') | third_party/WebKit/Source/core/dom/PendingScript.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698