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

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: 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
« no previous file with comments | « Source/modules/presentation/PresentationAvailability.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/modules/presentation/PresentationAvailability.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698