Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "modules/presentation/PresentationAvailability.h" | |
| 7 | |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 9 #include "bindings/core/v8/V8BindingForTesting.h" | |
| 10 #include "core/frame/LocalFrame.h" | |
| 11 #include "core/page/Page.h" | |
| 12 #include "core/testing/DummyPageHolder.h" | |
| 13 #include "platform/testing/URLTestHelpers.h" | |
| 14 #include "platform/weborigin/KURL.h" | |
| 15 #include <gtest/gtest.h> | |
| 16 #include <v8.h> | |
| 17 | |
| 18 namespace blink { | |
| 19 namespace { | |
| 20 | |
| 21 class PresentationAvailabilityTest : public ::testing::Test { | |
| 22 public: | |
| 23 PresentationAvailabilityTest() | |
| 24 : m_scope(v8::Isolate::GetCurrent()) | |
| 25 , m_page(DummyPageHolder::create()) | |
| 26 { | |
| 27 } | |
| 28 | |
| 29 void SetUp() override | |
| 30 { | |
| 31 m_scope.scriptState()->setExecutionContext(&m_page->document()); | |
| 32 } | |
| 33 | |
| 34 Page& page() { return m_page->page(); } | |
| 35 LocalFrame& frame() { return m_page->frame(); } | |
| 36 ScriptState* scriptState() { return m_scope.scriptState(); } | |
| 37 | |
| 38 private: | |
| 39 V8TestingScope m_scope; | |
| 40 OwnPtr<DummyPageHolder> m_page; | |
| 41 }; | |
| 42 | |
| 43 TEST_F(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach) | |
| 44 { | |
| 45 const KURL url = URLTestHelpers::toKURL("https://example.com"); | |
|
whywhat
2015/09/07 15:51:46
nit: could be a const reference?
mlamouri (slow - plz ping)
2015/09/07 16:28:37
I don't think so, toKURL() returns a new KURL obje
| |
| 46 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState( )); | |
|
whywhat
2015/09/07 15:51:46
is it destroyed in take() when resolved?
mlamouri (slow - plz ping)
2015/09/07 16:28:37
I think it is GC'd. I've added Persistent<> to mak
| |
| 47 Persistent<PresentationAvailability> availability = PresentationAvailability ::take(resolver, url, false); | |
| 48 | |
| 49 // These two calls should not crash. | |
| 50 frame().detach(FrameDetachType::Remove); | |
| 51 page().setVisibilityState(PageVisibilityStateHidden, false); | |
| 52 } | |
| 53 | |
| 54 } // anonymous namespace | |
| 55 } // namespace blink | |
| OLD | NEW |