2011-08-21 07:29:49 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
|
|
|
getService(Ci.nsIPrivateBrowsingService);
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
let cw;
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
if (cw)
|
2011-09-29 21:17:00 -07:00
|
|
|
cw.Search.hide();
|
2011-08-21 07:29:49 -07:00
|
|
|
|
|
|
|
TabView.hide();
|
|
|
|
pb.privateBrowsingEnabled = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
let enableSearch = function (callback) {
|
2011-09-29 21:17:00 -07:00
|
|
|
if (cw.Search.isEnabled()) {
|
2011-08-21 07:29:49 -07:00
|
|
|
callback();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cw.addEventListener("tabviewsearchenabled", function onSearchEnabled() {
|
|
|
|
cw.removeEventListener("tabviewsearchenabled", onSearchEnabled, false);
|
|
|
|
executeSoon(callback);
|
|
|
|
}, false);
|
|
|
|
|
2011-09-29 21:17:00 -07:00
|
|
|
cw.Search.ensureShown();
|
2011-08-21 07:29:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
let getSearchboxValue = function () {
|
|
|
|
return cw.iQ("#searchbox").val();
|
|
|
|
};
|
|
|
|
|
|
|
|
let prepareSearchbox = function (callback) {
|
2011-09-29 21:17:00 -07:00
|
|
|
ok(!cw.Search.isEnabled(), "search is disabled");
|
2011-08-21 07:29:49 -07:00
|
|
|
|
|
|
|
enableSearch(function () {
|
|
|
|
cw.iQ("#searchbox").val("moz");
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
let searchAndSwitchPBMode = function (callback) {
|
|
|
|
prepareSearchbox(function () {
|
|
|
|
togglePrivateBrowsing(function () {
|
|
|
|
showTabView(function () {
|
2011-09-29 21:17:00 -07:00
|
|
|
ok(!cw.Search.isEnabled(), "search is disabled");
|
2011-08-21 07:29:49 -07:00
|
|
|
is(getSearchboxValue(), "", "search box is empty");
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
showTabView(function () {
|
|
|
|
cw = TabView.getContentWindow();
|
|
|
|
searchAndSwitchPBMode(function () {
|
|
|
|
searchAndSwitchPBMode(function () {
|
|
|
|
hideTabView(finish);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|