Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(821)

Side by Side Diff: Source/modules/presentation/PresentationAvailabilityTest.cpp

Issue 1322493006: Presentation API: ignore page visibility changes if ExecutionContext is destoyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: forgot file Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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");
46 Persistent<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(s criptState());
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698