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

Closed
7 of 13 tasks
BillWagner opened this issue Jun 19, 2019 · 80 comments
Closed
7 of 13 tasks

Math.Round opens the browser print dialog #290

BillWagner opened this issue Jun 19, 2019 · 80 comments

Comments

@BillWagner
Copy link
Member

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
Copy link

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

@nphmuller
Copy link

nphmuller commented Jun 19, 2019

Can confirm it also happens on iOS 12.3.1 in Safari.

@CrshOverride
Copy link

Confirmed on Pop_OS! 19.04 in Brave.

@simpleauthority
Copy link

Same on MacOSX 10.14.5 on Firefox 67.0.3

@diedona
Copy link

diedona commented Jun 19, 2019

Confirmed on Win10 Chrome 74.0.3729.169

@PeterOrneholm
Copy link

PeterOrneholm 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
Copy link

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

@dbeylkhanov
Copy link

+1

@Pablissimo
Copy link

Pablissimo 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
Copy link

Confirmed on macOS Mojave 10.14.5 Safari Version 12.1.1 (14607.2.6.1.1)

@ewinnington
Copy link

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
Copy link

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

@NickAcPT
Copy link

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
Copy link
Member

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

@kowlgi
Copy link

kowlgi commented Jun 19, 2019

A video reproduction of the bug :
TRIMVIDEO (1)

Tested on macOS 10.14.5 Chrome 74.0.3729.169

@tomswartz07
Copy link

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

@gmarinov
Copy link

macOS 10.13.6, Safari 12.1.1

Screen Shot 2019-06-20 at 00 56 28

@jcoo092
Copy link

jcoo092 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
Copy link

ghost 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
Copy link

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

@mbrumlow
Copy link

mbrumlow commented Jun 20, 2019

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

@ghost
Copy link

ghost 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
Copy link

AndroidKitKat 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
Copy link

gaufung commented Jun 20, 2019

How it works?

@AyrA
Copy link

AyrA commented Jun 20, 2019

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

@babbaj
Copy link

babbaj commented Jun 20, 2019

confirmed on India Browser 2019

@mateuschmitz
Copy link

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

@arthurcolle
Copy link

Best Issue of 2019

@jaddie
Copy link

jaddie 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.

@berksaribas
Copy link

Confirmed on MacOS Mojave 10.14 with Firefox 67.0.3

@PurHur
Copy link

PurHur commented Jun 20, 2019

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

@Kivylius
Copy link

Confirmed on Windows Vista 64-bit with Internet Explorer 9

@alydemah
Copy link

Confirmed Win10 Chrome 74.0.3729.169

@friendlyanon
Copy link

@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
Copy link

PurHur 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
Copy link

confirmed: opens Print Butter dialogue on my Toaster

@Kotynek
Copy link

Kotynek commented Jun 20, 2019

Confirmed: Ubuntu 18.04.2 LTS, Opera 60.0.3255.170

@leonardus
Copy link

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
Copy link

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
Copy link

PurHur 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
Copy link

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
Copy link

DrRetro 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
Copy link

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
Copy link

PurHur 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
Copy link

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
Copy link

PurHur 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
Copy link

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

@ststeiger
Copy link

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
Copy link

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
Copy link
Member

EgorBo commented Jun 20, 2019

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

@PurHur
Copy link

PurHur 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
Copy link

Confirmed with firefox 67.0.3 on Ubuntu 19.04

@ststeiger
Copy link

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
Copy link

PurHur commented Jun 20, 2019

lol

this thread....

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

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!

@akshita31
Copy link
Contributor

We updated the version of blazor in try.dot.net and the issue is fixed now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests