Chromium Code Reviews| Index: Source/modules/presentation/PresentationAvailabilityTest.cpp |
| diff --git a/Source/modules/presentation/PresentationAvailabilityTest.cpp b/Source/modules/presentation/PresentationAvailabilityTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..47d5a707e0926b2d103052676000c907b987de8a |
| --- /dev/null |
| +++ b/Source/modules/presentation/PresentationAvailabilityTest.cpp |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "modules/presentation/PresentationAvailability.h" |
| + |
| +#include "bindings/core/v8/ScriptPromiseResolver.h" |
| +#include "bindings/core/v8/V8BindingForTesting.h" |
| +#include "core/frame/LocalFrame.h" |
| +#include "core/page/Page.h" |
| +#include "core/testing/DummyPageHolder.h" |
| +#include "platform/testing/URLTestHelpers.h" |
| +#include "platform/weborigin/KURL.h" |
| +#include <gtest/gtest.h> |
| +#include <v8.h> |
| + |
| +namespace blink { |
| +namespace { |
| + |
| +class PresentationAvailabilityTest : public ::testing::Test { |
| +public: |
| + PresentationAvailabilityTest() |
| + : m_scope(v8::Isolate::GetCurrent()) |
| + , m_page(DummyPageHolder::create()) |
| + { |
| + } |
| + |
| + void SetUp() override |
| + { |
| + m_scope.scriptState()->setExecutionContext(&m_page->document()); |
| + } |
| + |
| + Page& page() { return m_page->page(); } |
| + LocalFrame& frame() { return m_page->frame(); } |
| + ScriptState* scriptState() { return m_scope.scriptState(); } |
| + |
| +private: |
| + V8TestingScope m_scope; |
| + OwnPtr<DummyPageHolder> m_page; |
| +}; |
| + |
| +TEST_F(PresentationAvailabilityTest, NoPageVisibilityChangeAfterDetach) |
| +{ |
| + 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
|
| + 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
|
| + Persistent<PresentationAvailability> availability = PresentationAvailability::take(resolver, url, false); |
| + |
| + // These two calls should not crash. |
| + frame().detach(FrameDetachType::Remove); |
| + page().setVisibilityState(PageVisibilityStateHidden, false); |
| +} |
| + |
| +} // anonymous namespace |
| +} // namespace blink |