Bug 1261963 - createData should be optional for browser.windows.create, r?aswan
MozReview-Commit-ID: GCPFx4kuH9r
--- a/browser/components/extensions/schemas/windows.json
+++ b/browser/components/extensions/schemas/windows.json
@@ -262,16 +262,18 @@
"name": "create",
"type": "function",
"description": "Creates (opens) a new browser with any optional sizing, position or default URL provided.",
"async": "callback",
"parameters": [
{
"type": "object",
"name": "createData",
+ "optional": true,
+ "default": {},
"properties": {
"url": {
"description": "A URL or array of URLs to open as tabs in the window. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page.",
"optional": true,
"choices": [
{ "type": "string", "format": "relativeUrl" },
{
"type": "array",
--- a/browser/components/extensions/test/browser/browser_ext_windows_create.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_create.js
@@ -18,17 +18,19 @@ add_task(function* testWindowCreate() {
function checkWindow(expected) {
return new Promise(resolve => {
_checkWindowPromise = {resolve};
browser.test.sendMessage("check-window", expected);
});
}
async function createWindow(params, expected, keep = false) {
- let window = await browser.windows.create(params);
+ let window = await browser.windows.create(...params);
+ // params is null when testing create without createData
+ params = params[0] || {};
for (let key of Object.keys(params)) {
if (key == "state" && os == "mac" && params.state == "normal") {
// OS-X doesn't have a hard distinction between "normal" and
// "maximized" states.
browser.test.assertTrue(window.state == "normal" || window.state == "maximized",
`Expected window.state (currently ${window.state}) to be "normal" but will accept "maximized"`);
} else {
@@ -49,23 +51,29 @@ add_task(function* testWindowCreate() {
await browser.windows.update(window.id, {state: "normal"});
}
await browser.windows.remove(window.id);
}
try {
({os} = await browser.runtime.getPlatformInfo());
- await createWindow({state: "maximized"}, {state: "STATE_MAXIMIZED"});
- await createWindow({state: "minimized"}, {state: "STATE_MINIMIZED"});
- await createWindow({state: "normal"}, {state: "STATE_NORMAL", hiddenChrome: []});
- await createWindow({state: "fullscreen"}, {state: "STATE_FULLSCREEN"});
+ // Set the current window to state: "normal" because the test is failing on Windows
+ // where the current window is maximized.
+ let currentWindow = await browser.windows.getCurrent();
+ await browser.windows.update(currentWindow.id, {state: "normal"});
+
+ await createWindow([], {state: "STATE_NORMAL"});
+ await createWindow([{state: "maximized"}], {state: "STATE_MAXIMIZED"});
+ await createWindow([{state: "minimized"}], {state: "STATE_MINIMIZED"});
+ await createWindow([{state: "normal"}], {state: "STATE_NORMAL", hiddenChrome: []});
+ await createWindow([{state: "fullscreen"}], {state: "STATE_FULLSCREEN"});
let window = await createWindow(
- {type: "popup"},
+ [{type: "popup"}],
{hiddenChrome: ["menubar", "toolbar", "location", "directories", "status", "extrachrome"],
chromeFlags: ["CHROME_OPENAS_DIALOG"]},
true);
let tabs = await browser.tabs.query({windowType: "popup", active: true});
browser.test.assertEq(1, tabs.length, "Expected only one popup");
browser.test.assertEq(window.id, tabs[0].windowId, "Expected new window to be returned in query");