<?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>28622</bug_id>
          
          <creation_ts>2015-05-11 15:40:17 +0000</creation_ts>
          <short_desc>window.close() should not close the window when unload or beforeunload events are running</short_desc>
          <delta_ts>2019-03-29 19:13:02 +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>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gijs">gijskruitbosch</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>d</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>120250</commentid>
    <comment_count>0</comment_count>
    <who name="Gijs">gijskruitbosch</who>
    <bug_when>2015-05-11 15:40:17 +0000</bug_when>
    <thetext>https://html.spec.whatwg.org/multipage/browsers.html#dom-window-close currently says:

&gt; The close() method on Window objects should, if all the following conditions
&gt; are met, close the browsing context A:
&gt;
&gt; * The corresponding browsing context A is script-closable.
&gt; * The responsible browsing context specified by the incumbent settings object
&gt;   is familiar with the browsing context A.
&gt; * The responsible browsing context specified by the incumbent settings object
&gt;   is allowed to navigate the browsing context A.
&gt;
&gt; A browsing context is script-closable if it is an auxiliary browsing context
&gt; that was created by a script (as opposed to by an action of the user), or if
&gt; it is a top-level browsing context whose session history contains only one
&gt; Document.

Consider the following HTML:

&lt;body&gt;
&lt;script&gt;
window.addEventListener(&quot;beforeunload&quot;, function() { window.close() }, false);
&lt;/script&gt;
&lt;/body&gt;

If I understand the current spec correctly, if a page like this is loaded as the first document in a browsing context, and the user then attempts to navigate the page to any other page/address, say, https://whatwg.org/, then per spec the browsing context should close.

This does not seem optimal to me, and as best I can tell, is not what Blink implements (window.close gets ignored), while Trident prompts the user, and Gecko currently reacts as per spec in this case. I think the Blink behaviour makes some sense, and I think the spec should be brought in line with it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>129646</commentid>
    <comment_count>1</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2019-03-29 19:13:02 +0000</bug_when>
    <thetext>https://github.com/whatwg/html/issues/4466</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>