@MediumTest
  @Feature({"AndroidWebView", "Privacy"})
  public void testThirdPartyJavascriptCookie() throws Throwable {
    TestWebServer webServer = null;
    try {
      // This test again uses 127.0.0.1/localhost trick to simulate a third party.
      webServer = new TestWebServer(false);
      ThirdPartyCookiesTestHelper thirdParty = new ThirdPartyCookiesTestHelper(webServer);

      mCookieManager.setAcceptCookie(true);
      assertTrue(mCookieManager.acceptCookie());

      // When third party cookies are disabled...
      thirdParty.getSettings().setAcceptThirdPartyCookies(false);
      assertFalse(thirdParty.getSettings().getAcceptThirdPartyCookies());

      // ...we can't set third party cookies.
      thirdParty.assertThirdPartyIFrameCookieResult("1", false);

      // When third party cookies are enabled...
      thirdParty.getSettings().setAcceptThirdPartyCookies(true);
      assertTrue(thirdParty.getSettings().getAcceptThirdPartyCookies());

      // ...we can set third party cookies.
      thirdParty.assertThirdPartyIFrameCookieResult("2", true);
    } finally {
      if (webServer != null) webServer.shutdown();
    }
  }
  @MediumTest
  @Feature({"AndroidWebView", "Privacy"})
  public void testThirdPartyCookiesArePerWebview() throws Throwable {
    TestWebServer webServer = null;
    try {
      webServer = new TestWebServer(false);
      mCookieManager.setAcceptCookie(true);
      mCookieManager.removeAllCookie();
      assertTrue(mCookieManager.acceptCookie());
      assertFalse(mCookieManager.hasCookies());

      ThirdPartyCookiesTestHelper helperOne = new ThirdPartyCookiesTestHelper(webServer);
      ThirdPartyCookiesTestHelper helperTwo = new ThirdPartyCookiesTestHelper(webServer);

      helperOne.getSettings().setAcceptThirdPartyCookies(false);
      helperTwo.getSettings().setAcceptThirdPartyCookies(false);
      assertFalse(helperOne.getSettings().getAcceptThirdPartyCookies());
      assertFalse(helperTwo.getSettings().getAcceptThirdPartyCookies());
      helperOne.assertThirdPartyIFrameCookieResult("1", false);
      helperTwo.assertThirdPartyIFrameCookieResult("2", false);

      helperTwo.getSettings().setAcceptThirdPartyCookies(true);
      assertFalse(helperOne.getSettings().getAcceptThirdPartyCookies());
      assertTrue(helperTwo.getSettings().getAcceptThirdPartyCookies());
      helperOne.assertThirdPartyIFrameCookieResult("3", false);
      helperTwo.assertThirdPartyIFrameCookieResult("4", true);

      helperOne.getSettings().setAcceptThirdPartyCookies(true);
      assertTrue(helperOne.getSettings().getAcceptThirdPartyCookies());
      assertTrue(helperTwo.getSettings().getAcceptThirdPartyCookies());
      helperOne.assertThirdPartyIFrameCookieResult("5", true);
      helperTwo.assertThirdPartyIFrameCookieResult("6", true);

      helperTwo.getSettings().setAcceptThirdPartyCookies(false);
      assertTrue(helperOne.getSettings().getAcceptThirdPartyCookies());
      assertFalse(helperTwo.getSettings().getAcceptThirdPartyCookies());
      helperOne.assertThirdPartyIFrameCookieResult("7", true);
      helperTwo.assertThirdPartyIFrameCookieResult("8", false);
    } finally {
      if (webServer != null) webServer.shutdown();
    }
  }