b=518506 test no unnecessary invalidation of plugins with gtk2

This commit is contained in:
Karl Tomlinson 2009-12-14 15:32:46 +13:00
parent 8dc7c5e282
commit d4e82512c0
3 changed files with 197 additions and 3 deletions

View File

@ -55,7 +55,9 @@ endif
include $(topsrcdir)/config/rules.mk
_TEST_FILES = test_bug343416.xul \
_TEST_FILES =
_CHROME_FILES = test_bug343416.xul \
test_bug429954.xul \
window_bug429954.xul \
test_bug444800.xul \
@ -71,7 +73,7 @@ _TEST_FILES = test_bug343416.xul \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
_TEST_FILES += native_menus_window.xul \
_CHROME_FILES += native_menus_window.xul \
test_native_menus.xul \
native_mouse_mac_window.xul \
test_native_mouse_mac.xul \
@ -86,12 +88,23 @@ endif
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
ifneq ($(OS_ARCH), WINCE)
_TEST_FILES += taskbar_previews.xul \
_CHROME_FILES += taskbar_previews.xul \
window_state_windows.xul \
taskbar_progress.xul \
$(NULL)
endif
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
_TEST_FILES += plugin_scroll_invalidation.html \
test_plugin_scroll_invalidation.html \
$(NULL)
endif
ifdef _TEST_FILES
libs:: $(_TEST_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
endif
libs:: $(_CHROME_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)

View File

@ -0,0 +1,60 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test helper for plugin child widgets not being invalidated by scrolling</title>
<style>
body {
background: -moz-linear-gradient(top, red, black);
width: 200px;
height: 200px;
}
embed {
position:absolute;
}
embed#paint-waiter {
top: 0px;
left: 0px;
width: 0px;
height: 0px;
}
embed#e0 {
top: 70px;
left: 70px;
width: 10px;
height: 10px;
}
embed#e1 {
top: 60px;
left: 60px;
width: 10px;
height: 20px;
}
embed#e2 {
top: 60px;
left: 70px;
width: 20px;
height: 10px;
}
embed#e3 {
top: 70px;
left: 80px;
width: 10px;
height: 20px;
}
embed#e4 {
top: 80px;
left: 60px;
width: 20px;
height: 10px;
}
</style>
</head>
<body>
<embed id="paint-waiter" type="application/x-test" wmode="window">
<embed id="e0" type="application/x-test" wmode="window" class="scrolling"/>
<embed id="e1" type="application/x-test" wmode="window" class="scrolling"/>
<embed id="e2" type="application/x-test" wmode="window" class="scrolling"/>
<embed id="e3" type="application/x-test" wmode="window" class="scrolling"/>
<embed id="e4" type="application/x-test" wmode="window" class="scrolling"/>
</body>
</html>

View File

@ -0,0 +1,121 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for plugin child widgets not being invalidated by scrolling</title>
<script type="text/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="text/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body onload="initialize()">
<p id="display">
<iframe id="i" src="plugin_scroll_invalidation.html"
width="50" height="50" scrolling="no"></iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
var scrolling;
var scrolling_plugins = [];
var paint_waiter;
var last_paint_count;
function initialize() {
scrolling = document.getElementById("i").contentWindow;
scrolling_plugins = scrolling.document.querySelectorAll("embed.scrolling");
paint_waiter = scrolling.document.getElementById("paint-waiter");
// Plugins are not instantiated until after reflow
waitForPlugin(startTest);
}
function startTest() {
scrolling.scrollTo(50, 45);
is(paint_waiter.getPaintCount(), 0, "zero-sized plugin not painted");
waitForPaint(scrollAround);
}
function scrollAround() {
var paints = getPaintCounts();
for (var i = 0; i < paints.length; ++i) {
isnot(paints[i], 0, "embed " + scrolling_plugins[i].id + " is painted");
}
last_paint_count = sum(paints);
scrolling.scrollBy(-5, 5);
scrolling.scrollBy(5, 5);
scrolling.scrollBy(5, -5);
scrolling.scrollBy(-5, 5);
scrolling.scrollTo(45, 45);
scrolling.scrollBy(10, 0);
scrolling.scrollBy(0, 10);
scrolling.scrollBy(-10, 0);
scrolling.scrollBy(0, -10);
waitForPaint(done);
}
function done() {
is(sum(getPaintCounts()), last_paint_count, "no paint on scroll");
SimpleTest.finish();
}
function waitForPlugin(func) {
if (paint_waiter.getPaintCount) {
func();
return;
}
setTimeout(function() { waitForPlugin(func); }, 0);
}
function waitForPaint(func) {
paint_waiter.last_paint_count = paint_waiter.getPaintCount();
paint_waiter.style.left = scrolling.scrollX + "px";
paint_waiter.style.top = scrolling.scrollY + "px";
paint_waiter.style.width = "1px";
paint_waiter.style.height = "1px";
waitForPaintHelper(func);
}
function waitForPaintHelper(func) {
if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) {
// hide the paint waiter
paint_waiter.style.width = "0px";
paint_waiter.style.height = "0px";
setTimeout(func, 0);
return;
}
setTimeout(function() { waitForPaintHelper(func); }, 100);
}
function getPaintCounts() {
var result = [];
for (var i = 0; i < scrolling_plugins.length; ++i) {
result[i] = scrolling_plugins[i].getPaintCount();
}
return result;
}
function sum(array) {
var result = 0;
for (var i = 0; i < array.length; ++i) {
result += array[i];
}
return result;
}
</script>
</body>
</html>