OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/presentation/PresentationAvailability.h" | 5 #include "modules/presentation/PresentationAvailability.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/page/Page.h" | 10 #include "core/page/Page.h" |
11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
12 #include "platform/testing/URLTestHelpers.h" | 12 #include "platform/testing/URLTestHelpers.h" |
13 #include "platform/weborigin/KURL.h" | 13 #include "platform/weborigin/KURL.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include <v8.h> | 15 #include <v8.h> |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 namespace { | 18 namespace { |
19 | 19 |
20 class PresentationAvailabilityTest : public ::testing::Test { | 20 class PresentationAvailabilityTest : public ::testing::Test { |
21 public: | 21 public: |
22 PresentationAvailabilityTest() | 22 PresentationAvailabilityTest() |
23 : m_scope(v8::Isolate::GetCurrent()) | 23 : m_scope(v8::Isolate::GetCurrent()) |
24 , m_page(DummyPageHolder::create()) | 24 , m_page(DummyPageHolder::create()) |
25 { | 25 { |
26 } | 26 } |
27 | 27 |
28 void SetUp() override | 28 void SetUp() override |
29 { | 29 { |
30 m_scope.scriptState()->setExecutionContext(&m_page->document()); | 30 m_scope.getScriptState()->setExecutionContext(&m_page->document()); |
31 } | 31 } |
32 | 32 |
33 Page& page() { return m_page->page(); } | 33 Page& page() { return m_page->page(); } |
34 LocalFrame& frame() { return m_page->frame(); } | 34 LocalFrame& frame() { return m_page->frame(); } |
35 ScriptState* scriptState() { return m_scope.scriptState(); } | 35 ScriptState* getScriptState() { return m_scope.getScriptState(); } |
36 | 36 |
37 private: | 37 private: |
38 V8TestingScope m_scope; | 38 V8TestingScope m_scope; |
39 OwnPtr<DummyPageHolder> m_page; | 39 OwnPtr<DummyPageHolder> m_page; |
40 }; | 40 }; |
41 | 41 |
42 TEST_F(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach) | 42 TEST_F(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach) |
43 { | 43 { |
44 const KURL url = URLTestHelpers::toKURL("https://example.com"); | 44 const KURL url = URLTestHelpers::toKURL("https://example.com"); |
45 Persistent<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(s
criptState()); | 45 Persistent<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(g
etScriptState()); |
46 Persistent<PresentationAvailability> availability = PresentationAvailability
::take(resolver, url, false); | 46 Persistent<PresentationAvailability> availability = PresentationAvailability
::take(resolver, url, false); |
47 | 47 |
48 // These two calls should not crash. | 48 // These two calls should not crash. |
49 frame().detach(FrameDetachType::Remove); | 49 frame().detach(FrameDetachType::Remove); |
50 page().setVisibilityState(PageVisibilityStateHidden, false); | 50 page().setVisibilityState(PageVisibilityStateHidden, false); |
51 } | 51 } |
52 | 52 |
53 } // anonymous namespace | 53 } // anonymous namespace |
54 } // namespace blink | 54 } // namespace blink |
OLD | NEW |