@Override
 protected void setUp() throws Exception {
   super.setUp();
   AwContents.setShouldDownloadFavicons();
   mContentsClient = new TestAwContentsClient();
   AwTestContainerView testContainerView = createAwTestContainerViewOnMainSync(mContentsClient);
   mAwContents = testContainerView.getAwContents();
   mWebServer = TestWebServer.start();
 }
Пример #2
0
 @Override
 public void setUp() throws Exception {
   super.setUp();
   mContentsClient = new TestAwContentsClient();
   mTestView = createAwTestContainerViewOnMainSync(mContentsClient);
   mAwContents = mTestView.getAwContents();
   mWebServer = TestWebServer.start();
   final String imagePath = "/" + CommonResources.TEST_IMAGE_FILENAME;
   mWebServer.setResponseBase64(
       imagePath, CommonResources.FAVICON_DATA_BASE64, CommonResources.getImagePngHeaders(true));
 }
  @Override
  public void setUp() throws Exception {
    super.setUp();
    mContentsClient = new TestAwContentsClient();
    mTestView = createAwTestContainerViewOnMainSync(mContentsClient);
    mAwContents = mTestView.getAwContents();
    mWebServer = TestWebServer.start();
    mOrigin = mWebServer.getBaseUrl();

    AwSettings settings = getAwSettingsOnUiThread(mAwContents);
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setAppCacheEnabled(true);
    settings.setAppCachePath("whatever"); // Enables AppCache.
  }
Пример #4
0
  @DisabledTest // Fails on android-one: crbug.com/540723
  @MediumTest
  @Feature({"Navigation"})
  public void testWindowOpenUrlSpoof() throws Exception {
    TestWebServer webServer = TestWebServer.start();
    try {
      // Make sure that we start with one tab.
      final TabModel model = getActivity().getTabModelSelector().getModel(false);

      final Semaphore urlServedSemaphore = new Semaphore(0);
      Runnable checkAction =
          new Runnable() {
            @Override
            public void run() {
              final Tab tab = TabModelUtils.getCurrentTab(model);

              // Make sure that we are showing the spoofed data and a blank URL.
              String url = getTabUrlOnUIThread(tab);
              boolean spoofedUrl = "".equals(url) || "about:blank".equals(url);
              assertTrue("URL Spoofed", spoofedUrl);
              assertEquals("Not showing mocked content", "\"Spoofed\"", getTabBodyText(tab));
              urlServedSemaphore.release();
            }
          };

      // Mock out the test URL
      final String mockedUrl =
          webServer.setResponseWithRunnableAction(
              "/mockme.html",
              "<html>"
                  + "  <head>"
                  + "    <meta name=\"viewport\""
                  + "        content=\"initial-scale=0.75,maximum-scale=0.75,user-scalable=no\">"
                  + "  </head>"
                  + "  <body>Real</body>"
                  + "</html>",
              null,
              checkAction);

      // Navigate to the spoofable URL
      loadUrl(
          UrlUtils.encodeHtmlDataUri(
              "<head>"
                  + "  <meta name=\"viewport\""
                  + "      content=\"initial-scale=0.5,maximum-scale=0.5,user-scalable=no\">"
                  + "</head>"
                  + "<script>"
                  + "  function spoof() {"
                  + "    var w = open();"
                  + "    w.opener = null;"
                  + "    w.document.write('Spoofed');"
                  + "    w.location = '"
                  + mockedUrl
                  + "'"
                  + "  }"
                  + "</script>"
                  + "<body id='body' onclick='spoof()'></body>"));
      assertWaitForPageScaleFactorMatch(0.5f);

      // Click the page, which triggers the URL load.
      DOMUtils.clickNode(this, getActivity().getCurrentContentViewCore(), "body");

      // Wait for the proper URL to be served.
      assertTrue(urlServedSemaphore.tryAcquire(5, TimeUnit.SECONDS));

      // Wait for the url to change.
      final Tab tab = TabModelUtils.getCurrentTab(model);
      assertWaitForPageScaleFactorMatch(0.75f);
      CriteriaHelper.pollForCriteria(
          new Criteria("Page url didn't change") {
            @Override
            public boolean isSatisfied() {
              return mockedUrl.equals(getTabUrlOnUIThread(tab));
            }
          },
          5000,
          50);

      // Make sure that we're showing new content now.
      assertEquals("Still showing spoofed data", "\"Real\"", getTabBodyText(tab));
    } finally {
      webServer.shutdown();
    }
  }
 @Override
 public void setUp() throws Exception {
   super.setUp();
   mWebServer = TestWebServer.start();
 }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   mWebServer = TestWebServer.start();
 }