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

Unified 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 side-by-side diff with in-line comments
Download patch
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..7f56c1015800e93b9c443480c0e5a168d7f605f9
--- /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");
+ Persistent<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState());
+ 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

Powered by Google App Engine
This is Rietveld 408576698