Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math.Round opens the browser print dialog #290

Open
BillWagner opened this issue Jun 19, 2019 · 79 comments

Comments

Projects
None yet
@BillWagner
Copy link
Member

commented Jun 19, 2019

Describe the bug

Put the following code in the http:/try.dot.net page:

using System;
public class Example
{
    public static void Main()
    {
        var x = Math.Round(11.1, MidpointRounding.AwayFromZero);
    }
}

Instead of printing the output, the "run" button opens the browser's print dialog.

Did this error occur while using dotnet try or online?

  • dotnet-try
  • online

What kind of error was it?

  • User Interface (UI): For example the output never displayed
  • Service Error: For example "The service is temporarily unavailable. We are working on it"
  • Other:

Screenshots

Please complete the following:

  • OS
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Safari

Both Edge and Chrome exhibit this behavior on both Windows 10 and MacOS.

/cc @jonsequitur @rchande

@TomasEkeli

This comment has been minimized.

Copy link

commented Jun 19, 2019

I can confirm it does this on Win10 Firefox 67.0.3 as well

@nphmuller

This comment has been minimized.

Copy link

commented Jun 19, 2019

Can confirm it also happens on iOS 12.3.1 in Safari.

@CrshOverride

This comment has been minimized.

Copy link

commented Jun 19, 2019

Confirmed on Pop_OS! 19.04 in Brave.

@simpleauthority

This comment has been minimized.

Copy link

commented Jun 19, 2019

Same on MacOSX 10.14.5 on Firefox 67.0.3

@diedona

This comment has been minimized.

Copy link

commented Jun 19, 2019

Confirmed on Win10 Chrome 74.0.3729.169

@PeterOrneholm

This comment has been minimized.

Copy link

commented Jun 19, 2019

Interesting! Confirmed on Win 10 / Chrome here as well.

I just tried listening to beforeprint event (see exampel below), but that wasn't triggered (as it is if calling window.print();). How can that dialog even be launched in a browser except usingwindow.print();?

window.addEventListener("beforeprint", function(event) { debugger; console.log("print", arguments); });
@DominykasPetke

This comment has been minimized.

Copy link

commented Jun 19, 2019

Confirming in Manjaro (testing branch), Firefox 67.0.3-0

@beylkhanovdamir

This comment has been minimized.

Copy link

commented Jun 19, 2019

+1

@Pablissimo

This comment has been minimized.

Copy link

commented Jun 19, 2019

Just doing a bit of breakpointing, and the following line seems to trigger it from mono.js:

image

Above is prettified in Chrome having just traversed a bit of the stacktrace for the console errors that appear after the print dialog is dismissed.

@OscarCanek

This comment has been minimized.

Copy link

commented Jun 19, 2019

Confirmed on macOS Mojave 10.14.5 Safari Version 12.1.1 (14607.2.6.1.1)

@ewinnington

This comment has been minimized.

Copy link

commented Jun 19, 2019

On iOS 12.3.1 in Safari, I get a message “This webpage has been blocked from automatically printing”, allowing it bring us the printer options for a one page print job.

@SnakyBeaky

This comment has been minimized.

Copy link

commented Jun 19, 2019

Changing MidpointRounding.AwayFromZero to MidpointRounding.ToEven stops that behaviour.

@NickAcPT

This comment has been minimized.

Copy link

commented Jun 19, 2019

My guess is that the error handler shown above by Pablissimo is calling window.print instead of it calling a method that prints the error to the console out.

@colombod

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

so cool. would not be surprised if this is another amazing byproduct of name scoping in javascript when in browser.

@kowlgi

This comment has been minimized.

Copy link

commented Jun 19, 2019

A video reproduction of the bug :
TRIMVIDEO (1)

Tested on macOS 10.14.5 Chrome 74.0.3729.169

@jonsequitur jonsequitur added the bug label Jun 19, 2019

@tomswartz07

This comment has been minimized.

Copy link

commented Jun 19, 2019

Confirmed Firefox 67.0.3 on Archlinux 5.1.11-arch1-1-ARCH here as well. Truly cross platform 🎉

@gmarinov

This comment has been minimized.

Copy link

commented Jun 19, 2019

macOS 10.13.6, Safari 12.1.1

Screen Shot 2019-06-20 at 00 56 28

@jcoo092

This comment has been minimized.

Copy link

commented Jun 20, 2019

Just in case it's needed: Confirmed also on Windows 10 Home version 10.0.18362 with Opera 60.0.3255.170

@ghost

This comment has been minimized.

Copy link

commented Jun 20, 2019

I tried this on IE5.5 in a MacOS 9 VM and an Apple Laserwriter II spontaneously materialized on the floor

@hydrogen18

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed on Chrome 72.0.3626.96 (Official Build) (64-bit) on Ubuntu 14.04

@mbrumlow

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed on Linux - Ubuntu 19.04 running Firefox nightly 69.0a1 (2019-06-19) (64-bit)

@braden-wright93

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed the print dialog opens on Linux - Ubuntu 18.04 LTS (64-bit) with Firefox 67.0.2 (64-bit)

Unable to trigger print dialog on Android - LineageOS 16 for Google Pixel, default Chrome/WebView browser

@AndroidKitKat

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed in macOS 10.14.4 using Microsoft Edge Insider 77.0.189.3 (Official build) Dev (64-bit)
スクリーンショット 2019-06-19 21 39 50

@gaufung

This comment has been minimized.

Copy link

commented Jun 20, 2019

How it works?

@AyrA

This comment has been minimized.

Copy link

commented Jun 20, 2019

Looks like some function somewhere calls print, meaning a local print function but this is probably set to window

@babbaj

This comment has been minimized.

Copy link

commented Jun 20, 2019

confirmed on India Browser 2019

@mateuschmitz

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed in macOS 10.14.5 and Firefox 67.0.2 (64-bit)

@arthurcolle

This comment has been minimized.

Copy link

commented Jun 20, 2019

Best Issue of 2019

@jaddie

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed on Manjaro Linux - Chromium Version 75.0.3770.80 Arch Linux (64-bit)

Also the print dialog appears to require dismissing twice as well.

@pietrovismara

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed on Naenara for Red Star OS 3.0

@frzifus

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed: Chromium Version 75 Gentoo Linux

@berksaribas

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed on MacOS Mojave 10.14 with Firefox 67.0.3

@PurHur

This comment has been minimized.

Copy link

commented Jun 20, 2019

Javascript is the best. If we had such architecture 20 years ago we would be doomed now.

@Kivylius

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed on Windows Vista 64-bit with Internet Explorer 9

@alydemah

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed Win10 Chrome 74.0.3729.169

@friendlyanon

This comment has been minimized.

Copy link

commented Jun 20, 2019

@PurHur

Javascript is the best. If we had such architecture 20 years ago we would be doomed now.

As shown in the thread earlier the browser is instructed to print. Is the computer doing A when instructed to do A an unusual thing outside the JavaScript world?

@PurHur

This comment has been minimized.

Copy link

commented Jun 20, 2019

As shown in the thread earlier the browser is instructed to print. Is the computer doing A when instructed to do A an unusual thing outside the JavaScript world?

In good langues such things dont happen randomly if you dont pass a valid this object to your call because you made some magic.
Its not like the devs called window.print here. Its a side effect which should never happen.

to long to explain: Its bad that the language allows such sort of bugs.

@chrisetheridge

This comment has been minimized.

Copy link

commented Jun 20, 2019

confirmed: opens Print Butter dialogue on my Toaster

@Kotynek

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed: Ubuntu 18.04.2 LTS, Opera 60.0.3255.170

@leonardus

This comment has been minimized.

Copy link

commented Jun 20, 2019

I don't think this bug needs to be confirmed anymore, except in cases where the bug is not present, such as in Tor Browser. Instead we should be discussing possible causes and solutions.

@jalovatt

This comment has been minimized.

Copy link

commented Jun 20, 2019

In good langues such things dont happen randomly if you dont pass a valid this object to your call because you made some magic.
Its not like the devs called window.print here. Its a side effect which should never happen.

to long to explain: Its bad that the language allows such sort of bugs.

So if someone were to override printf in a C program that would make C a bad language? Because you can do that. You probably shouldn't, but you can.

@PurHur

This comment has been minimized.

Copy link

commented Jun 20, 2019

In good langues such things dont happen randomly if you dont pass a valid this object to your call because you made some magic.
Its not like the devs called window.print here. Its a side effect which should never happen.
to long to explain: Its bad that the language allows such sort of bugs.

So if someone were to override printf in a C program that would make C a bad language? Because you can do that. You probably shouldn't, but you can.

C is not Javascript and clean code in Asm doesnt exist.
Its the matter of it can happen accidentally not "im going to overwrite printf for the sake of a discussion".
How do you randomly overwrite printf in c?

@leonardus

This comment has been minimized.

Copy link

commented Jun 20, 2019

In good langues such things dont happen randomly if you dont pass a valid this object to your call because you made some magic.
Its not like the devs called window.print here. Its a side effect which should never happen.
to long to explain: Its bad that the language allows such sort of bugs.

So if someone were to override printf in a C program that would make C a bad language? Because you can do that. You probably shouldn't, but you can.

Absolutely. There is an exhaustive list of valid criticisms of Javascript, but letting you run with scissors is not one of them.

@DrRetro

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed:

1.) Ubuntu 18.04.2 LTS, Mozilla FF 67.0.3 (64-Bit) & Google Chromium Version 75.0.3770.90
2.) Arch Linux x86_64 (Kernel 5.1.9-arch-1-ARCH) FF 67.0.3-1 & Chromium Version 75.3770.100

@jalovatt

This comment has been minimized.

Copy link

commented Jun 20, 2019

In good langues such things dont happen randomly if you dont pass a valid this object to your call because you made some magic.
Its not like the devs called window.print here. Its a side effect which should never happen.
to long to explain: Its bad that the language allows such sort of bugs.

So if someone were to override printf in a C program that would make C a bad language? Because you can do that. You probably shouldn't, but you can.

C is not Javascript and clean code in Asm doesnt exist.
Its the matter of it can happen accidentally not "im going to overwrite printf for the sake of a discussion".
How do you randomly overwrite printf in c?

Who said random? You can link a library with your own printf that tries to use the printer if you want, and if someone else hops on the project and doesn't know that...

This is human error. What you're suggesting is possible with pretty much any language.

@PurHur

This comment has been minimized.

Copy link

commented Jun 20, 2019

It is prossible but you wont accidentally fall into it. Thats makes a bad language. But im out now. This is no rant forum.

@graingert

This comment has been minimized.

Copy link

commented Jun 20, 2019

def better_print(*args, **kwargs):
    import subprocess
    lpr =  subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE)
    lpr.stdin.write(' '.join(args))

import builtins
builtins.print = better_print
@PurHur

This comment has been minimized.

Copy link

commented Jun 20, 2019

def better_print(*args, **kwargs):
    import subprocess
    lpr =  subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE)
    lpr.stdin.write(' '.join(args))

import builtins
builtins.print = better_print

only that dotnet did not overwrite the print or round function at all. omg please

@friendlyanon

This comment has been minimized.

Copy link

commented Jun 20, 2019

Instead it called the global print that - as the name suggests - prints what was given to it! What a shocker!

@ststeiger

This comment has been minimized.

Copy link

commented Jun 20, 2019

Best Issue of 2019

Best Issue of 2019 SO FAR
And just a typical day in JS development.

Changing MidpointRounding.AwayFromZero to MidpointRounding.ToEven stops that behaviour.

Yea, but that also switches from mercantile rounding to mathematical rounding.
Which is actually better, by the way, but unfortunately, results from .NET then don't match results from SQL-Server rounding - which means if you display results in report vs. forms yields a different result.
Also, it that value (rounded to 2 decimals) is multiplying another value (high), then the difference can be quite substantial.

@hackbyte

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed with Chromium on Funtoo (1.3-kit, baselayout 2.2.2 ## pure64):
Installed versions: 71.0.3578.30^d(06:56:13 AM 04/19/2019)(cups hangouts pic proprietary-codecs suid widevine -component-build -custom-cflags -gnome-keyring -jumbo-build -kerberos -neon -pulseaudio -selinux -system-ffmpeg -system-icu -system-libvpx -tcmalloc KERNEL="linux"

@EgorBo

This comment has been minimized.

Copy link

commented Jun 20, 2019

I like the idea of printing stack-traces on a real printer instead of console log

@PurHur

This comment has been minimized.

Copy link

commented Jun 20, 2019

I like the idea of printing stack-traces on a real printer instead of console log

its a feature not a bug!

@Volker-Weissmann

This comment has been minimized.

Copy link

commented Jun 20, 2019

Confirmed with firefox 67.0.3 on Ubuntu 19.04

@ststeiger

This comment has been minimized.

Copy link

commented Jun 20, 2019

I like the idea of printing stack-traces on a real printer instead of console log

Yea, but on the off chance that this isn't meant sarcastically - please think of the environment hounds on melting ice sheet on water walking like jesus in the ocean before you needlessly print every single last crap.
Paper doesn't just come from the supplier, you know.

@PurHur

This comment has been minimized.

Copy link

commented Jun 20, 2019

lol

this thread....

@dotnet dotnet locked as spam and limited conversation to collaborators Jun 20, 2019

@lpereira

This comment has been minimized.

Copy link
Member

commented Jun 20, 2019

As amusing as the bug report is, and as funny as many of the responses here are, I'm locking down the issue while we work on it. Thanks for reporting it, @BillWagner!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.