Index: chrome/android/javatests/src/org/chromium/chrome/browser/permissions/PermissionFrameTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/PermissionFrameTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/PermissionFrameTest.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d100b0b93590c81caee33bde2260548f133f4c39 |
--- /dev/null |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/permissions/PermissionFrameTest.java |
@@ -0,0 +1,65 @@ |
+// 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. |
+ |
+package org.chromium.chrome.browser.permissions; |
+ |
+import android.support.test.filters.MediumTest; |
+ |
+import org.chromium.base.test.util.CallbackHelper; |
+import org.chromium.base.test.util.CommandLineFlags; |
+import org.chromium.base.test.util.Feature; |
+import org.chromium.base.test.util.RetryOnFailure; |
+import org.chromium.chrome.browser.tab.EmptyTabObserver; |
+import org.chromium.chrome.browser.tab.Tab; |
+ |
+/** |
+ * Test suite for permission requests in frames. |
+ */ |
+@RetryOnFailure |
+public class PermissionFrameTest extends PermissionTestCaseBase { |
+ private static final String TEST_FILE = "/content/test/data/android/permission_frame_test.html"; |
+ |
+ public PermissionFrameTest() {} |
+ |
+ /** |
+ * Check that permission prompts from iframes work as expected upon navigation. The loaded page |
+ * starts by prompting for geolocation in an iframe. When the frame navigates, the infobar |
+ * remains visible although accept/block actions are ignored. A subsequent geolocation request |
+ * from the main frame should still create an infobar and be able to be resolved successfully. |
+ * |
+ * @throws Exception |
+ */ |
+ @MediumTest |
+ @Feature({"Permissions"}) |
+ @CommandLineFlags.Add({"enable-features=" + PERMISSION_REQUEST_MANAGER_FLAG}) |
+ public void testPermissionInIframeWhichNavigates() throws Exception { |
+ setUpUrl(TEST_FILE); |
+ waitForInfoBar(); |
+ |
+ Tab tab = getActivity().getActivityTab(); |
+ final CallbackHelper callbackHelper = new CallbackHelper(); |
+ EmptyTabObserver navigationWaiter = new EmptyTabObserver() { |
+ @Override |
+ public void onDidFinishNavigation(Tab tab, String url, boolean isInMainFrame, |
+ boolean isErrorPage, boolean hasCommitted, boolean isSameDocument, |
+ boolean isFragmentNavigation, Integer pageTransition, int errorCode, |
+ int httpStatusCode) { |
+ callbackHelper.notifyCalled(); |
+ } |
+ }; |
+ tab.addObserver(navigationWaiter); |
+ runJavaScriptCodeInCurrentTab("navigateIFrame()"); |
+ callbackHelper.waitForCallback(0); |
+ tab.removeObserver(navigationWaiter); |
+ |
+ replyToInfoBar(true, false, false); |
+ checkPermissionStatus("geolocation", "prompt"); |
+ |
+ runJavaScriptCodeInCurrentTab("requestGeolocation()"); |
+ waitForInfoBar(); |
+ replyToInfoBar(true, false, false); |
+ |
+ checkPermissionStatus("geolocation", "granted"); |
+ } |
+} |