Test for Bug 796179 - Errors in files with large data URIs can cause the error console to consume gigabytes of memory and lock up the browser. r=rcampbell
authorSeth Fowler <seth@mozilla.com>
Mon, 12 Nov 2012 11:50:09 -0800
changeset 113008 fc53121e1685eb9dfd07197c12cd3c22be52c15d
parent 113007 a557ce61d622e955d3a0981661b3bd57859cd25a
child 113009 30df269639f0d4e270657e1e614d5f984d5d69c6
push id23847
push userphilringnalda@gmail.com
push dateTue, 13 Nov 2012 05:07:25 +0000
treeherdermozilla-central@1b0226622e94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell
bugs796179
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Test for Bug 796179 - Errors in files with large data URIs can cause the error console to consume gigabytes of memory and lock up the browser. r=rcampbell
toolkit/components/console/Makefile.in
toolkit/components/console/tests/Makefile.in
toolkit/components/console/tests/test_hugeURIs.xul
--- a/toolkit/components/console/Makefile.in
+++ b/toolkit/components/console/Makefile.in
@@ -10,9 +10,11 @@ VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 EXTRA_COMPONENTS = \
   jsconsole-clhandler.js \
   jsconsole-clhandler.manifest \
   $(NULL)
 
+TEST_DIRS = tests
+
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/toolkit/components/console/tests/Makefile.in
@@ -0,0 +1,18 @@
+#
+# 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/.
+
+DEPTH		= @DEPTH@
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+relativesrcdir  = @relativesrcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MOCHITEST_CHROME_FILES	= \
+		test_hugeURIs.xul \
+		$(NULL)
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/toolkit/components/console/tests/test_hugeURIs.xul
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=796179
+-->
+<window title="Mozilla Bug 796179"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        onload="RunTest();">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+  <!-- Detect severe performance and memory issues when large amounts of errors
+       are reported from CSS embedded in a file with a long data URI. Addressed
+       by 786108 for issues internal to the style system and by 796179 for issues
+       related to the error console. This error console test should finish quickly
+       with those patches and run for a very long time or OOM otherwise. -->
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+    <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=796179"
+      target="_blank">Mozilla Bug 796179</a>
+    <div id="badSVG" style="max-width: 1; max-height: 1; overflow: hidden"></div>
+  </body>
+
+  <!-- display the error console so we can test its reaction to the test -->
+  <iframe id="errorConsoleFrame"  height="400" src="chrome://global/content/console.xul"></iframe>
+
+  <!-- test code -->
+  <script type="application/javascript">
+  <![CDATA[
+    function RunTest()
+    {
+      // Create the bad SVG and add it to the document.
+      var img = new Array;
+      img.push('<img src="data:image/svg+xml,');
+      img.push(encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="300px" height="300px">'));
+
+      for (var i = 0 ; i < 10000 ; i++)
+        img.push(encodeURIComponent('<circle cx="0" cy="0" r="1" style="xxx-invalid-property: 0;"/>'));
+
+      img.push(encodeURIComponent('</svg>'));
+      img.push('" />');
+
+      document.getElementById('badSVG').innerHTML = img.join('');
+
+      // We yield control of the thread, allowing the error console to render.
+      // If we get control back without timing out or OOMing then the test passed.
+      SimpleTest.waitForExplicitFinish();
+      SimpleTest.executeSoon(function() {
+                               // Clean up.
+                               var elem = document.getElementById('errorConsoleFrame');
+                               elem.parentNode.removeChild(elem);
+                               elem = document.getElementById('badSVG');
+                               elem.parentNode.removeChild(elem);
+                               elem = null;
+
+                               // Finish the test with a pass.
+                               ok(true, 'Error console rendered OK.');
+                               SimpleTest.finish();
+                             }, 0);
+    }
+  ]]>
+  </script>
+</window>