diff --git a/browser/base/content/browser-plugins.js b/browser/base/content/browser-plugins.js index 730d2cfdc7f..0918bc70008 100644 --- a/browser/base/content/browser-plugins.js +++ b/browser/base/content/browser-plugins.js @@ -106,8 +106,8 @@ var gPluginHandler = { let pluginRect = plugin.getBoundingClientRect(); // XXX bug 446693. The text-shadow on the submitted-report text at // the bottom causes scrollHeight to be larger than it should be. - let overflows = (overlay.scrollWidth > pluginRect.width) || - (overlay.scrollHeight - 5 > pluginRect.height); + let overflows = (overlay.scrollWidth > Math.ceil(pluginRect.width)) || + (overlay.scrollHeight - 5 > Math.ceil(pluginRect.height)); if (overflows) { return false; } diff --git a/browser/base/content/test/plugins/browser.ini b/browser/base/content/test/plugins/browser.ini index 51f6ec9459c..cf659134768 100644 --- a/browser/base/content/test/plugins/browser.ini +++ b/browser/base/content/test/plugins/browser.ini @@ -40,6 +40,7 @@ support-files = plugin_two_types.html plugin_unknown.html plugin_crashCommentAndURL.html + plugin_zoom.html [browser_bug743421.js] [browser_bug744745.js] @@ -62,6 +63,7 @@ run-if = crashreporter [browser_CTP_notificationBar.js] [browser_CTP_outsideScrollArea.js] [browser_CTP_resize.js] +[browser_CTP_zoom.js] [browser_globalplugin_crashinfobar.js] [browser_pageInfo_plugins.js] [browser_pluginnotification.js] diff --git a/browser/base/content/test/plugins/browser_CTP_zoom.js b/browser/base/content/test/plugins/browser_CTP_zoom.js new file mode 100644 index 00000000000..6d351786ac9 --- /dev/null +++ b/browser/base/content/test/plugins/browser_CTP_zoom.js @@ -0,0 +1,77 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +let rootDir = getRootDirectory(gTestPath); +const gTestRoot = rootDir; +const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", + "http://127.0.0.1:8888/"); + +let gTestBrowser = null; + +Components.utils.import("resource://gre/modules/Services.jsm"); + +function test() { + waitForExplicitFinish(); + registerCleanupFunction(() => { + FullZoom.reset(); + clearAllPluginPermissions(); + Services.prefs.clearUserPref("extensions.blocklist.suppressUI"); + }); + Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true); + + Services.prefs.setBoolPref("plugins.click_to_play", true); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); + + let newTab = gBrowser.addTab(); + gBrowser.selectedTab = newTab; + gTestBrowser = gBrowser.selectedBrowser; + gTestBrowser.addEventListener("load", pageLoad, true); + gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_zoom.html" +} + +function finishTest() { + clearAllPluginPermissions(); + gTestBrowser.removeEventListener("load", pageLoad, true); + gBrowser.removeCurrentTab(); + window.focus(); + finish(); +} + +function pageLoad() { + // Due to layout being async, "PluginBindAttached" may trigger later. + // This wraps a function to force a layout flush, thus triggering it, + // and schedules the function execution so they're definitely executed + // afterwards. + let doc = gTestBrowser.contentDocument; + let elems = doc.getElementsByTagName('embed'); + if (elems.length < 1) { + elems = doc.getElementsByTagName('object'); + } + elems[0].clientTop; + executeSoon(testOverlay); +} + +let enlargeCount = 4; + +// Enlarges the zoom level |enlargeCount| times and tests that the overlay is +// visible after each enlargement. +function testOverlay() { + let plugin = gTestBrowser.contentDocument.getElementById("test"); + let doc = gTestBrowser.contentDocument; + let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); + ok(overlay, "Overlay should exist"); + ok(overlay.classList.contains("visible"), "Overlay should be visible"); + + if (enlargeCount > 0) { + --enlargeCount; + FullZoom.enlarge(); + gTestBrowser.contentWindow.location.reload(); + } else { + FullZoom.reset(); + clearAllPluginPermissions(); + finishTest(); + } +} diff --git a/browser/base/content/test/plugins/plugin_zoom.html b/browser/base/content/test/plugins/plugin_zoom.html new file mode 100644 index 00000000000..f9e5986581f --- /dev/null +++ b/browser/base/content/test/plugins/plugin_zoom.html @@ -0,0 +1,10 @@ + + + + + + + + + +