bug 1273146 - populate tabs in windows.create() return value r=kmag

MozReview-Commit-ID: 5dnnSdXrsaJ

--HG--
extra : rebase_source : 5cc49e83ed070b9c96dc7855ff3f612045a44647
This commit is contained in:
Tomislav Jovanovic 2016-10-09 02:11:25 +02:00
Родитель 74303f6a71
Коммит e06eb7dfd0
3 изменённых файлов: 16 добавлений и 14 удалений

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

@ -160,20 +160,16 @@ extensions.registerSchemaAPI("windows", "addon_parent", context => {
return new Promise(resolve => {
window.addEventListener("load", function listener() {
window.removeEventListener("load", listener);
if (createData.state == "maximized" || createData.state == "normal" ||
(createData.state == "fullscreen" && AppConstants.platform != "macosx")) {
if (["maximized", "normal"].includes(createData.state)) {
window.document.documentElement.setAttribute("sizemode", createData.state);
} else if (createData.state !== null) {
// window.minimize() has no effect until the window has been shown.
return promiseObserved("document-shown", doc => doc == window.document).then(() => {
WindowManager.setState(window, createData.state);
resolve();
});
}
resolve();
resolve(promiseObserved("browser-delayed-startup-finished", win => win == window));
});
}).then(() => {
// Some states only work after delayed-startup-finished
if (["minimized", "fullscreen", "docked"].includes(createData.state)) {
WindowManager.setState(window, createData.state);
}
if (allowScriptsToClose) {
for (let {linkedBrowser} of window.gBrowser.tabs) {
onXULFrameLoaderCreated({target: linkedBrowser});
@ -181,7 +177,7 @@ extensions.registerSchemaAPI("windows", "addon_parent", context => {
"XULFrameLoaderCreated", onXULFrameLoaderCreated);
}
}
return WindowManager.convert(extension, window);
return WindowManager.convert(extension, window, {populate: true});
});
},

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

@ -35,6 +35,7 @@ add_task(function* testWindowCreate() {
}
}
browser.test.assertEq(1, window.tabs.length, "tabs property got populated");
return checkWindow(expected).then(() => {
if (keep) {
return window;

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

@ -24,13 +24,14 @@ add_task(function* testWindowCreate() {
});
};
let windowId;
let windowId, tabId;
browser.windows.getCurrent().then(window => {
windowId = window.id;
browser.test.log("Create additional tab in window 1");
return browser.tabs.create({windowId, url: "about:blank"});
}).then(tab => {
tabId = tab.id;
browser.test.log("Create a new window, adopting the new tab");
// Note that we want to check against actual boolean values for
@ -39,10 +40,11 @@ add_task(function* testWindowCreate() {
return Promise.all([
promiseTabAttached(),
browser.windows.create({tabId: tab.id}),
browser.windows.create({tabId: tabId}),
]);
}).then(([, window]) => {
browser.test.assertEq(false, window.incognito, "New window is not private");
browser.test.assertEq(tabId, window.tabs[0].id, "tabs property populated correctly");
browser.test.log("Close the new window");
return browser.windows.remove(window.id);
@ -113,6 +115,10 @@ add_task(function* testWindowCreate() {
return browser.windows.create({url: ["http://example.com/", "http://example.org/"]});
}).then(window => {
browser.test.assertEq(2, window.tabs.length, "2 tabs were opened in new window");
browser.test.assertEq("about:blank", window.tabs[0].url, "about:blank, page not loaded yet");
browser.test.assertEq("about:blank", window.tabs[1].url, "about:blank, page not loaded yet");
return Promise.all([
promiseTabUpdated("http://example.com/"),
promiseTabUpdated("http://example.org/"),
@ -145,4 +151,3 @@ add_task(function* testWindowCreate() {
yield extension.awaitFinish("window-create");
yield extension.unload();
});