| 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..22824a96b9b225fc81885e9e03a2dfb6549d719b 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>
|
| @@ -17,7 +18,7 @@ namespace {
|
|
|
| class V8ScriptRunnerTest : public ::testing::Test {
|
| public:
|
| - V8ScriptRunnerTest() : m_scope(v8::Isolate::GetCurrent()) { }
|
| + V8ScriptRunnerTest() : m_cacheHandler(nullptr), m_scope(v8::Isolate::GetCurrent()) { }
|
| virtual ~V8ScriptRunnerTest() { }
|
|
|
| virtual void SetUp() override
|
| @@ -30,6 +31,7 @@ public:
|
| virtual void TearDown() override
|
| {
|
| m_resourceRequest.clear();
|
| + m_cacheHandler = nullptr;
|
| m_resource.clear();
|
| }
|
|
|
| @@ -52,20 +54,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, nullptr, NotSharableCrossOrigin, cacheOptions)
|
| .IsEmpty();
|
| }
|
|
|
| @@ -73,17 +75,20 @@ public:
|
| {
|
| m_resourceRequest = WTF::adoptPtr(new ResourceRequest);
|
| m_resource = ScriptResource::create(*m_resourceRequest.get(), "UTF-8");
|
| + m_cacheHandler = m_resource->cacheHandler();
|
| }
|
|
|
| void setResource()
|
| {
|
| m_resourceRequest = WTF::adoptPtr(new ResourceRequest(url()));
|
| m_resource = ScriptResource::create(*m_resourceRequest.get(), "UTF-8");
|
| + m_cacheHandler = m_resource->cacheHandler();
|
| }
|
|
|
| protected:
|
| WTF::OwnPtr<ResourceRequest> m_resourceRequest;
|
| OwnPtrWillBePersistent<ScriptResource> m_resource;
|
| + CachedMetadataHandler* m_cacheHandler;
|
| V8TestingScope m_scope;
|
|
|
| static int counter;
|
| @@ -99,64 +104,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(m_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(m_cacheHandler->cachedMetadata(tagForParserCache(m_cacheHandler)));
|
| + EXPECT_FALSE(m_cacheHandler->cachedMetadata(tagForCodeCache(m_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(m_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(m_cacheHandler->cachedMetadata(tagForParserCache(m_cacheHandler)));
|
| + EXPECT_FALSE(m_cacheHandler->cachedMetadata(tagForCodeCache(m_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(m_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(m_cacheHandler->cachedMetadata(tagForParserCache(m_cacheHandler)));
|
| + EXPECT_TRUE(m_cacheHandler->cachedMetadata(tagForCodeCache(m_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(m_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(m_cacheHandler->cachedMetadata(tagForParserCache(m_cacheHandler)));
|
| + EXPECT_FALSE(m_cacheHandler->cachedMetadata(tagForCodeCache(m_cacheHandler)));
|
| }
|
|
|
| } // namespace
|
|
|