MSIE 6.0 'Permission Denied During Window Closing' Bug - Test Case

Date: August 23th, 2006

Microsoft's latest security update (issued on August 8th, 2006) seems to have triggered a new Javascript bug in MSIE 6.0, which triggers a "Permission Denied" error when accessing the properties of a newly opened window-object while the new window is in the process of closing itself.

(Note: This bug does not seem to affect older versions of MSIE.)


See the bug for yourself:

  1. Open the Window <--- click here!
  2. Then close the window normally.
  3. Notice how script crashes with a "Permission Denied" error, in MSIE 6.0 (with the 2006-08-08 security update installed).

See the original blog entry for comments/discussion.


The javascript that triggers the bug:

  var myWindow = null;
  var myInterval = null;
  var intervalMs = 25;

  var checkWindowStatus = function() {
    if (!myWindow || myWindow.closed) {
      alert("the popup has been closed!");
      clearInterval(myInterval);
      myWindow = null;
    }
  };

  var openWindow = function() {
    if (myWindow) { return; }
    myWindow = window.open("about:blank", "popup", "width=200,height=200");
    myInterval = setInterval(checkWindowStatus, intervalMs);
  };

Note: As you increase the value of intervalMs, the probability of the bug getting triggered approaches zero.


Workarounds:


Author: Már Örlygsson - Discuss this bug!