This commit is contained in:
Ryan VanderMeulen 2012-07-07 10:06:52 -04:00
Родитель ff823ab950 4a6576672e
Коммит d25eaaf52d
22 изменённых файлов: 184 добавлений и 113 удалений

Просмотреть файл

@ -11,12 +11,12 @@ function test() {
var newWindow;
var tabToDetach;
var documentToDetach;
function onPageShow(event) {
// we get here if the test is executed before the pageshow
// event for the window's first tab
if (!tabToDetach ||
tabToDetach.linkedBrowser.contentDocument != event.target)
if (!tabToDetach || documentToDetach != event.target)
return;
event.currentTarget.removeEventListener("pageshow", onPageShow, false);
@ -46,6 +46,10 @@ function test() {
finish();
}
gBrowser.addEventListener("pageshow", onPageShow, false);
tabToDetach = gBrowser.addTab(testPage);
tabToDetach.linkedBrowser.addEventListener("load", function onLoad() {
tabToDetach.linkedBrowser.removeEventListener("load", onLoad, true);
documentToDetach = tabToDetach.linkedBrowser.contentDocument;
gBrowser.addEventListener("pageshow", onPageShow, false);
}, true);
}

Просмотреть файл

@ -9,7 +9,7 @@
function runTests() {
// we remove sites and expect the gaps to be filled as long as there still
// are some sites available
setLinks("0,1,2,3,4,5,6,7,8,9");
yield setLinks("0,1,2,3,4,5,6,7,8,9");
setPinnedLinks("");
yield addNewTabPageTab();
@ -26,7 +26,7 @@ function runTests() {
// we removed a pinned site
yield restore();
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",1");
yield addNewTabPageTab();
@ -38,7 +38,7 @@ function runTests() {
// we remove the last site on the grid (which is pinned) and expect the gap
// to be re-filled and the new site to be unpinned
yield restore();
setLinks("0,1,2,3,4,5,6,7,8,9");
yield setLinks("0,1,2,3,4,5,6,7,8,9");
setPinnedLinks(",,,,,,,,8");
yield addNewTabPageTab();
@ -50,7 +50,7 @@ function runTests() {
// we remove the first site on the grid with the last one pinned. all cells
// but the last one should shift to the left and a new site fades in
yield restore();
setLinks("0,1,2,3,4,5,6,7,8,9");
yield setLinks("0,1,2,3,4,5,6,7,8,9");
setPinnedLinks(",,,,,,,,8");
yield addNewTabPageTab();

Просмотреть файл

@ -2,19 +2,19 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
function runTests() {
setLinks("0,1,2,3,4,5,6,7,8");
NewTabUtils.pinnedLinks._links = [
{url: "about:blank#7", title: ""},
{url: "about:blank#8", title: "title"},
{url: "about:blank#9", title: "about:blank#9"}
];
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks([
{url: "http://example.com/#7", title: ""},
{url: "http://example.com/#8", title: "title"},
{url: "http://example.com/#9", title: "http://example.com/#9"}
]);
yield addNewTabPageTab();
checkGrid("7p,8p,9p,0,1,2,3,4,5");
checkTooltip(0, "about:blank#7", "1st tooltip is correct");
checkTooltip(1, "title\nabout:blank#8", "2nd tooltip is correct");
checkTooltip(2, "about:blank#9", "3rd tooltip is correct");
checkTooltip(0, "http://example.com/#7", "1st tooltip is correct");
checkTooltip(1, "title\nhttp://example.com/#8", "2nd tooltip is correct");
checkTooltip(2, "http://example.com/#9", "3rd tooltip is correct");
}
function checkTooltip(aIndex, aExpected, aMessage) {

Просмотреть файл

@ -5,30 +5,26 @@ const NOW = Date.now() * 1000;
const URL = "http://fake-site.com/";
let tmp = {};
Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://browser/content/sanitize.js", tmp);
let {NewTabUtils, Sanitizer} = tmp;
let bhist = Cc["@mozilla.org/browser/global-history;2"]
.getService(Ci.nsIBrowserHistory);
let {Sanitizer} = tmp;
function runTests() {
clearHistory();
yield fillHistory();
sanitizeHistory();
yield addFakeVisits();
yield addNewTabPageTab();
is(getCell(0).site.url, URL, "first site is our fake site");
whenPagesUpdated();
yield clearHistory();
yield sanitizeHistory();
ok(!getCell(0).site, "the fake site is gone");
}
function fillHistory() {
function addFakeVisits() {
let visits = [];
for (let i = 59; i > 0; i--) {
visits.push({
@ -42,13 +38,18 @@ function fillHistory() {
visits: visits
};
PlacesUtils.asyncHistory.updatePlaces(place, {
handleError: function () do_throw("Unexpected error in adding visit."),
handleResult: function () { },
handleCompletion: function () TestRunner.next()
handleError: function () ok(false, "couldn't add visit"),
handleResult: function () {},
handleCompletion: function () {
NewTabUtils.links.populateCache(function () {
NewTabUtils.allPages.update();
TestRunner.next();
}, true);
}
});
}
function clearHistory() {
function sanitizeHistory() {
let s = new Sanitizer();
s.prefDomain = "privacy.cpd.";

Просмотреть файл

@ -3,7 +3,7 @@
function runTests() {
// create a new tab page and hide it.
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();
@ -12,7 +12,7 @@ function runTests() {
yield addNewTabPageTab();
gBrowser.removeTab(firstTab);
ok(NewTabUtils.allPages.enabled, true, "page is enabled");
ok(NewTabUtils.allPages.enabled, "page is enabled");
NewTabUtils.allPages.enabled = false;
ok(getGrid().node.hasAttribute("page-disabled"), "page is disabled");
}

Просмотреть файл

@ -2,7 +2,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
function runTests() {
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();

Просмотреть файл

@ -2,7 +2,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
function runTests() {
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();
@ -10,14 +10,14 @@ function runTests() {
let cell = getCell(0).node;
sendDragEvent("drop", cell, "about:blank#99\nblank");
is(NewTabUtils.pinnedLinks.links[0].url, "about:blank#99",
sendDragEvent("drop", cell, "http://example.com/#99\nblank");
is(NewTabUtils.pinnedLinks.links[0].url, "http://example.com/#99",
"first cell is pinned and contains the dropped site");
yield whenPagesUpdated();
checkGrid("99p,0,1,2,3,4,5,6,7");
sendDragEvent("drop", cell, "");
is(NewTabUtils.pinnedLinks.links[0].url, "about:blank#99",
is(NewTabUtils.pinnedLinks.links[0].url, "http://example.com/#99",
"first cell is still pinned with the site we dropped before");
}

Просмотреть файл

@ -2,7 +2,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
function runTests() {
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();

Просмотреть файл

@ -2,7 +2,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
function runTests() {
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();

Просмотреть файл

@ -7,7 +7,7 @@
*/
function runTests() {
// create a new tab page and hide it.
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();

Просмотреть файл

@ -9,7 +9,7 @@
*/
function runTests() {
// test a simple drag-and-drop scenario
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();
@ -19,7 +19,7 @@ function runTests() {
checkGrid("1,0p,2,3,4,5,6,7,8");
// drag a cell to its current cell and make sure it's not pinned afterwards
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();
@ -29,7 +29,7 @@ function runTests() {
checkGrid("0,1,2,3,4,5,6,7,8");
// ensure that pinned pages aren't moved if that's not necessary
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",1,2");
yield addNewTabPageTab();
@ -40,7 +40,7 @@ function runTests() {
// pinned sites should always be moved around as blocks. if a pinned site is
// moved around, neighboring pinned are affected as well
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("0,1");
yield addNewTabPageTab();
@ -51,7 +51,7 @@ function runTests() {
// pinned sites should not be pushed out of the grid (unless there are only
// pinned ones left on the grid)
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",,,,,,,7,8");
yield addNewTabPageTab();
@ -61,7 +61,7 @@ function runTests() {
checkGrid("0,1,3,4,5,6,7p,8p,2p");
// make sure that pinned sites are re-positioned correctly
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("0,1,2,,,5");
yield addNewTabPageTab();
@ -71,7 +71,7 @@ function runTests() {
checkGrid("3,1p,2p,4,0p,5p,6,7,8");
// drag a new site onto the very first cell
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",,,,,,,7,8");
yield addNewTabPageTab();
@ -82,7 +82,7 @@ function runTests() {
// drag a new site onto the grid and make sure that pinned cells don't get
// pushed out
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",,,,,,,7,8");
yield addNewTabPageTab();
@ -93,7 +93,7 @@ function runTests() {
// drag a new site beneath a pinned cell and make sure the pinned cell is
// not moved
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",,,,,,,,8");
yield addNewTabPageTab();
@ -104,7 +104,7 @@ function runTests() {
// drag a new site onto a block of pinned sites and make sure they're shifted
// around accordingly
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("0,1,2,,,,,,");
yield addNewTabPageTab();

Просмотреть файл

@ -7,7 +7,7 @@
*/
function runTests() {
// the first three sites are pinned - make sure they're re-arranged correctly
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("0,1,2,,,5");
yield addNewTabPageTab();

Просмотреть файл

@ -15,8 +15,9 @@ function runTests() {
}
// Create a new tab page.
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();
gURLBar.focus();
@ -51,4 +52,4 @@ function countFocus(aExpectedCount) {
}, true);
document.commandDispatcher.advanceFocus();
}
}

Просмотреть файл

@ -12,7 +12,7 @@ let pb = Cc["@mozilla.org/privatebrowsing;1"]
function runTests() {
// prepare the grid
setLinks("0,1,2,3,4,5,6,7,8,9");
yield setLinks("0,1,2,3,4,5,6,7,8,9");
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
yield addNewTabPageTab();

Просмотреть файл

@ -9,7 +9,7 @@ function runTests() {
return;
// create a new tab page and check its modified state after blocking a site
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks("");
yield addNewTabPageTab();

Просмотреть файл

@ -11,7 +11,7 @@ function runTests() {
// Disabled until bug 716543 is fixed.
return;
setLinks("0,1,2,3,4,5,6,7,8,9");
yield setLinks("0,1,2,3,4,5,6,7,8,9");
setPinnedLinks(",1");
yield addNewTabPageTab();

Просмотреть файл

@ -8,7 +8,7 @@
function runTests() {
// we have a pinned link that didn't change its position since it was pinned.
// nothing should happend when we unpin it.
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",1");
yield addNewTabPageTab();
@ -20,7 +20,7 @@ function runTests() {
// we have a pinned link that is not anymore in the list of the most-visited
// links. this should disappear, the remaining links adjust their positions
// and a new link will appear at the end of the grid.
setLinks("0,1,2,3,4,5,6,7,8");
yield setLinks("0,1,2,3,4,5,6,7,8");
setPinnedLinks(",99");
yield addNewTabPageTab();
@ -31,7 +31,7 @@ function runTests() {
// we have a pinned link that changed its position since it was pinned. it
// should be moved to its new position after being unpinned.
setLinks("0,1,2,3,4,5,6,7");
yield setLinks("0,1,2,3,4,5,6,7");
setPinnedLinks(",1,,,,,,,0");
yield addNewTabPageTab();
@ -45,7 +45,7 @@ function runTests() {
// we have pinned link that changed its position since it was pinned. the
// link will disappear from the grid because it's now a much lower priority
setLinks("0,1,2,3,4,5,6,7,8,9");
yield setLinks("0,1,2,3,4,5,6,7,8,9");
setPinnedLinks("9");
yield addNewTabPageTab();

Просмотреть файл

@ -7,7 +7,17 @@ Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, true);
let tmp = {};
Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
let NewTabUtils = tmp.NewTabUtils;
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://browser/content/sanitize.js", tmp);
let {NewTabUtils, Sanitizer} = tmp;
let uri = Services.io.newURI("about:newtab", null, null);
let principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
let sm = Services.domStorageManager;
let storage = sm.getLocalStorageForPrincipal(principal, "");
registerCleanupFunction(function () {
while (gBrowser.tabs.length > 1)
@ -16,11 +26,6 @@ registerCleanupFunction(function () {
Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
});
/**
* We'll want to restore the original links provider later.
*/
let originalProvider = NewTabUtils.links._provider;
/**
* Provide the default test function to start our test runner.
*/
@ -58,9 +63,7 @@ let TestRunner = {
*/
finish: function () {
function cleanupAndFinish() {
// Restore the old provider.
NewTabUtils.links._provider = originalProvider;
clearHistory();
whenPagesUpdated(finish);
NewTabUtils.restore();
}
@ -113,17 +116,52 @@ function getCell(aIndex) {
* @param aLinksPattern the pattern (see below)
*
* Example: setLinks("1,2,3")
* Result: [{url: "about:blank#1", title: "site#1"},
* {url: "about:blank#2", title: "site#2"}
* {url: "about:blank#3", title: "site#3"}]
* Result: [{url: "http://example.com/#1", title: "site#1"},
* {url: "http://example.com/#2", title: "site#2"}
* {url: "http://example.com/#3", title: "site#3"}]
*/
function setLinks(aLinksPattern) {
let links = aLinksPattern.split(/\s*,\s*/).map(function (id) {
return {url: "about:blank#" + id, title: "site#" + id};
});
function setLinks(aLinks) {
let links = aLinks;
NewTabUtils.links._provider = {getLinks: function (c) c(links)};
NewTabUtils.links._links = links;
if (typeof links == "string") {
links = aLinks.split(/\s*,\s*/).map(function (id) {
return {url: "http://example.com/#" + id, title: "site#" + id};
});
}
clearHistory();
fillHistory(links, function () {
NewTabUtils.links.populateCache(function () {
NewTabUtils.allPages.update();
TestRunner.next();
}, true);
});
}
function clearHistory() {
PlacesUtils.history.removeAllPages();
}
function fillHistory(aLinks, aCallback) {
let numLinks = aLinks.length;
let transitionLink = Ci.nsINavHistoryService.TRANSITION_LINK;
for (let link of aLinks.reverse()) {
let place = {
uri: makeURI(link.url),
title: link.title,
visits: [{visitDate: Date.now() * 1000, transitionType: transitionLink}]
};
PlacesUtils.asyncHistory.updatePlaces(place, {
handleError: function () ok(false, "couldn't add visit to history"),
handleResult: function () {},
handleCompletion: function () {
if (--numLinks == 0)
aCallback();
}
});
}
}
/**
@ -132,23 +170,22 @@ function setLinks(aLinksPattern) {
* @param aLinksPattern the pattern (see below)
*
* Example: setPinnedLinks("3,,1")
* Result: 'about:blank#3' is pinned in the first cell. 'about:blank#1' is
* Result: 'http://example.com/#3' is pinned in the first cell. 'http://example.com/#1' is
* pinned in the third cell.
*/
function setPinnedLinks(aLinksPattern) {
let pinnedLinks = [];
function setPinnedLinks(aLinks) {
let links = aLinks;
aLinksPattern.split(/\s*,\s*/).forEach(function (id, index) {
let link;
if (typeof links == "string") {
links = aLinks.split(/\s*,\s*/).map(function (id) {
if (id)
return {url: "http://example.com/#" + id, title: "site#" + id};
});
}
if (id)
link = {url: "about:blank#" + id, title: "site#" + id};
pinnedLinks[index] = link;
});
// Inject the list of pinned links to work with.
NewTabUtils.pinnedLinks._links = pinnedLinks;
storage.setItem("pinnedLinks", JSON.stringify(links));
NewTabUtils.pinnedLinks.resetCache();
NewTabUtils.allPages.update();
}
/**
@ -187,9 +224,9 @@ function addNewTabPageTab() {
* @param the array of sites to compare with (optional)
*
* Example: checkGrid("3p,2,,1p")
* Result: We expect the first cell to contain the pinned site 'about:blank#3'.
* The second cell contains 'about:blank#2'. The third cell is empty.
* The fourth cell contains the pinned site 'about:blank#4'.
* Result: We expect the first cell to contain the pinned site 'http://example.com/#3'.
* The second cell contains 'http://example.com/#2'. The third cell is empty.
* The fourth cell contains the pinned site 'http://example.com/#4'.
*/
function checkGrid(aSitesPattern, aSites) {
let length = aSitesPattern.split(",").length;
@ -205,7 +242,7 @@ function checkGrid(aSitesPattern, aSites) {
if (pinned != hasPinnedAttr)
ok(false, "invalid state (site.isPinned() != site[pinned])");
return aSite.url.replace(/^about:blank#(\d+)$/, "$1") + (pinned ? "p" : "");
return aSite.url.replace(/^http:\/\/example\.com\/#(\d+)$/, "$1") + (pinned ? "p" : "");
});
is(current, aSitesPattern, "grid status = " + aSitesPattern);
@ -246,7 +283,7 @@ function unpinCell(aIndex) {
function simulateDrop(aDropIndex, aDragIndex) {
let draggedSite;
let {gDrag: drag, gDrop: drop} = getContentWindow();
let event = createDragEvent("drop", "about:blank#99\nblank");
let event = createDragEvent("drop", "http://example.com/#99\nblank");
if (typeof aDragIndex != "undefined")
draggedSite = getCell(aDragIndex).site;

Просмотреть файл

@ -38,7 +38,7 @@ class Emulator(object):
deviceRe = re.compile(r"^emulator-(\d+)(\s*)(.*)$")
def __init__(self, homedir=None, noWindow=False, logcat_dir=None, arch="x86",
emulatorBinary=None, userdata=None):
emulatorBinary=None, res='480x800', userdata=None):
self.port = None
self._emulator_launched = False
self.proc = None
@ -50,6 +50,7 @@ class Emulator(object):
self.logcat_proc = None
self.arch = arch
self.binary = emulatorBinary
self.res = res
self.battery = EmulatorBattery(self)
self.homedir = homedir
self.noWindow = noWindow
@ -131,7 +132,7 @@ class Emulator(object):
qemuArgs.extend(['-memory', '512',
'-partition-size', '512',
'-verbose',
'-skin', '480x800',
'-skin', self.res,
'-qemu'] + self.tail_args)
return qemuArgs

Просмотреть файл

@ -71,8 +71,9 @@ class Marionette(object):
CONTEXT_CONTENT = 'content'
def __init__(self, host='localhost', port=2828, bin=None, profile=None,
emulator=None, emulatorBinary=None, connectToRunningEmulator=False,
homedir=None, baseurl=None, noWindow=False, logcat_dir=None):
emulator=None, emulatorBinary=None, emulator_res='480x800',
connectToRunningEmulator=False, homedir=None, baseurl=None,
noWindow=False, logcat_dir=None):
self.host = host
self.port = self.local_port = port
self.bin = bin
@ -96,7 +97,8 @@ class Marionette(object):
noWindow=self.noWindow,
logcat_dir=self.logcat_dir,
arch=emulator,
emulatorBinary=emulatorBinary)
emulatorBinary=emulatorBinary,
res=emulator_res)
self.emulator.start()
self.port = self.emulator.setup_port_forwarding(self.port)
assert(self.emulator.wait_for_port())

Просмотреть файл

@ -21,7 +21,7 @@ try:
from mozhttpd import iface, MozHttpd
except ImportError:
print "manifestparser or mozhttpd not found! Please install mozbase:\n"
print "\tgit clone git clone git://github.com/mozilla/mozbase.git"
print "\tgit clone git://github.com/mozilla/mozbase.git"
print "\tpython setup_development.py\n"
import sys
sys.exit(1)
@ -144,13 +144,15 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
class MarionetteTestRunner(object):
def __init__(self, address=None, emulator=None, emulatorBinary=None, homedir=None,
bin=None, profile=None, autolog=False, revision=None, es_server=None,
def __init__(self, address=None, emulator=None, emulatorBinary=None,
emulator_res='480x800', homedir=None, bin=None, profile=None,
autolog=False, revision=None, es_server=None,
rest_server=None, logger=None, testgroup="marionette",
noWindow=False, logcat_dir=None):
self.address = address
self.emulator = emulator
self.emulatorBinary = emulatorBinary
self.emulator_res = emulator_res
self.homedir = homedir
self.bin = bin
self.profile = profile
@ -224,6 +226,7 @@ class MarionetteTestRunner(object):
elif self.emulator:
self.marionette = Marionette(emulator=self.emulator,
emulatorBinary=self.emulatorBinary,
emulator_res=self.emulator_res,
homedir=self.homedir,
baseurl=self.baseurl,
noWindow=self.noWindow,
@ -418,6 +421,11 @@ if __name__ == "__main__":
default = None,
help = "Launch a specific emulator binary rather than "
"launching from the B2G built emulator")
parser.add_option('--emulator-res',
action = 'store', dest = 'emulator_res',
default = '480x800', type= 'str',
help = 'Set a custom resolution for the emulator. '
'Example: "480x800"')
parser.add_option("--no-window",
action = "store_true", dest = "noWindow",
default = False,
@ -469,9 +477,21 @@ if __name__ == "__main__":
if options.emulator and not options.logcat_dir:
options.logcat_dir = 'logcat'
# check for valid resolution string, strip whitespaces
try:
dims = options.emulator_res.split('x')
assert len(dims) == 2
width = str(int(dims[0]))
height = str(int(dims[1]))
res = 'x'.join([width, height])
except:
raise ValueError('Invalid emulator resolution format. '
'Should be like "480x800".\n')
runner = MarionetteTestRunner(address=options.address,
emulator=options.emulator,
emulatorBinary=options.emulatorBinary,
emulator_res=res,
homedir=options.homedir,
logcat_dir=options.logcat_dir,
bin=options.bin,

Просмотреть файл

@ -1141,16 +1141,6 @@
// are swapped.
var fieldsToSwap = [ "_docShell", "_webBrowserFind", "_contentWindow", "_webNavigation"];
var ourTabBrowser = this.getTabBrowser();
// _fastFind is tied to the docshell if we don't have a tabbrowser
if ((ourTabBrowser != null) !=
(aOtherBrowser.getTabBrowser() != null))
throw "Unable to perform swap on <browsers> if one is in a <tabbrowser> and one is not";
if (!ourTabBrowser)
fieldsToSwap.push("_fastFind");
var ourFieldValues = {};
var otherFieldValues = {};
for each (var field in fieldsToSwap) {
@ -1159,10 +1149,25 @@
}
this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
.swapFrameLoaders(aOtherBrowser);
// Before we swap the actual docShell property we need to detach the
// form fill controller from those docShells.
this.detachFormFill();
aOtherBrowser.detachFormFill();
for each (var field in fieldsToSwap) {
this[field] = otherFieldValues[field];
aOtherBrowser[field] = ourFieldValues[field];
}
// Re-attach the docShells to the form fill controller.
this.attachFormFill();
aOtherBrowser.attachFormFill();
// Null the current nsITypeAheadFind instances so that they're
// lazily re-created on access. We need to do this because they
// might have attached the wrong docShell.
this._fastFind = aOtherBrowser._fastFind = null;
]]>
</body>
</method>