summaryrefslogtreecommitdiffstats
path: root/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js')
-rw-r--r--browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
new file mode 100644
index 0000000000..4a7ec8f2b7
--- /dev/null
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
@@ -0,0 +1,79 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+loadTestSubscript("head_browserAction.js");
+
+add_task(async function testBrowserActionPopupResize() {
+ let extension = ExtensionTestUtils.loadExtension({
+ manifest: {
+ browser_action: {
+ default_popup: "popup.html",
+ default_area: "navbar",
+ browser_style: true,
+ },
+ },
+
+ files: {
+ "popup.html":
+ '<!DOCTYPE html><html><head><meta charset="utf-8"></head></html>',
+ },
+ });
+
+ await extension.startup();
+
+ let browser = await openBrowserActionPanel(extension, undefined, true);
+
+ async function checkSize(expected) {
+ let dims = await promiseContentDimensions(browser);
+
+ Assert.lessOrEqual(
+ Math.abs(dims.window.innerHeight - expected),
+ 1,
+ `Panel window should be ${expected}px tall (was ${dims.window.innerHeight})`
+ );
+ is(
+ dims.body.clientHeight,
+ dims.body.scrollHeight,
+ "Panel body should be tall enough to fit its contents"
+ );
+
+ // Tolerate if it is 1px too wide, as that may happen with the current resizing method.
+ Assert.lessOrEqual(
+ Math.abs(dims.window.innerWidth - expected),
+ 1,
+ `Panel window should be ${expected}px wide`
+ );
+ is(
+ dims.body.clientWidth,
+ dims.body.scrollWidth,
+ "Panel body should be wide enough to fit its contents"
+ );
+ }
+
+ function setSize(size) {
+ content.document.body.style.height = `${size}px`;
+ content.document.body.style.width = `${size}px`;
+ }
+
+ let sizes = [200, 400, 300];
+
+ for (let size of sizes) {
+ await alterContent(browser, setSize, size);
+ await checkSize(size);
+ }
+
+ let popup = getBrowserActionPopup(extension);
+ await closeBrowserAction(extension);
+ is(popup.state, "closed", "browserAction popup has been closed");
+
+ await extension.unload();
+});
+
+add_task(async function testBrowserActionMenuResizeStandards() {
+ await testPopupSize(true);
+});
+
+add_task(async function testBrowserActionMenuResizeQuirks() {
+ await testPopupSize(false);
+});