Add test for continuous firing of resize events. (Bug 114649)
authorL. David Baron <dbaron@dbaron.org>
Mon, 29 Sep 2008 15:57:41 -0700
changeset 19888 8f53fcb8bde5
parent 19887 8110e3bae4bf
child 19889 20af22e0eb6a
push id2518
push userdbaron@mozilla.com
push dateMon, 29 Sep 2008 22:58:27 +0000
treeherdermozilla-central@8f53fcb8bde5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs114649
milestone1.9.1b1pre
Add test for continuous firing of resize events. (Bug 114649)
layout/base/tests/Makefile.in
layout/base/tests/test_bug114649.html
--- a/layout/base/tests/Makefile.in
+++ b/layout/base/tests/Makefile.in
@@ -75,16 +75,17 @@ LIBS		+= \
 endif # false
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -D_IMPL_NS_LAYOUT
 
 _TEST_FILES =	\
 		test_bug66619.html \
+		test_bug114649.html \
 		test_bug386575.xhtml \
 		test_bug388019.html \
 		test_bug394057.html \
 		test_bug396024.html \
 		test_bug399284.html \
 		test_bug399951.html \
 		test_bug404209.xhtml \
 		test_bug416896.html \
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/test_bug114649.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=114649
+-->
+<head>
+  <title>Test for Bug 114649</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="run()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=114649">Mozilla Bug 114649</a>
+<iframe id="display" style="width: 500px; height: 500px;"></iframe>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 114649 **/
+
+var gIFrame;
+var gCurrentWidth = 500;
+var gGotEventsAt = [];
+var gInterval;
+
+function run() {
+    SimpleTest.waitForExplicitFinish();
+
+    gIFrame = document.getElementById("display");
+
+    var subdoc = gIFrame.contentDocument;
+    subdoc.open();
+    subdoc.write("<body onresize='window.parent.handle_child_resize()'>");
+    subdoc.close();
+
+    gInterval = window.setInterval(do_a_resize, 50);
+}
+
+function do_a_resize()
+{
+    // decrease the width by 10 until we hit 400, then stop
+    gCurrentWidth -= 10;
+    gIFrame.style.width = gCurrentWidth + "px";
+
+    if (gCurrentWidth == 400) {
+        window.clearInterval(gInterval);
+        window.setTimeout(check_for_resize_events, 250);
+        return;
+    }
+}
+
+function handle_child_resize()
+{
+    gGotEventsAt.push(gCurrentWidth);
+}
+
+function check_for_resize_events()
+{
+	ok(gGotEventsAt.length >= 2, "got continuous events");
+	isnot(gGotEventsAt[0], 400, "got continuous events");
+	is(gGotEventsAt[gGotEventsAt.length - 1], 400, "got last event");
+	SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>