Closed Bug 1414935 Opened 7 years ago Closed 7 years ago

Not possible to feature detect window.print

Categories

(Firefox for Android Graveyard :: General, defect)

Firefox 56
defect
Not set
normal

Tracking

(firefox59 fixed)

RESOLVED FIXED
Firefox 59
Tracking Status
firefox59 --- fixed

People

(Reporter: jdlrobson, Assigned: bzbarsky)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Steps to reproduce: Visit this proof of concept in Firefox mobile (v56) and click pint http://jdlrobson.com/dev/window.print/ Actual results: An exception is thrown when window.print() is called To avoid showing a useless button in the browser I'd like to feature detect this and avoid showing the button when print functionality is not available e.g. if ( window.print === undefined ) hidePrintButton; Expected results: window.print is a function and even though we know it will fail unconditionally we provide no way for a JS developer to take preemptive measures... :(
Looks like dom.disable_window_print is set in mobile/android/app/mobile.js That was added in bug 739038, which was before we converted Window to WebIDL bindings in bug 789261. At this point, we can definitely condition exposure of the function on that preference. Matt, can you think of a reason not to do that?
Flags: needinfo?(mbrubeck)
No, I don't know of any particular need to keep the "print" function visible when the pref is set.
Flags: needinfo?(mbrubeck)
MozReview-Commit-ID: ArDw85eQYeh
Attachment #8926699 - Flags: review?(nika)
Assignee: nobody → bzbarsky
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8926699 - Flags: review?(nika) → review+
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/b9aa0fc4f179 Hide window.print entirely when it's disabled by pref. r=mystor
Backed out for failing mochitest test_bug739038.html: https://hg.mozilla.org/integration/mozilla-inbound/rev/0fb0e62aadffc3585545dd8274bdbfa9ce313991 Push with failures: https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&revision=01a5361e9460683fb43c05a3c267eec4bbef081d&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=usercancel&filter-resultStatus=runnable&filter-resultStatus=retry Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=144336263&repo=mozilla-inbound [task 2017-11-13T17:51:53.375Z] 17:51:53 INFO - TEST-START | dom/tests/mochitest/bugs/test_bug739038.html [task 2017-11-13T17:51:53.601Z] 17:51:53 INFO - GECKO(3520) | [Parent 3520, Main Thread] WARNING: Couldn't connect to D-Bus system bus, Could not connect: No such file or directory: 'glib warning', file /builds/worker/workspace/build/src/toolkit/xre/nsSigHandlers.cpp, line 141 [task 2017-11-13T17:51:53.601Z] 17:51:53 INFO - GECKO(3520) | ** (firefox:3520): WARNING **: Couldn't connect to D-Bus system bus, Could not connect: No such file or directory [task 2017-11-13T17:58:03.614Z] 17:58:03 INFO - Buffered messages finished [task 2017-11-13T17:58:03.616Z] 17:58:03 ERROR - TEST-UNEXPECTED-TIMEOUT | dom/tests/mochitest/bugs/test_bug739038.html | application timed out after 370 seconds with no output [task 2017-11-13T17:58:03.617Z] 17:58:03 ERROR - Force-terminating active process(es). [task 2017-11-13T17:58:03.619Z] 17:58:03 INFO - Determining child pids from psutil [task 2017-11-13T17:58:03.623Z] 17:58:03 INFO - Found child pids: [3574, 3627] [task 2017-11-13T17:58:03.624Z] 17:58:03 INFO - Killing process: 3574 [task 2017-11-13T17:58:03.625Z] 17:58:03 INFO - TEST-INFO | started process screentopng [task 2017-11-13T17:58:03.910Z] 17:58:03 INFO - TEST-INFO | screentopng: exit 0 [task 2017-11-13T17:58:03.912Z] 17:58:03 INFO - Killing process: 3627 [task 2017-11-13T17:58:03.913Z] 17:58:03 INFO - Not taking screenshot here: see the one that was previously logged [task 2017-11-13T17:58:33.916Z] 17:58:33 INFO - psutil found pid 3627 dead [task 2017-11-13T17:58:33.918Z] 17:58:33 WARNING - failed to kill pid 3574 after 30s [task 2017-11-13T17:58:33.918Z] 17:58:33 INFO - Killing process: 3520 [task 2017-11-13T17:58:33.918Z] 17:58:33 INFO - Not taking screenshot here: see the one that was previously logged [task 2017-11-13T17:58:34.059Z] 17:58:34 INFO - TEST-INFO | Main app process: exit 6 [task 2017-11-13T17:58:34.061Z] 17:58:34 INFO - Buffered messages finished [task 2017-11-13T17:58:34.063Z] 17:58:34 ERROR - TEST-UNEXPECTED-FAIL | dom/tests/mochitest/bugs/test_bug739038.html | application terminated with exit code 6 [task 2017-11-13T17:58:34.064Z] 17:58:34 INFO - runtests.py | Application ran for: 0:07:23.363489 [task 2017-11-13T17:58:34.065Z] 17:58:34 INFO - zombiecheck | Reading PID log: /tmp/tmpFvUtIBpidlog [task 2017-11-13T17:58:34.066Z] 17:58:34 INFO - ==> process 3520 launched child process 3545 [task 2017-11-13T17:58:34.067Z] 17:58:34 INFO - ==> process 3520 launched child process 3574 [task 2017-11-13T17:58:34.068Z] 17:58:34 INFO - ==> process 3520 launched child process 3627 [task 2017-11-13T17:58:34.069Z] 17:58:34 INFO - ==> process 3520 launched child process 3676 [task 2017-11-13T17:58:34.070Z] 17:58:34 INFO - zombiecheck | Checking for orphan process with PID: 3545 [task 2017-11-13T17:58:34.071Z] 17:58:34 INFO - zombiecheck | Checking for orphan process with PID: 3574 [task 2017-11-13T17:58:34.072Z] 17:58:34 INFO - zombiecheck | Checking for orphan process with PID: 3627 [task 2017-11-13T17:58:34.073Z] 17:58:34 INFO - zombiecheck | Checking for orphan process with PID: 3676 [task 2017-11-13T17:58:34.074Z] 17:58:34 INFO - mozcrash Downloading symbols from: https://queue.taskcluster.net/v1/task/dfwzmgM9Q16JoVuKKe2wkQ/artifacts/public/build/target.crashreporter-symbols.zip [task 2017-11-13T17:58:40.756Z] 17:58:40 INFO - mozcrash Copy/paste: /usr/local/bin/linux64-minidump_stackwalk /tmp/tmp46rYMp.mozrunner/minidumps/6035fd20-c533-d3c4-d5a4-bf108cb7c146.dmp /tmp/tmpMpvfUh [task 2017-11-13T17:58:48.736Z] 17:58:48 INFO - mozcrash Saved minidump as /builds/worker/workspace/build/blobber_upload_dir/6035fd20-c533-d3c4-d5a4-bf108cb7c146.dmp [task 2017-11-13T17:58:48.747Z] 17:58:48 INFO - mozcrash Saved app info as /builds/worker/workspace/build/blobber_upload_dir/6035fd20-c533-d3c4-d5a4-bf108cb7c146.extra [task 2017-11-13T17:58:48.775Z] 17:58:48 INFO - PROCESS-CRASH | dom/tests/mochitest/bugs/test_bug739038.html | application crashed [@ libc-2.23.so + 0xfb70d] [task 2017-11-13T17:58:48.775Z] 17:58:48 INFO - Crash dump filename: /tmp/tmp46rYMp.mozrunner/minidumps/6035fd20-c533-d3c4-d5a4-bf108cb7c146.dmp [task 2017-11-13T17:58:48.775Z] 17:58:48 INFO - Operating system: Linux [task 2017-11-13T17:58:48.775Z] 17:58:48 INFO - 0.0.0 Linux 3.13.0-112-generic #159-Ubuntu SMP Fri Mar 3 15:26:07 UTC 2017 x86_64 [task 2017-11-13T17:58:48.775Z] 17:58:48 INFO - CPU: amd64 [task 2017-11-13T17:58:48.775Z] 17:58:48 INFO - family 6 model 62 stepping 4 [task 2017-11-13T17:58:48.776Z] 17:58:48 INFO - 2 CPUs [task 2017-11-13T17:58:48.776Z] 17:58:48 INFO - [task 2017-11-13T17:58:48.776Z] 17:58:48 INFO - GPU: UNKNOWN [task 2017-11-13T17:58:48.776Z] 17:58:48 INFO - [task 2017-11-13T17:58:48.777Z] 17:58:48 INFO - Crash reason: SIGABRT [task 2017-11-13T17:58:48.778Z] 17:58:48 INFO - Crash address: 0x3e8000003d9 [task 2017-11-13T17:58:48.778Z] 17:58:48 INFO - Process uptime: not available [task 2017-11-13T17:58:48.779Z] 17:58:48 INFO - [task 2017-11-13T17:58:48.780Z] 17:58:48 INFO - Thread 0 (crashed) [task 2017-11-13T17:58:48.780Z] 17:58:48 INFO - 0 libc-2.23.so + 0xfb70d [task 2017-11-13T17:58:48.781Z] 17:58:48 INFO - rax = 0xfffffffffffffffc rdx = 0x00000000ffffffff [task 2017-11-13T17:58:48.782Z] 17:58:48 INFO - rcx = 0xffffffffffffffff rbx = 0x00007fbf6d07e7a0 [task 2017-11-13T17:58:48.782Z] 17:58:48 INFO - rsi = 0x0000000000000003 rdi = 0x00007fbf6d07e7a0 [task 2017-11-13T17:58:48.783Z] 17:58:48 INFO - rbp = 0x00007ffd98390db0 rsp = 0x00007ffd98390d80 [task 2017-11-13T17:58:48.784Z] 17:58:48 INFO - r8 = 0x0000000000000003 r9 = 0x0000000000000001 [task 2017-11-13T17:58:48.784Z] 17:58:48 INFO - r10 = 0x00007fbf6d07e720 r11 = 0x0000000000000293 [task 2017-11-13T17:58:48.785Z] 17:58:48 INFO - r12 = 0x0000000000000003 r13 = 0x00000000ffffffff [task 2017-11-13T17:58:48.786Z] 17:58:48 INFO - r14 = 0x00007fbf77c04050 r15 = 0x0000000000000003 [task 2017-11-13T17:58:48.787Z] 17:58:48 INFO - rip = 0x00007fbf8622570d [task 2017-11-13T17:58:48.787Z] 17:58:48 INFO - Found by: given as instruction pointer in context [task 2017-11-13T17:58:48.788Z] 17:58:48 INFO - 1 libxul.so!PollWrapper [nsAppShell.cpp:01a5361e9460 : 53 + 0xf] [task 2017-11-13T17:58:48.789Z] 17:58:48 INFO - rbp = 0x00007ffd98390db0 rsp = 0x00007ffd98390d90 [task 2017-11-13T17:58:48.789Z] 17:58:48 INFO - rip = 0x00007fbf77c0407f [task 2017-11-13T17:58:48.790Z] 17:58:48 INFO - Found by: stack scanning [task 2017-11-13T17:58:48.791Z] 17:58:48 INFO - 2 libglib-2.0.so.0.4800.2 + 0x4a38c [task 2017-11-13T17:58:48.791Z] 17:58:48 INFO - rbx = 0x00007fbf7031d2f0 rbp = 0x0000000000000003 [task 2017-11-13T17:58:48.792Z] 17:58:48 INFO - rsp = 0x00007ffd98390dc0 r12 = 0x00007fbf6d07e7a0 [task 2017-11-13T17:58:48.793Z] 17:58:48 INFO - r13 = 0x00000000ffffffff rip = 0x00007fbf812d938c [task 2017-11-13T17:58:48.793Z] 17:58:48 INFO - Found by: call frame info [task 2017-11-13T17:58:48.794Z] 17:58:48 INFO - 3 libglib-2.0.so.0.4800.2 + 0x4a49c [task 2017-11-13T17:58:48.795Z] 17:58:48 INFO - rsp = 0x00007ffd98390e20 rip = 0x00007fbf812d949c [task 2017-11-13T17:58:48.795Z] 17:58:48 INFO - Found by: stack scanning [task 2017-11-13T17:58:48.796Z] 17:58:48 INFO - 4 libxul.so!nsAppShell::ProcessNextNativeEvent [nsAppShell.cpp:01a5361e9460 : 295 + 0x5] [task 2017-11-13T17:58:48.797Z] 17:58:48 INFO - rsp = 0x00007ffd98390e40 rip = 0x00007fbf77c040cf [task 2017-11-13T17:58:48.797Z] 17:58:48 INFO - Found by: stack scanning [task 2017-11-13T17:58:48.798Z] 17:58:48 INFO - 5 libxul.so!nsBaseAppShell::DoProcessNextNativeEvent [nsBaseAppShell.cpp:01a5361e9460 : 141 + 0x10] [task 2017-11-13T17:58:48.798Z] 17:58:48 INFO - rsp = 0x00007ffd98390e50 rip = 0x00007fbf77bcf98c [task 2017-11-13T17:58:48.799Z] 17:58:48 INFO - Found by: stack scanning [task 2017-11-13T17:58:48.799Z] 17:58:48 INFO - 6 libxul.so!nsBaseAppShell::OnProcessNextEvent [nsBaseAppShell.cpp:01a5361e9460 : 292 + 0x8] [task 2017-11-13T17:58:48.800Z] 17:58:48 INFO - rsp = 0x00007ffd98390e80 rip = 0x00007fbf77bcfb40 [task 2017-11-13T17:58:48.800Z] 17:58:48 INFO - Found by: stack scanning [task 2017-11-13T17:58:48.800Z] 17:58:48 INFO - 7 libxul.so!nsThread::ProcessNextEvent [nsThread.cpp:01a5361e9460 : 950 + 0xf] [task 2017-11-13T17:58:48.800Z] 17:58:48 INFO - rsp = 0x00007ffd98390ed0 rip = 0x00007fbf75c89181 [task 2017-11-13T17:58:48.801Z] 17:58:48 INFO - Found by: stack scanning [task 2017-11-13T17:58:48.801Z] 17:58:48 INFO - 8 ld-2.23.so + 0xab01 [task 2017-11-13T17:58:48.802Z] 17:58:48 INFO - rsp = 0x00007ffd98390f20 rip = 0x00007fbf875eab01 [task 2017-11-13T17:58:48.802Z] 17:58:48 INFO - Found by: stack scanning
Flags: needinfo?(bzbarsky)
Yeah, the test needs to test against a global it creates after the pref is set. Fix coming up....
Pushed by bzbarsky@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/24a55985eeba Hide window.print entirely when it's disabled by pref. r=mystor
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
Flags: needinfo?(bzbarsky)
Target Milestone: Firefox 58 → Firefox 59
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: