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 "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "core/fetch/ScriptResource.h" | 9 #include "core/fetch/ScriptResource.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 { | 65 { |
66 return !V8ScriptRunner::compileScript( | 66 return !V8ScriptRunner::compileScript( |
67 v8String(isolate(), code()), filename(), WTF::TextPosition(), | 67 v8String(isolate(), code()), filename(), WTF::TextPosition(), |
68 m_resource.get(), 0, isolate(), NotSharableCrossOrigin, cacheOptions
) | 68 m_resource.get(), 0, isolate(), NotSharableCrossOrigin, cacheOptions
) |
69 .IsEmpty(); | 69 .IsEmpty(); |
70 } | 70 } |
71 | 71 |
72 void setEmptyResource() | 72 void setEmptyResource() |
73 { | 73 { |
74 m_resourceRequest = WTF::adoptPtr(new ResourceRequest); | 74 m_resourceRequest = WTF::adoptPtr(new ResourceRequest); |
75 m_resource = adoptPtrWillBeNoop(new ScriptResource(*m_resourceRequest.ge
t(), "UTF-8")); | 75 m_resource = ScriptResource::create(*m_resourceRequest.get(), "UTF-8"); |
76 } | 76 } |
77 | 77 |
78 void setResource() | 78 void setResource() |
79 { | 79 { |
80 m_resourceRequest = WTF::adoptPtr(new ResourceRequest(url())); | 80 m_resourceRequest = WTF::adoptPtr(new ResourceRequest(url())); |
81 m_resource = adoptPtrWillBeNoop(new ScriptResource(*m_resourceRequest.ge
t(), "UTF-8")); | 81 m_resource = ScriptResource::create(*m_resourceRequest.get(), "UTF-8"); |
82 } | 82 } |
83 | 83 |
84 protected: | 84 protected: |
85 WTF::OwnPtr<ResourceRequest> m_resourceRequest; | 85 WTF::OwnPtr<ResourceRequest> m_resourceRequest; |
86 OwnPtrWillBePersistent<ScriptResource> m_resource; | 86 OwnPtrWillBePersistent<ScriptResource> m_resource; |
87 V8TestingScope m_scope; | 87 V8TestingScope m_scope; |
88 | 88 |
89 static int counter; | 89 static int counter; |
90 }; | 90 }; |
91 | 91 |
(...skipping 24 matching lines...) Expand all Loading... |
116 } | 116 } |
117 | 117 |
118 TEST_F(V8ScriptRunnerTest, parseMemoryOption) | 118 TEST_F(V8ScriptRunnerTest, parseMemoryOption) |
119 { | 119 { |
120 setResource(); | 120 setResource(); |
121 EXPECT_TRUE(compileScript(V8CacheOptionsParseMemory)); | 121 EXPECT_TRUE(compileScript(V8CacheOptionsParseMemory)); |
122 EXPECT_TRUE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())))
; | 122 EXPECT_TRUE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())))
; |
123 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); | 123 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); |
124 // The cached data is associated with the encoding. | 124 // The cached data is associated with the encoding. |
125 ResourceRequest request(url()); | 125 ResourceRequest request(url()); |
126 ScriptResource anotherResource(request, "UTF-16"); | 126 OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create(
request, "UTF-16"); |
127 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(&anotherResource))
); | 127 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(anotherResource.ge
t()))); |
128 } | 128 } |
129 | 129 |
130 TEST_F(V8ScriptRunnerTest, parseOption) | 130 TEST_F(V8ScriptRunnerTest, parseOption) |
131 { | 131 { |
132 setResource(); | 132 setResource(); |
133 EXPECT_TRUE(compileScript(V8CacheOptionsParse)); | 133 EXPECT_TRUE(compileScript(V8CacheOptionsParse)); |
134 EXPECT_TRUE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())))
; | 134 EXPECT_TRUE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())))
; |
135 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); | 135 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); |
136 // The cached data is associated with the encoding. | 136 // The cached data is associated with the encoding. |
137 ResourceRequest request(url()); | 137 ResourceRequest request(url()); |
138 ScriptResource anotherResource(request, "UTF-16"); | 138 OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create(
request, "UTF-16"); |
139 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(&anotherResource))
); | 139 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(anotherResource.ge
t()))); |
140 } | 140 } |
141 | 141 |
142 TEST_F(V8ScriptRunnerTest, codeOption) | 142 TEST_F(V8ScriptRunnerTest, codeOption) |
143 { | 143 { |
144 setResource(); | 144 setResource(); |
145 EXPECT_TRUE(compileScript(V8CacheOptionsCode)); | 145 EXPECT_TRUE(compileScript(V8CacheOptionsCode)); |
146 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get()))
); | 146 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get()))
); |
147 EXPECT_TRUE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); | 147 EXPECT_TRUE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); |
148 // The cached data is associated with the encoding. | 148 // The cached data is associated with the encoding. |
149 ResourceRequest request(url()); | 149 ResourceRequest request(url()); |
150 ScriptResource anotherResource(request, "UTF-16"); | 150 OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create(
request, "UTF-16"); |
151 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(&anotherResource))); | 151 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(anotherResource.get(
)))); |
152 } | 152 } |
153 | 153 |
154 TEST_F(V8ScriptRunnerTest, codeCompressedOptions) | 154 TEST_F(V8ScriptRunnerTest, codeCompressedOptions) |
155 { | 155 { |
156 setResource(); | 156 setResource(); |
157 EXPECT_TRUE(compileScript(V8CacheOptionsCodeCompressed)); | 157 EXPECT_TRUE(compileScript(V8CacheOptionsCodeCompressed)); |
158 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get()))
); | 158 EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get()))
); |
159 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); | 159 EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get()))); |
160 } | 160 } |
161 | 161 |
162 } // namespace | 162 } // namespace |
163 | 163 |
164 } // namespace blink | 164 } // namespace blink |
OLD | NEW |