| Index: Source/bindings/core/v8/V8ScriptRunnerTest.cpp
|
| diff --git a/Source/bindings/core/v8/V8ScriptRunnerTest.cpp b/Source/bindings/core/v8/V8ScriptRunnerTest.cpp
|
| index cce830cdf3e7e459fc0efa415e924fae546b36c3..1ffe4f5d02bb4136e40bff7fef3c54aea30e772c 100644
|
| --- a/Source/bindings/core/v8/V8ScriptRunnerTest.cpp
|
| +++ b/Source/bindings/core/v8/V8ScriptRunnerTest.cpp
|
| @@ -6,6 +6,7 @@
|
| #include "bindings/core/v8/V8ScriptRunner.h"
|
|
|
| #include "bindings/core/v8/V8Binding.h"
|
| +#include "core/fetch/CachedMetadataHandler.h"
|
| #include "core/fetch/ScriptResource.h"
|
| #include "platform/heap/Handle.h"
|
| #include <gtest/gtest.h>
|
| @@ -52,20 +53,20 @@ public:
|
| {
|
| return WTF::String::format("http://bla.com/bla%d", counter);
|
| }
|
| - unsigned tagForParserCache(Resource* resource) const
|
| + unsigned tagForParserCache(CachedMetadataHandler* cacheHandler) const
|
| {
|
| - return V8ScriptRunner::tagForParserCache(resource);
|
| + return V8ScriptRunner::tagForParserCache(cacheHandler);
|
| }
|
| - unsigned tagForCodeCache(Resource* resource) const
|
| + unsigned tagForCodeCache(CachedMetadataHandler* cacheHandler) const
|
| {
|
| - return V8ScriptRunner::tagForCodeCache(resource);
|
| + return V8ScriptRunner::tagForCodeCache(cacheHandler);
|
| }
|
|
|
| bool compileScript(V8CacheOptions cacheOptions)
|
| {
|
| return !V8ScriptRunner::compileScript(
|
| v8String(isolate(), code()), filename(), WTF::TextPosition(),
|
| - m_resource.get(), 0, isolate(), NotSharableCrossOrigin, cacheOptions)
|
| + isolate(), m_resource.get(), nullptr, m_resource.get() ? m_resource->cacheHandler(): nullptr, NotSharableCrossOrigin, cacheOptions)
|
| .IsEmpty();
|
| }
|
|
|
| @@ -81,6 +82,11 @@ public:
|
| m_resource = ScriptResource::create(*m_resourceRequest.get(), "UTF-8");
|
| }
|
|
|
| + CachedMetadataHandler* cacheHandler()
|
| + {
|
| + return m_resource->cacheHandler();
|
| + }
|
| +
|
| protected:
|
| WTF::OwnPtr<ResourceRequest> m_resourceRequest;
|
| OwnPtrWillBePersistent<ScriptResource> m_resource;
|
| @@ -99,64 +105,54 @@ TEST_F(V8ScriptRunnerTest, resourcelessShouldPass)
|
| EXPECT_TRUE(compileScript(V8CacheOptionsCode));
|
| }
|
|
|
| -TEST_F(V8ScriptRunnerTest, emptyResourceDoesNothing)
|
| +TEST_F(V8ScriptRunnerTest, emptyResourceDoesNotHaveCacheHandler)
|
| {
|
| setEmptyResource();
|
| - EXPECT_TRUE(compileScript(V8CacheOptionsDefault));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get())));
|
| -
|
| - EXPECT_TRUE(compileScript(V8CacheOptionsParse));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get())));
|
| -
|
| - EXPECT_TRUE(compileScript(V8CacheOptionsCode));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get())));
|
| + EXPECT_FALSE(cacheHandler());
|
| }
|
|
|
| TEST_F(V8ScriptRunnerTest, parseMemoryOption)
|
| {
|
| setResource();
|
| EXPECT_TRUE(compileScript(V8CacheOptionsParseMemory));
|
| - EXPECT_TRUE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get())));
|
| + EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())));
|
| // The cached data is associated with the encoding.
|
| ResourceRequest request(url());
|
| OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create(request, "UTF-16");
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(anotherResource.get())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(anotherResource->cacheHandler())));
|
| }
|
|
|
| TEST_F(V8ScriptRunnerTest, parseOption)
|
| {
|
| setResource();
|
| EXPECT_TRUE(compileScript(V8CacheOptionsParse));
|
| - EXPECT_TRUE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get())));
|
| + EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())));
|
| // The cached data is associated with the encoding.
|
| ResourceRequest request(url());
|
| OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create(request, "UTF-16");
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(anotherResource.get())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(anotherResource->cacheHandler())));
|
| }
|
|
|
| TEST_F(V8ScriptRunnerTest, codeOption)
|
| {
|
| setResource();
|
| EXPECT_TRUE(compileScript(V8CacheOptionsCode));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())));
|
| - EXPECT_TRUE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler())));
|
| + EXPECT_TRUE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())));
|
| // The cached data is associated with the encoding.
|
| ResourceRequest request(url());
|
| OwnPtrWillBeRawPtr<ScriptResource> anotherResource = ScriptResource::create(request, "UTF-16");
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(anotherResource.get())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(anotherResource->cacheHandler())));
|
| }
|
|
|
| TEST_F(V8ScriptRunnerTest, codeCompressedOptions)
|
| {
|
| setResource();
|
| EXPECT_TRUE(compileScript(V8CacheOptionsCodeCompressed));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache(m_resource.get())));
|
| - EXPECT_FALSE(m_resource->cachedMetadata(tagForCodeCache(m_resource.get())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForParserCache(cacheHandler())));
|
| + EXPECT_FALSE(cacheHandler()->cachedMetadata(tagForCodeCache(cacheHandler())));
|
| }
|
|
|
| } // namespace
|
|
|