diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/plugins/test/mochitest/browser_bug1196539.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/plugins/test/mochitest/browser_bug1196539.js')
-rw-r--r-- | dom/plugins/test/mochitest/browser_bug1196539.js | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/dom/plugins/test/mochitest/browser_bug1196539.js b/dom/plugins/test/mochitest/browser_bug1196539.js new file mode 100644 index 000000000..8b2210ccd --- /dev/null +++ b/dom/plugins/test/mochitest/browser_bug1196539.js @@ -0,0 +1,119 @@ +var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); + +function checkPaintCount(aCount) { + ok(aCount != 0, "paint count can't be greater than zero, count was " + aCount); + ok(aCount < kMaxPaints, "paint count should be within limits, count was " + aCount); +} + +// maximum number of paints we allow before failing. The test plugin doesn't +// animate so this should really be just 1, but operating systems can +// occasionally fire a few of these so we give these tests a fudge factor. +// A bad regression would either be 0, or 100+. +const kMaxPaints = 10; + +add_task(function* () { + let result, tabSwitchedPromise; + + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in"); + + let testTab = gBrowser.selectedTab; + let pluginTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html"); + let homeTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home"); + + result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + return !!plugin; + }); + is(result, true, "plugin is loaded"); + + result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); + }); + is(result, true, "plugin is hidden"); + + // reset plugin paint count + yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + XPCNativeWrapper.unwrap(plugin).resetPaintCount(); + }); + + // select plugin tab + tabSwitchedPromise = waitTabSwitched(); + gBrowser.selectedTab = pluginTab; + yield tabSwitchedPromise; + + // wait a bit for spurious paints + yield waitForMs(100); + + result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); + }); + is(result, true, "plugin is visible"); + + // check for good paint count + result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + return XPCNativeWrapper.unwrap(plugin).getPaintCount(); + }); + checkPaintCount(result); + + // select home tab + tabSwitchedPromise = waitTabSwitched(); + gBrowser.selectedTab = homeTab; + yield tabSwitchedPromise; + + // reset paint count + yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + XPCNativeWrapper.unwrap(plugin).resetPaintCount(); + }); + + // wait a bit for spurious paints + yield waitForMs(100); + + // check for no paint count + result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + return XPCNativeWrapper.unwrap(plugin).getPaintCount(); + }); + is(result, 0, "no paints, this is correct."); + + result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); + }); + is(result, true, "plugin is hidden"); + + // reset paint count + yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + XPCNativeWrapper.unwrap(plugin).resetPaintCount(); + }); + + // select plugin tab + tabSwitchedPromise = waitTabSwitched(); + gBrowser.selectedTab = pluginTab; + yield tabSwitchedPromise; + + // check paint count + result = yield ContentTask.spawn(pluginTab.linkedBrowser, null, function*() { + let doc = content.document; + let plugin = doc.getElementById("testplugin"); + return XPCNativeWrapper.unwrap(plugin).getPaintCount(); + }); + checkPaintCount(result); + + gBrowser.removeTab(homeTab); + gBrowser.removeTab(pluginTab); +}); |