browser/components/sessionstore/test/browser_495495.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/sessionstore/test/browser_495495.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function test() {
     1.9 +  /** Test for Bug 495495 **/
    1.10 +
    1.11 +  waitForExplicitFinish();
    1.12 +
    1.13 +  let newWin = openDialog(location, "_blank", "chrome,all,dialog=no,toolbar=yes");
    1.14 +  newWin.addEventListener("load", function() {
    1.15 +    newWin.removeEventListener("load", arguments.callee, false);
    1.16 +
    1.17 +    executeSoon(function() {
    1.18 +      let state1 = ss.getWindowState(newWin);
    1.19 +      newWin.close();
    1.20 +
    1.21 +      newWin = openDialog(location, "_blank",
    1.22 +        "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar=no,location,personal,directories,dialog=no");
    1.23 +      newWin.addEventListener("load", function() {
    1.24 +        newWin.removeEventListener("load", arguments.callee, false);
    1.25 +
    1.26 +        executeSoon(function() {
    1.27 +          let state2 = ss.getWindowState(newWin);
    1.28 +          newWin.close();
    1.29 +
    1.30 +          function testState(state, expected, callback) {
    1.31 +            let win = openDialog(location, "_blank", "chrome,all,dialog=no");
    1.32 +            win.addEventListener("load", function() {
    1.33 +              win.removeEventListener("load", arguments.callee, false);
    1.34 +
    1.35 +              is(win.gURLBar.readOnly, false,
    1.36 +                 "URL bar should not be read-only before setting the state");
    1.37 +              is(win.gURLBar.getAttribute("enablehistory"), "true",
    1.38 +                 "URL bar autocomplete should be enabled before setting the state");
    1.39 +              ss.setWindowState(win, state, true);
    1.40 +              is(win.gURLBar.readOnly, expected.readOnly,
    1.41 +                 "URL bar read-only state should be restored correctly");
    1.42 +              is(win.gURLBar.getAttribute("enablehistory"), expected.enablehistory,
    1.43 +                 "URL bar autocomplete state should be restored correctly");
    1.44 +
    1.45 +              win.close();
    1.46 +              executeSoon(callback);
    1.47 +            }, false);
    1.48 +          }
    1.49 +
    1.50 +          testState(state1, {readOnly: false, enablehistory: "true"}, function() {
    1.51 +            testState(state2, {readOnly: true, enablehistory: "false"}, finish);
    1.52 +          });
    1.53 +        });
    1.54 +      }, false);
    1.55 +    });
    1.56 +  }, false);
    1.57 +}

mercurial