Bug 1288228 part 3: Add regression mochitest for this bug. r?jwatt
MozReview-Commit-ID: DOqPoTLU1MZ
--- a/dom/svg/test/mochitest.ini
+++ b/dom/svg/test/mochitest.ini
@@ -82,16 +82,18 @@ skip-if = android_version == '18' # bug
[test_SVGStringList.xhtml]
[test_SVGStyleElement.xhtml]
[test_SVGTransformListAddition.xhtml]
[test_SVGTransformList.xhtml]
[test_SVGUnitTypes.html]
[test_SVGxxxListIndexing.xhtml]
[test_SVGxxxList.xhtml]
[test_switch.xhtml]
+[test_tearoff_with_cc.html]
+support-files = tearoff_with_cc_helper.html
[test_text_2.html]
[test_text_dirty.html]
[test_text.html]
[test_text_lengthAdjust.html]
[test_text_scaled.html]
[test_text_selection.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' # b2g(Mouse selection not workin on b2g) b2g-debug(Mouse selection not workin on b2g) b2g-desktop(Mouse selection not workin on b2g)
[test_text_update.html]
new file mode 100644
--- /dev/null
+++ b/dom/svg/test/tearoff_with_cc_helper.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<body onload="go()">
+ <svg id="outerSvg" width="50%" height="50%"
+ style="border: 1px solid black">
+ </svg>
+ <script type="application/javascript">
+ /* I'm not sure what exactly was required to trigger bug 1288228's crash,
+ * but it involved tweaking a length's specified units and cycle-collecting
+ * and reloading (in some combination). So, we'll tweak the units and
+ * cycle-collect a few times, and message the outer page to reload us
+ * after we've made the first tweak.
+ */
+ const maxTweaks = 5;
+ let remainingTweaks = maxTweaks;
+
+ var savedBaseVal = document.getElementById("outerSvg").width.baseVal;
+ function go() {
+ window.parent.SpecialPowers.DOMWindowUtils.cycleCollect();
+ tweak();
+ }
+
+ function tweak() {
+ console.log("tweaked");
+ savedBaseVal.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX);
+ savedBaseVal.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PERCENTAGE);
+ if (remainingTweaks == maxTweaks) {
+ window.parent.postMessage("ping", "*"); // only do this on first tweak
+ }
+ if (--remainingTweaks) {
+ setTimeout(tweak, 0);
+ }
+ }
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/svg/test/test_tearoff_with_cc.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1288228
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1288228</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+ /** Test for Bug 1288228 **/
+ /* Note: the crash in bug 1288228 doesn't happen reliably (and only happens
+ * after several reloads). So, we reload the iframe 10 times, and then call
+ * it good if we haven't crashed.
+ */
+ const maxReloads = 10;
+ let remainingReloads = maxReloads;
+
+ /* The helper-file in the iframe will notify us after it's performed its
+ * potentially-crash-triggering tweak. At that point, we reload the iframe
+ * and wait for it to notify again (or we simply finish, if we've completed
+ * all of the reloads we planned to do).
+ */
+ window.addEventListener("message", reloadIframe, false);
+
+ function reloadIframe() {
+ if (--remainingReloads == 0) {
+ ok(true, "Didn't crash!");
+ SimpleTest.finish();
+ } else {
+ var frame = document.getElementById("testIframe");
+ frame.setAttribute("src", "");
+ frame.setAttribute("src", "tearoff_with_cc_helper.html");
+ }
+ }
+ SimpleTest.waitForExplicitFinish();
+ </script>
+</head>
+<body onload="reloadIframe()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1288228">
+ Mozilla Bug 1288228
+</a>
+<p id="display">
+ <iframe id="testIframe"></iframe>
+</p>
+</body>
+</html>