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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/printing/PrintingControllerTest.java

Issue 1338333002: Add checks for android printing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated test. It still is kind of flaky (2/30, the print dialog comes up -> timeout), but no crash Created 5 years, 3 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
Index: chrome/android/javatests/src/org/chromium/chrome/browser/printing/PrintingControllerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/printing/PrintingControllerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/printing/PrintingControllerTest.java
index ba24fcd22e2ff8a68640eef1099eb28ecc69fbd3..fcc396a1605289156e264d141b1db103b634e12a 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/printing/PrintingControllerTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/printing/PrintingControllerTest.java
@@ -13,14 +13,19 @@
import android.print.PrintDocumentAdapter;
import android.print.PrintDocumentInfo;
import android.test.suitebuilder.annotation.LargeTest;
+import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.TestFileUtil;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.chrome.test.util.browser.TabTitleObserver;
+import org.chromium.content.common.ContentSwitches;
import org.chromium.printing.PrintDocumentAdapterWrapper;
import org.chromium.printing.PrintManagerDelegate;
import org.chromium.printing.PrintingControllerImpl;
@@ -150,6 +155,31 @@ public void onLayoutFinished(PrintDocumentInfo info, boolean changed) {
}
+ /**
+ * Test for http://crbug.com/528909
+ */
+ @CommandLineFlags.Add(
+ {ContentSwitches.DISABLE_POPUP_BLOCKING, ChromeSwitches.DISABLE_DOCUMENT_MODE})
+ @SmallTest
+ @Feature({"Printing"})
+ public void testPrintClosedWindow() throws Throwable {
+ String html = "<html><head><title>printwindowclose</title></head><body><script>"
+ + "function printClosedWindow() {"
+ + " w = window.open(); w.close();"
+ + " setTimeout(()=>{w.print(); document.title='completed'}, 0);"
+ + "}</script></body></html>";
+
+ startMainActivityWithURL("data:text/html;charset=utf-8," + html);
+
+ Tab mTab = getActivity().getActivityTab();
+ assertEquals("title does not match initial title", "printwindowclose", mTab.getTitle());
+
+ TabTitleObserver mOnTitleUpdatedHelper = new TabTitleObserver(mTab, "completed");
+ runJavaScriptCodeInCurrentTab("printClosedWindow();");
+ mOnTitleUpdatedHelper.waitForTitleUpdate(2);
+ assertEquals("JS did not finish running", "completed", mTab.getTitle());
+ }
+
private PrintingControllerImpl createControllerOnUiThread() {
try {
final FutureTask<PrintingControllerImpl> task =

Powered by Google App Engine
This is Rietveld 408576698