OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/V8ScriptRunner.h" | 6 #include "bindings/core/v8/V8ScriptRunner.h" |
7 | 7 |
8 #include "core/fetch/ScriptResource.h" | 8 #include "core/fetch/ScriptResource.h" |
| 9 #include "platform/heap/Handle.h" |
9 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
10 #include <v8.h> | 11 #include <v8.h> |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 class V8ScriptRunnerTest : public ::testing::Test { | 17 class V8ScriptRunnerTest : public ::testing::Test { |
17 public: | 18 public: |
18 V8ScriptRunnerTest() { } | 19 V8ScriptRunnerTest() { } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 v8::Context::Scope contextScope(context); | 74 v8::Context::Scope contextScope(context); |
74 return !V8ScriptRunner::compileScript( | 75 return !V8ScriptRunner::compileScript( |
75 v8String(code()), filename(), WTF::TextPosition(), m_resource.get(), | 76 v8String(code()), filename(), WTF::TextPosition(), m_resource.get(), |
76 isolate(), NotSharableCrossOrigin, cacheOptions) | 77 isolate(), NotSharableCrossOrigin, cacheOptions) |
77 .IsEmpty(); | 78 .IsEmpty(); |
78 } | 79 } |
79 | 80 |
80 void setEmptyResource() | 81 void setEmptyResource() |
81 { | 82 { |
82 m_resourceRequest = WTF::adoptPtr(new ResourceRequest); | 83 m_resourceRequest = WTF::adoptPtr(new ResourceRequest); |
83 m_resource = WTF::adoptPtr(new ScriptResource(*m_resourceRequest.get(),
"text/utf-8")); | 84 m_resource = adoptPtrWillBeNoop(new ScriptResource(*m_resourceRequest.ge
t(), "text/utf-8")); |
84 } | 85 } |
85 | 86 |
86 void setResource() | 87 void setResource() |
87 { | 88 { |
88 m_resourceRequest = WTF::adoptPtr(new ResourceRequest(url())); | 89 m_resourceRequest = WTF::adoptPtr(new ResourceRequest(url())); |
89 m_resource = WTF::adoptPtr(new ScriptResource(*m_resourceRequest.get(),
"text/utf-8")); | 90 m_resource = adoptPtrWillBeNoop(new ScriptResource(*m_resourceRequest.ge
t(), "text/utf-8")); |
90 } | 91 } |
91 | 92 |
92 protected: | 93 protected: |
93 WTF::OwnPtr<ResourceRequest> m_resourceRequest; | 94 WTF::OwnPtr<ResourceRequest> m_resourceRequest; |
94 WTF::OwnPtr<ScriptResource> m_resource; | 95 OwnPtrWillBePersistent<ScriptResource> m_resource; |
95 | 96 |
96 static unsigned cacheTagParser; | 97 static unsigned cacheTagParser; |
97 static unsigned cacheTagCode; | 98 static unsigned cacheTagCode; |
98 static int counter; | 99 static int counter; |
99 }; | 100 }; |
100 | 101 |
101 unsigned V8ScriptRunnerTest::cacheTagParser = 0; | 102 unsigned V8ScriptRunnerTest::cacheTagParser = 0; |
102 unsigned V8ScriptRunnerTest::cacheTagCode = 0; | 103 unsigned V8ScriptRunnerTest::cacheTagCode = 0; |
103 int V8ScriptRunnerTest::counter = 0; | 104 int V8ScriptRunnerTest::counter = 0; |
104 | 105 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 EXPECT_FALSE(m_resource->cachedMetadata(cacheTagParser)); | 149 EXPECT_FALSE(m_resource->cachedMetadata(cacheTagParser)); |
149 | 150 |
150 // TODO(vogelheim): Code caching is presently still disabled. | 151 // TODO(vogelheim): Code caching is presently still disabled. |
151 // Enable EXPECT when code caching lands. | 152 // Enable EXPECT when code caching lands. |
152 // EXPECT_TRUE(m_resource->cachedMetadata(cacheTagCode)); | 153 // EXPECT_TRUE(m_resource->cachedMetadata(cacheTagCode)); |
153 } | 154 } |
154 | 155 |
155 } // namespace | 156 } // namespace |
156 | 157 |
157 } // namespace blink | 158 } // namespace blink |
OLD | NEW |