Closed Bug 1247848 Opened 9 years ago Closed 9 years ago

Support window.print()

Categories

(Firefox for iOS :: Browser, defect)

Other
iOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fxios 4.0+ ---

People

(Reporter: vinoth.r, Assigned: st3fan)

References

(Depends on 2 open bugs)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36 Steps to reproduce: 1. Open this url http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_print on your Firefox in iPad or android tablet. 2. Click print this page button Actual results: It doesn't open print dialogue but it does in desktop browsers, Safari for iPad and chrome for Android Expected results: It should promot print dialogue to print the page
This doesn't work in Chrome for iOS either (WKWebView). I suspect there is no method available or no delegate method hooked up.
Status: UNCONFIRMED → NEW
tracking-fxios: --- → ?
Ever confirmed: true
I'm pretty sure we don't support window.print on Android either.
Assignee: nobody → sarentz
Summary: window.print() doesn't respond in Firefox for iOS → Support window.print()
This patch adds support for `window.print()`. It does so by patching `window.print()` to our own handler, which sends a message to the native side of things. There we can use the standard iOS print infrastructure to print the `WKWebView`.
Attachment #8725082 - Flags: review?(sleroux)
Attachment #8725082 - Flags: review?(sleroux) → review+
There was a question in the PR about supporting the onBeforePrint/onAfterPrint callbacks. I have been testing this and it seems that WebKit instead supports this via the 'print' media query. var mediaQueryList = window.matchMedia('print'); mediaQueryList.addListener(function(mql) { if (mql.matches) { document.getElementById("foo").innerHTML="beforePrint"; } else { document.getElementById("foo").innerHTML="afterPrint"; } }); Full demo at http://people.mozilla.org/~sarentz/t/onprint.html This is triggered correctly via both this window.print() implementation and the system Print action from the Share Sheet. So I think this is good to go in terms of WebKit compatibility.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Depends on: 1261805
Depends on: 1263570
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: