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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "bindings/core/v8/ScriptController.h"
6
7 #include "bindings/core/v8/ScriptSourceCode.h"
8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace blink {
12 namespace {
13
14 TEST(ScriptControllerTest, CompileAndExecuteScriptInMainWorld) {
15 V8TestingScope scope;
16 ScriptController& script = scope.frame().script();
17 CompiledScript* compiled = script.compileScriptInMainWorld(
18 ScriptSourceCode("x = 42;"), NotSharableCrossOrigin);
19 script.executeScriptInMainWorld(*compiled);
20 v8::Local<v8::Value> value =
21 script.executeScriptInMainWorldAndReturnValue(ScriptSourceCode("x"));
22 EXPECT_EQ(42, value->Int32Value());
23 }
24
25 TEST(ScriptControllerTest, CompileAndExecuteScriptInMainWorldInterleaved) {
26 V8TestingScope scope;
27 ScriptController& script = scope.frame().script();
28 CompiledScript* compiled = script.compileScriptInMainWorld(
29 ScriptSourceCode("x *= 2;"), NotSharableCrossOrigin);
30 CompiledScript* compiled2 = script.compileScriptInMainWorld(
31 ScriptSourceCode("x = 21;"), NotSharableCrossOrigin);
32 script.executeScriptInMainWorld(*compiled2);
33 script.executeScriptInMainWorld(*compiled);
34 v8::Local<v8::Value> value =
35 script.executeScriptInMainWorldAndReturnValue(ScriptSourceCode("x"));
36 EXPECT_EQ(42, value->Int32Value());
37 }
38
39 } // namespace
40 } // namespace blink
OLDNEW
« 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