New issue
Advanced search Search tips

Issue 879464 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Sep 7
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 1
Type: Bug



Sign in to add a comment

Print not working in window.open('about:blank', '') page in ios chrome.

Reported by satheesh...@knowledgeq.com, Aug 31

Issue description

Steps to reproduce the problem:
1. Write some content inside the about:blank page using document.write(). Then use the window.print() to print the page.
2. Now run the html file in the ios chrome.

What is the expected behavior?
Now it should print the page.

What went wrong?
Airprint popup not even appearing.

Did this work before? N/A 

Chrome version: 68.0.3440.106  Channel: stable
OS Version: 10.0
Flash Version:
 
index.html
2.0 KB View Download
This issue will only be reproduced in ipad devices. Any ipad will do.
Components: -Blink Internals>Printing Mobile>WebView>Glue
Owner: eugene...@chromium.org
Status: Assigned (was: Unconfirmed)
Eugenebut, do you think we can support this?
function myprint() {
        const wnd = window.open('about:blank', '', '_blank, alwaysRaised=yes');
        wnd.document.write('<html><head><title></title>');
        wnd.document.write('</head><body>');
        wnd.document.write('<div>JavaScript often abbreviated as JS, is a high-level, interpreted programming language.</div>');
        wnd.document.write('</body></html>');
        wnd.focus();
        wnd.print();
}


Print function in the above code is not working in iPad chrome. This is definitely not an iPad setting issue, because the normal web page print works fine. Here I'm trying to add the content in the popup page using window. open () and window. document. write (). The page opened and content appended perfectly. But the print functions not working in the iPad chrome. Only in the iPad chrome. Is this an iPad issue? Or is there any other fix for this.

Also, I found out that, the print function in the iframe is also not working in the iPad chrome.

I have already searched the web, and I don't think anybody talked much about this. I have found a few links, but no fix available for both the issue.
Hi, Is there any update?
Cc: eugene...@chromium.org
Components: -Mobile>WebView>Glue
Labels: -Pri-2 Hotlist-GoodFirstBug Pri-3
Owner: ----
Status: Available (was: Assigned)
window.print only works if JS call is invoked from displayed Tab:
https://cs.chromium.org/chromium/src/ios/chrome/browser/ui/browser_view_controller.mm?type=cs&q=printWebState:&sq=package:chromium&g=0&l=5894

I wonder how does this work in other iOS browsers (Safari, Firefox, Edge)?


Hi,

You said, window.print only works in displayed tab, see the below code.

function myprint() {
        const wnd = window.open('about:blank', '', '_blank, alwaysRaised=yes');
        wnd.document.write('<html><head><title></title>');
        wnd.document.write('</head><body>');
        wnd.document.write('<div>JavaScript often abbreviated as JS, is a high-level, interpreted programming language.</div>');

        wnd.document.write('<button onclick="window.print()"></button>');

        wnd.document.write('</body></html>');
}

This is also not working in the iOS chrome.

Now, how print works in other iOS browsers?

Actually iOS browsers not executes the print commends. Print commends are executed by third party application called "AirPrint". I think AirPrint is not executing the chrome "about:blank" window print. 
Cc: -eugene...@chromium.org
Labels: M-70
Owner: eugene...@chromium.org
Status: Started (was: Available)
The bug described in comment #6 will be fixed in M70 as the root cause affect multiple features.
Labels: -Pri-3 Pri-1
Thanks for the conformation and I hope update M70 will come soon.

And also, I talked about the iframe issue in comment #3, which is also not working in the iOS chrome. Can I get some insight on that issue too.
My apologizes, I missed your question about iframe. Chrome for iOS does not support printing from iframes: https://cs.chromium.org/chromium/src/ios/chrome/browser/web/print_tab_helper.mm?type=cs&q=%22//+Print+is+only+supported+on+main+frame.%22&sq=package:chromium&g=0&l=60

This is not intentional, but rather for historical reasons. However we should be thoughtful with enabling window.print() inside iframes to avoid abusive behavior from web sites. We will track iframes issue here:  crbug.com/881876 


Project Member

Comment 11 by bugdroid1@chromium.org, Sep 7

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2248e7049cd6c56f90d337a1c1582c8d898fb8f9

commit 2248e7049cd6c56f90d337a1c1582c8d898fb8f9
Author: Eugene But <eugenebut@google.com>
Date: Fri Sep 07 18:30:15 2018

Fix respondToWKScriptMessage for windows with opener.

For windows with opener |scriptMessage.frameInfo.securityOrigin| returns
opener's security origin, while document URL can be about:blank.
This change allows all the messages coming from the main frame, which
was the orginal intention of the code.

This CL does not have a test because code that filters cross-origin
messages will be removed anyway.

Bug:  879464 
Change-Id: I15dac35bb3911ad93fc6bd2fe18d1b3c2385e649
Reviewed-on: https://chromium-review.googlesource.com/1212402
Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589594}
[modify] https://crrev.com/2248e7049cd6c56f90d337a1c1582c8d898fb8f9/ios/web/web_state/ui/crw_web_controller.mm

Labels: Merge-Request-70
Status: Fixed (was: Started)
Project Member

Comment 13 by sheriffbot@chromium.org, Sep 8

Labels: -Merge-Request-70 Hotlist-Merge-Approved Merge-Approved-70
Your change meets the bar and is auto-approved for M70. Please go ahead and merge the CL to branch 3538 manually. Please contact milestone owner if you have questions.
Owners: benmason@(Android), kariahda@(iOS), geohsu@(ChromeOS), abdulsyed@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 14 by bugdroid1@chromium.org, Sep 10

Labels: -merge-approved-70 merge-merged-3538
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8492fb8be05789efb160f2ff528b7f92568ec45c

commit 8492fb8be05789efb160f2ff528b7f92568ec45c
Author: Eugene But <eugenebut@google.com>
Date: Mon Sep 10 18:18:40 2018

Fix respondToWKScriptMessage for windows with opener.

For windows with opener |scriptMessage.frameInfo.securityOrigin| returns
opener's security origin, while document URL can be about:blank.
This change allows all the messages coming from the main frame, which
was the orginal intention of the code.

This CL does not have a test because code that filters cross-origin
messages will be removed anyway.

TBR=eugenebut@google.com

(cherry picked from commit 2248e7049cd6c56f90d337a1c1582c8d898fb8f9)

Bug:  879464 
Change-Id: I15dac35bb3911ad93fc6bd2fe18d1b3c2385e649
Reviewed-on: https://chromium-review.googlesource.com/1212402
Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#589594}
Reviewed-on: https://chromium-review.googlesource.com/1217025
Reviewed-by: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/branch-heads/3538@{#228}
Cr-Branched-From: 79f7c91a2b2a2932cd447fa6f865cb6662fa8fa6-refs/heads/master@{#587811}
[modify] https://crrev.com/8492fb8be05789efb160f2ff528b7f92568ec45c/ios/web/web_state/ui/crw_web_controller.mm

Status: Verified (was: Fixed)
Verified in M71.0.3549.0 canary
iOS: 12.0 11.4.1
iPhoneX, iPad Pro.
Verified in M70.0.3538.17 in iPad Air(iOS 12 beta 12), iPad Air(iOS 10.3.3) and iPhone 6s plus(iOS 12 beta 12)

Print is now working with the attached html file, looks good.

Link to video:
https://drive.google.com/file/d/1Z37e9go7JX9hKpXFqaFq8i90vKfB6F0j/view?usp=sharing


Sign in to add a comment