| 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 "modules/fetch/Request.h" | 5 #include "modules/fetch/Request.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/Frame.h" | 10 #include "core/frame/Frame.h" |
| 11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
| 12 #include "public/platform/WebURLRequest.h" | 12 #include "public/platform/WebURLRequest.h" |
| 13 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" | 13 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "wtf/HashMap.h" | 15 #include "wtf/HashMap.h" |
| 16 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
| 17 #include <memory> |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class ServiceWorkerRequestTest : public ::testing::Test { | 22 class ServiceWorkerRequestTest : public ::testing::Test { |
| 22 public: | 23 public: |
| 23 ServiceWorkerRequestTest() | 24 ServiceWorkerRequestTest() |
| 24 : m_page(DummyPageHolder::create(IntSize(1, 1))) { } | 25 : m_page(DummyPageHolder::create(IntSize(1, 1))) { } |
| 25 | 26 |
| 26 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } | 27 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } |
| 27 ExecutionContext* getExecutionContext() { return getScriptState()->getExecut
ionContext(); } | 28 ExecutionContext* getExecutionContext() { return getScriptState()->getExecut
ionContext(); } |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 OwnPtr<DummyPageHolder> m_page; | 31 std::unique_ptr<DummyPageHolder> m_page; |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 TEST_F(ServiceWorkerRequestTest, FromString) | 34 TEST_F(ServiceWorkerRequestTest, FromString) |
| 34 { | 35 { |
| 35 TrackExceptionState exceptionState; | 36 TrackExceptionState exceptionState; |
| 36 | 37 |
| 37 KURL url(ParsedURLString, "http://www.example.com/"); | 38 KURL url(ParsedURLString, "http://www.example.com/"); |
| 38 Request* request = Request::create(getScriptState(), url, exceptionState); | 39 Request* request = Request::create(getScriptState(), url, exceptionState); |
| 39 ASSERT_FALSE(exceptionState.hadException()); | 40 ASSERT_FALSE(exceptionState.hadException()); |
| 40 ASSERT(request); | 41 ASSERT(request); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 Request* request = Request::create(getScriptState(), url, exceptionState); | 118 Request* request = Request::create(getScriptState(), url, exceptionState); |
| 118 ASSERT(request); | 119 ASSERT(request); |
| 119 | 120 |
| 120 WebServiceWorkerRequest webRequest; | 121 WebServiceWorkerRequest webRequest; |
| 121 request->populateWebServiceWorkerRequest(webRequest); | 122 request->populateWebServiceWorkerRequest(webRequest); |
| 122 EXPECT_EQ(urlWithoutFragment, KURL(webRequest.url())); | 123 EXPECT_EQ(urlWithoutFragment, KURL(webRequest.url())); |
| 123 } | 124 } |
| 124 | 125 |
| 125 } // namespace | 126 } // namespace |
| 126 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |