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/dom/DOMException.h" |
9 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
10 #include "core/page/Page.h" | 11 #include "core/page/Page.h" |
11 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" |
| 13 #include "modules/presentation/PresentationRequest.h" |
12 #include "platform/testing/URLTestHelpers.h" | 14 #include "platform/testing/URLTestHelpers.h" |
13 #include "platform/weborigin/KURL.h" | 15 #include "platform/weborigin/KURL.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
15 #include <v8.h> | 17 #include <v8.h> |
16 | 18 |
17 namespace blink { | 19 namespace blink { |
18 namespace { | 20 namespace { |
19 | 21 |
20 TEST(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach) { | 22 TEST(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach) { |
21 V8TestingScope scope; | 23 V8TestingScope scope; |
22 const KURL url = URLTestHelpers::toKURL("https://example.com"); | 24 const KURL url = URLTestHelpers::toKURL("https://example.com"); |
23 Persistent<ScriptPromiseResolver> resolver = | 25 Persistent<PresentationAvailabilityProperty> resolver = |
24 ScriptPromiseResolver::create(scope.getScriptState()); | 26 new PresentationAvailabilityProperty( |
| 27 scope.getExecutionContext(), nullptr, |
| 28 PresentationAvailabilityProperty::Ready); |
25 Persistent<PresentationAvailability> availability = | 29 Persistent<PresentationAvailability> availability = |
26 PresentationAvailability::take(resolver, url, false); | 30 PresentationAvailability::take(resolver, url, false); |
27 | 31 |
28 // These two calls should not crash. | 32 // These two calls should not crash. |
29 scope.frame().detach(FrameDetachType::Remove); | 33 scope.frame().detach(FrameDetachType::Remove); |
30 scope.page().setVisibilityState(PageVisibilityStateHidden, false); | 34 scope.page().setVisibilityState(PageVisibilityStateHidden, false); |
31 } | 35 } |
32 | 36 |
33 } // anonymous namespace | 37 } // anonymous namespace |
34 } // namespace blink | 38 } // namespace blink |
OLD | NEW |