OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 package org.chromium.chrome.browser.permissions; |
| 6 |
| 7 import android.support.test.filters.MediumTest; |
| 8 |
| 9 import org.chromium.base.test.util.CallbackHelper; |
| 10 import org.chromium.base.test.util.CommandLineFlags; |
| 11 import org.chromium.base.test.util.Feature; |
| 12 import org.chromium.base.test.util.RetryOnFailure; |
| 13 import org.chromium.chrome.browser.tab.EmptyTabObserver; |
| 14 import org.chromium.chrome.browser.tab.Tab; |
| 15 |
| 16 /** |
| 17 * Test suite for permission requests in frames. |
| 18 */ |
| 19 @RetryOnFailure |
| 20 public class PermissionFrameTest extends PermissionTestCaseBase { |
| 21 private static final String TEST_FILE = "/content/test/data/android/permissi
on_frame_test.html"; |
| 22 |
| 23 public PermissionFrameTest() {} |
| 24 |
| 25 /** |
| 26 * Check that permission prompts from iframes work as expected upon navigati
on. The loaded page |
| 27 * starts by prompting for geolocation in an iframe. When the frame navigate
s, the infobar |
| 28 * remains visible although accept/block actions are ignored. A subsequent g
eolocation request |
| 29 * from the main frame should still create an infobar and be able to be reso
lved successfully. |
| 30 * |
| 31 * @throws Exception |
| 32 */ |
| 33 @MediumTest |
| 34 @Feature({"Permissions"}) |
| 35 @CommandLineFlags.Add({"enable-features=" + PERMISSION_REQUEST_MANAGER_FLAG}
) |
| 36 public void testPermissionInIframeWhichNavigates() throws Exception { |
| 37 setUpUrl(TEST_FILE); |
| 38 waitForInfoBar(); |
| 39 |
| 40 Tab tab = getActivity().getActivityTab(); |
| 41 final CallbackHelper callbackHelper = new CallbackHelper(); |
| 42 EmptyTabObserver navigationWaiter = new EmptyTabObserver() { |
| 43 @Override |
| 44 public void onDidFinishNavigation(Tab tab, String url, boolean isInM
ainFrame, |
| 45 boolean isErrorPage, boolean hasCommitted, boolean isSameDoc
ument, |
| 46 boolean isFragmentNavigation, Integer pageTransition, int er
rorCode, |
| 47 int httpStatusCode) { |
| 48 callbackHelper.notifyCalled(); |
| 49 } |
| 50 }; |
| 51 tab.addObserver(navigationWaiter); |
| 52 runJavaScriptCodeInCurrentTab("navigateIFrame()"); |
| 53 callbackHelper.waitForCallback(0); |
| 54 tab.removeObserver(navigationWaiter); |
| 55 |
| 56 replyToInfoBar(true, false, false); |
| 57 checkPermissionStatus("geolocation", "prompt"); |
| 58 |
| 59 runJavaScriptCodeInCurrentTab("requestGeolocation()"); |
| 60 waitForInfoBar(); |
| 61 replyToInfoBar(true, false, false); |
| 62 |
| 63 checkPermissionStatus("geolocation", "granted"); |
| 64 } |
| 65 } |
OLD | NEW |