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

Unified Diff: third_party/WebKit/Source/web/tests/WindowProxyTest.cpp

Issue 2732483004: Reinitialize WindowProxy on navigations. (Closed)
Patch Set: . Created 3 years, 10 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 | « third_party/WebKit/Source/web/BUILD.gn ('k') | third_party/WebKit/Source/web/tests/sim/SimTest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WindowProxyTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WindowProxyTest.cpp b/third_party/WebKit/Source/web/tests/WindowProxyTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c81c9ba8c558cdaf7a26cb35982363cdd9612066
--- /dev/null
+++ b/third_party/WebKit/Source/web/tests/WindowProxyTest.cpp
@@ -0,0 +1,51 @@
+// Copyright 2017 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 "platform/testing/UnitTestHelpers.h"
+#include "web/tests/sim/SimRequest.h"
+#include "web/tests/sim/SimTest.h"
+
+namespace blink {
+
+using WindowProxyTest = SimTest;
+
+// Tests that a WindowProxy is reinitialized after a navigation, even if the new
+// Document does not use any scripting.
+TEST_F(WindowProxyTest, ReinitializedAfterNavigation) {
+ // TODO(dcheng): It's nicer to use TestingPlatformSupportWithMockScheduler,
+ // but that leads to random DCHECKs in loading code.
+
+ SimRequest mainResource("https://example.com/index.html", "text/html");
+ loadURL("https://example.com/index.html");
+ mainResource.complete(
+ "<!DOCTYPE html>"
+ "<html><head><script>"
+ "var childWindow;"
+ "function runTest() {"
+ " childWindow = window[0];"
+ " document.querySelector('iframe').onload = runTest2;"
+ " childWindow.location = 'data:text/plain,Initial.';"
+ "}"
+ "function runTest2() {"
+ " try {"
+ " childWindow.location = 'data:text/plain,Final.';"
+ " console.log('PASSED');"
+ " } catch (e) {"
+ " console.log('FAILED');"
+ " }"
+ " document.querySelector('iframe').onload = null;"
+ "}"
+ "</script></head><body onload='runTest()'>"
+ "<iframe></iframe></body></html>");
+
+ // Wait for the first data: URL to load
+ testing::runPendingTasks();
+
+ // Wait for the second data: URL to load.
+ testing::runPendingTasks();
+
+ ASSERT_GT(consoleMessages().size(), 0U);
+ EXPECT_EQ("PASSED", consoleMessages()[0]);
+}
+}
« no previous file with comments | « third_party/WebKit/Source/web/BUILD.gn ('k') | third_party/WebKit/Source/web/tests/sim/SimTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698