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

Side by Side Diff: Source/bindings/core/v8/V8ScriptRunnerTest.cpp

Issue 1170503003: Remove resource type-specific fetching logic from ResourceFetcher (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Null-check Document::loader() before calling startPreload() Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/core/v8/ScriptStreamerTest.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bindings/core/v8/V8BindingForTesting.h" 9 #include "bindings/core/v8/V8BindingForTesting.h"
10 #include "core/fetch/CachedMetadataHandler.h" 10 #include "core/fetch/CachedMetadataHandler.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 { 67 {
68 return !V8ScriptRunner::compileScript( 68 return !V8ScriptRunner::compileScript(
69 v8String(isolate(), code()), filename(), String(), WTF::TextPosition (), 69 v8String(isolate(), code()), filename(), String(), WTF::TextPosition (),
70 isolate(), m_resource.get(), nullptr, m_resource.get() ? m_resource- >cacheHandler(): nullptr, NotSharableCrossOrigin, cacheOptions) 70 isolate(), m_resource.get(), nullptr, m_resource.get() ? m_resource- >cacheHandler(): nullptr, NotSharableCrossOrigin, cacheOptions)
71 .IsEmpty(); 71 .IsEmpty();
72 } 72 }
73 73
74 void setEmptyResource() 74 void setEmptyResource()
75 { 75 {
76 m_resourceRequest = WTF::adoptPtr(new ResourceRequest); 76 m_resourceRequest = WTF::adoptPtr(new ResourceRequest);
77 m_resource = ScriptResource::create(*m_resourceRequest.get(), "UTF-8"); 77 m_resource = new ScriptResource(*m_resourceRequest.get(), "UTF-8");
78 } 78 }
79 79
80 void setResource() 80 void setResource()
81 { 81 {
82 m_resourceRequest = WTF::adoptPtr(new ResourceRequest(url())); 82 m_resourceRequest = WTF::adoptPtr(new ResourceRequest(url()));
83 m_resource = ScriptResource::create(*m_resourceRequest.get(), "UTF-8"); 83 m_resource = new ScriptResource(*m_resourceRequest.get(), "UTF-8");
84 } 84 }
85 85
86 CachedMetadataHandler* cacheHandler() 86 CachedMetadataHandler* cacheHandler()
87 { 87 {
88 return m_resource->cacheHandler(); 88 return m_resource->cacheHandler();
89 } 89 }
90 90
91 protected: 91 protected:
92 WTF::OwnPtr<ResourceRequest> m_resourceRequest; 92 WTF::OwnPtr<ResourceRequest> m_resourceRequest;
93 OwnPtrWillBePersistent<ScriptResource> m_resource; 93 ResourcePtr<ScriptResource> m_resource;
94 V8TestingScope m_scope; 94 V8TestingScope m_scope;
95 95
96 static int counter; 96 static int counter;
97 }; 97 };
98 98
99 int V8ScriptRunnerTest::counter = 0; 99 int V8ScriptRunnerTest::counter = 0;
100 100
101 TEST_F(V8ScriptRunnerTest, resourcelessShouldPass) 101 TEST_F(V8ScriptRunnerTest, resourcelessShouldPass)
102 { 102 {
103 EXPECT_TRUE(compileScript(V8CacheOptionsNone)); 103 EXPECT_TRUE(compileScript(V8CacheOptionsNone));
104 EXPECT_TRUE(compileScript(V8CacheOptionsParseMemory)); 104 EXPECT_TRUE(compileScript(V8CacheOptionsParseMemory));
105 EXPECT_TRUE(compileScript(V8CacheOptionsParse)); 105 EXPECT_TRUE(compileScript(V8CacheOptionsParse));
106 EXPECT_TRUE(compileScript(V8CacheOptionsCode)); 106 EXPECT_TRUE(compileScript(V8CacheOptionsCode));
107 } 107 }
108 108
109 TEST_F(V8ScriptRunnerTest, emptyResourceDoesNotHaveCacheHandler) 109 TEST_F(V8ScriptRunnerTest, emptyResourceDoesNotHaveCacheHandler)
110 { 110 {
111 setEmptyResource(); 111 setEmptyResource();
112 EXPECT_FALSE(cacheHandler()); 112 EXPECT_FALSE(cacheHandler());
113 } 113 }
114 114
115 TEST_F(V8ScriptRunnerTest, parseMemoryOption) 115 TEST_F(V8ScriptRunnerTest, parseMemoryOption)
116 { 116 {
117 setResource(); 117 setResource();
118 EXPECT_TRUE(compileScript(V8CacheOptionsParseMemory)); 118 EXPECT_TRUE(compileScript(V8CacheOptionsParseMemory));
119 EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler()) )); 119 EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler()) ));
120 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())) ); 120 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())) );
121 // The cached data is associated with the encoding. 121 // The cached data is associated with the encoding.
122 ResourceRequest request(url()); 122 ResourceRequest request(url());
123 OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create( request, "UTF-16"); 123 ResourcePtr<ScriptResource> anotherResource = new ScriptResource(request, "U TF-16");
124 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(anotherResourc e->cacheHandler()))); 124 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(anotherResourc e->cacheHandler())));
125 } 125 }
126 126
127 TEST_F(V8ScriptRunnerTest, parseOption) 127 TEST_F(V8ScriptRunnerTest, parseOption)
128 { 128 {
129 setResource(); 129 setResource();
130 EXPECT_TRUE(compileScript(V8CacheOptionsParse)); 130 EXPECT_TRUE(compileScript(V8CacheOptionsParse));
131 EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler()) )); 131 EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler()) ));
132 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())) ); 132 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())) );
133 // The cached data is associated with the encoding. 133 // The cached data is associated with the encoding.
134 ResourceRequest request(url()); 134 ResourceRequest request(url());
135 OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create( request, "UTF-16"); 135 ResourcePtr<ScriptResource> anotherResource = new ScriptResource(request, "U TF-16");
136 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(anotherResourc e->cacheHandler()))); 136 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(anotherResourc e->cacheHandler())));
137 } 137 }
138 138
139 TEST_F(V8ScriptRunnerTest, codeOption) 139 TEST_F(V8ScriptRunnerTest, codeOption)
140 { 140 {
141 setResource(); 141 setResource();
142 EXPECT_TRUE(compileScript(V8CacheOptionsCode)); 142 EXPECT_TRUE(compileScript(V8CacheOptionsCode));
143 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler() ))); 143 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler() )));
144 EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler()))) ; 144 EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler()))) ;
145 // The cached data is associated with the encoding. 145 // The cached data is associated with the encoding.
146 ResourceRequest request(url()); 146 ResourceRequest request(url());
147 OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create( request, "UTF-16"); 147 ResourcePtr<ScriptResource> anotherResource = new ScriptResource(request, "U TF-16");
148 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(anotherResource- >cacheHandler()))); 148 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(anotherResource- >cacheHandler())));
149 } 149 }
150 150
151 TEST_F(V8ScriptRunnerTest, codeCompressedOptions) 151 TEST_F(V8ScriptRunnerTest, codeCompressedOptions)
152 { 152 {
153 setResource(); 153 setResource();
154 EXPECT_TRUE(compileScript(V8CacheOptionsCodeCompressed)); 154 EXPECT_TRUE(compileScript(V8CacheOptionsCodeCompressed));
155 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler() ))); 155 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler() )));
156 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())) ); 156 EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())) );
157 } 157 }
158 158
159 } // namespace 159 } // namespace
160 160
161 } // namespace blink 161 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptStreamerTest.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698