summaryrefslogtreecommitdiff
path: root/dom/browser-element/mochitest/browserElement_CloseFromOpener.js
blob: 65ea4d1b7f653263b8170a48d742ce72372f4580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Any copyright is dedicated to the public domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Bug 764718 - Test that window.close() works from the opener window.
"use strict";

SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();

function runTest() {
  var iframe = document.createElement('iframe');
  iframe.setAttribute('mozbrowser', 'true');

  iframe.addEventListener('mozbrowseropenwindow', function(e) {
    ok(true, "got openwindow event.");
    document.body.appendChild(e.detail.frameElement);

    e.detail.frameElement.addEventListener("mozbrowserclose", function(e) {
      ok(true, "got mozbrowserclose event.");
      SimpleTest.finish();
    });
  });


  document.body.appendChild(iframe);

  // file_browserElement_CloseFromOpener opens a new window and then calls
  // close() on it.
  iframe.src = "file_browserElement_CloseFromOpener.html";
}

addEventListener('testready', runTest);