/** * Given some nsIDOMWindow for a window running in the parent * process, return the nsIWebBrowserChrome chrome flags for * the associated XUL window. * * @param win (nsIDOMWindow) * Some window in the parent process. * @returns int
*/ function getParentChromeFlags(win) { return win.docShell.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIAppWindow).chromeFlags;
}
// If features isn't empty, the following should be true to open tab/window: // * location or toolbar (defaults to false) // * menubar (defaults to false) // * resizable (defaults to true) // * scrollbars (defaults to false) // * status (defaults to false)
{ features: "location,menubar,resizable,scrollbars,status", popup: false },
{ features: "toolbar,menubar,resizable,scrollbars,status", popup: false },
// The following testcases use "location,menubar,scrollbars,status" // as the base non-popup case, and test the boundary between popup // vs non-popup.
// If either location or toolbar is true, not popup.
{
features: "toolbar,menubar,resizable,scrollbars,status",
popup: false,
},
{
features: "location,menubar,resizable,scrollbars,status",
popup: false,
},
// If both location and toolbar are false, popup.
{ features: "menubar,scrollbars,status", popup: true },
// If menubar is false, popup.
{ features: "location,resizable,scrollbars,status", popup: true },
// If resizable is true, not popup.
{
features: "location,menubar,resizable=yes,scrollbars,status",
popup: false,
},
// If resizable is false, popup.
{ features: "location,menubar,resizable=0,scrollbars,status", popup: true },
// If scrollbars is false, popup.
{ features: "location,menubar,resizable,status", popup: true },
// If status is false, popup.
{ features: "location,menubar,resizable,scrollbars", popup: true },
// position and size have no effect.
{
features: "location,menubar,scrollbars,status," + "left=100,screenX=100,top=100,screenY=100," + "width=100,innerWidth=100,outerWidth=100," + "height=100,innerHeight=100,outerHeight=100",
popup: false,
},
// Most feature defaults to false if the feature is not empty. // Specifying only some of them opens a popup.
{ features: "location,toolbar,menubar", popup: true },
{ features: "resizable,scrollbars,status", popup: true },
// Specifying unknown feature makes the feature not empty.
{ features: "someunknownfeature", popup: true },
// noopener and noreferrer are removed before testing if feature is empty.
{ features: "noopener,noreferrer", popup: false },
];
for (const [name, visible] of Object.entries(flags)) { if (visible) { Assert.equal(
!!(parentChromeFlags & Ci.nsIWebBrowserChrome[name]), true,
`${name} should be present for features "${features}"`
);
} else { Assert.equal(
!!(parentChromeFlags & Ci.nsIWebBrowserChrome[name]), false,
`${name} should not be present for features "${features}"`
);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.