browser/components/tabview/test/browser_tabview_bug598600.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/tabview/test/browser_tabview_bug598600.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +let newWin;
     1.8 +function test() {
     1.9 +  let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
    1.10 +
    1.11 +  requestLongerTimeout(2);
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  // open a new window and setup the window state.
    1.15 +  newWin = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", "about:blank");
    1.16 +  newWin.addEventListener("load", function onLoad(event) {
    1.17 +    this.removeEventListener("load", onLoad, false);
    1.18 +
    1.19 +    let newState = {
    1.20 +      windows: [{
    1.21 +        tabs: [{
    1.22 +          entries: [{ "url": "about:blank" }],
    1.23 +          hidden: true,
    1.24 +          attributes: {},
    1.25 +          extData: {
    1.26 +            "tabview-tab":
    1.27 +              '{"bounds":{"left":20,"top":35,"width":280,"height":210},' +
    1.28 +              '"userSize":null,"url":"about:blank","groupID":1,' + 
    1.29 +              '"imageData":null,"title":null}'
    1.30 +          }
    1.31 +        },{
    1.32 +          entries: [{ url: "about:blank" }],
    1.33 +          index: 1,
    1.34 +          hidden: false,
    1.35 +          attributes: {},
    1.36 +          extData: {
    1.37 +            "tabview-tab": 
    1.38 +              '{"bounds":{"left":375,"top":35,"width":280,"height":210},' + 
    1.39 +              '"userSize":null,"url":"about:blank","groupID":2,' + 
    1.40 +              '"imageData":null,"title":null}'
    1.41 +          }
    1.42 +        }],
    1.43 +        selected:2,
    1.44 +        _closedTabs: [],
    1.45 +        extData: {
    1.46 +          "tabview-groups": '{"nextID":3,"activeGroupId":2}',
    1.47 +          "tabview-group": 
    1.48 +            '{"1":{"bounds":{"left":15,"top":10,"width":320,"height":375},' + 
    1.49 +            '"userSize":null,"title":"","id":1},' + 
    1.50 +            '"2":{"bounds":{"left":380,"top":5,"width":320,"height":375},' + 
    1.51 +            '"userSize":null,"title":"","id":2}}',
    1.52 +          "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":875,"height":650}}'
    1.53 +        }, sizemode:"normal"
    1.54 +      }]
    1.55 +    };
    1.56 +    ss.setWindowState(newWin, JSON.stringify(newState), true);
    1.57 +
    1.58 +    // add a new tab.
    1.59 +    newWin.gBrowser.addTab();
    1.60 +    is(newWin.gBrowser.tabs.length, 3, "There are 3 browser tabs"); 
    1.61 +
    1.62 +    let onTabViewShow = function() {
    1.63 +      newWin.removeEventListener("tabviewshown", onTabViewShow, false);
    1.64 +
    1.65 +      let contentWindow = newWin.TabView.getContentWindow();
    1.66 +      is(contentWindow.GroupItems.groupItems.length, 2, "Has two group items");
    1.67 +
    1.68 +      // clean up and finish
    1.69 +      newWin.close();
    1.70 +
    1.71 +      finish();
    1.72 +    }
    1.73 +    newWin.addEventListener("tabviewshown", onTabViewShow, false);
    1.74 +    waitForFocus(function() { newWin.TabView.toggle(); });
    1.75 +  }, false);
    1.76 +}

mercurial