<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25686</bug_id>
          
          <creation_ts>2014-05-13 17:29:36 +0000</creation_ts>
          <short_desc>alert() needs two overloads so alert(undefined) can alert &quot;undefined&quot;</short_desc>
          <delta_ts>2014-05-16 16:54:15 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#the-window-object</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>d</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>105871</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-05-13 17:29:36 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html
Multipage: http://www.whatwg.org/C#the-window-object
Complete: http://www.whatwg.org/c#the-window-object
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
alert() needs two overloads so alert(undefined) can alert &quot;undefined&quot;

Posted from: 63.245.221.34 by bzbarsky@mit.edu
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105872</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-13 17:34:44 +0000</bug_when>
    <thetext>People are asking for alert(undefined) to show &quot;undefined&quot;.

Current behavior in browsers:

Chrome, Firefox 27 and earlier, IE11:
  alert() shows &quot;&quot;
  alert(undefined) shows &quot;undefined&quot;

Firefox 28 and later, current spec: 
  alert() shows &quot;&quot;
  alert(undefined) shows &quot;&quot;

Safari 7: 
  alert() shows &quot;undefined&quot;
  alert(undefined) shows &quot;undefined&quot;

To get the Chrome/IE/old-Firefox behavior, the IDL needs to be:

  void alert();
  void alert(DOMString message);

with prose that says that the first overload uses &quot;&quot; as the message.

To get the Safari behavior, the IDL can be:

  void alert(optional DOMString message = &quot;undefined&quot;);

For now I&apos;m switching Firefox to our old behavior over in https://bugzilla.mozilla.org/show_bug.cgi?id=999315</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105873</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-13 17:35:38 +0000</bug_when>
    <thetext>But note that the Safari behavior here is more JavaScripty in principle.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105874</commentid>
    <comment_count>3</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2014-05-13 17:39:50 +0000</bug_when>
    <thetext>Just to chime in:

Both the Firefox 28+ and Safari 7+ behaviors are reasonably JavaScriptey. Firefox 28+ behaves as if it were

function alert(message = &quot;&quot;) {
  message = String(message); // standard type coercion here
}

and Safari 7+ behaves as if it were

function alert(message) {
  message = String(message);
}

If we can get away with either of those two that would be nice. Sounds like the Firefox 28+ behavior is a no-go though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105875</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-13 17:57:31 +0000</bug_when>
    <thetext>Right, to be clear I was comparing the Safari behavior to the Chrome/IE/old-Firefox behavior.

The new-Firefox behavior is indeed reasonably JavaScripty, but seems to not be what people seem to want from this API.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105876</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-13 17:57:56 +0000</bug_when>
    <thetext>And I personally would be OK with trying to switch Gecko to the Safari behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105879</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-13 18:00:32 +0000</bug_when>
    <thetext>If I define:

  void alert();
  void alert(DOMString message);

...and then you pass the undefined value explicitly, it picks the DOMString overload? It doesn&apos;t pretend the argument was omitted?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105886</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-13 18:28:09 +0000</bug_when>
    <thetext>I believe that is the current state of WebIDL, yes, and some other APIs rely on that....

Of course if we do the Safari behavior it&apos;s a nonissue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106095</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-15 21:02:06 +0000</bug_when>
    <thetext>Yeah, looks like Web IDL doesn&apos;t do anything to treat explicit &quot;undefined&quot;s as missing arguments. Ok.

Do you want this for prompt() or confirm() too, or just alert()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106174</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-16 16:18:13 +0000</bug_when>
    <thetext>It&apos;s only come up as an issue for alert(), since people use that to examine the value.  For prompt() and confirm() both &quot;&quot; and &quot;undefined&quot; are pretty much pointless given how the string is supposed to be used, so I don&apos;t have an opinion as to which we should do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106175</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-16 16:53:37 +0000</bug_when>
    <thetext>Ok. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106176</commentid>
    <comment_count>11</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-05-16 16:54:04 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8638.
Check-in comment: for compat, apparently alert() should alert &apos;&apos; and alert(undefined) should alert &apos;undefined&apos;
http://html5.org/tools/web-apps-tracker?from=8637&amp;to=8638</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106177</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-16 16:54:15 +0000</bug_when>
    <thetext>(I used the more widely implemented behaviour; I don&apos;t mind switching to another behaviour but we should get more vendors on board if we want to do that.)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>