Bug 511487 - XSLT transformation fails with onload in FF3.6a1, r=peterv
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 16 Sep 2009 12:09:12 +0300
changeset 32526 38754465ffdea88becaef6eaecd61bacd0d8f716
parent 32525 b501121884dd0e6a8d6f79d4f5bcb034dc4a20e9
child 32527 5d22feabe471b170181c8881d33af8a8c0ba8984
push id9146
push useropettay@mozilla.com
push dateWed, 16 Sep 2009 09:36:16 +0000
treeherdermozilla-central@38754465ffde [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs511487
milestone1.9.3a1pre
Bug 511487 - XSLT transformation fails with onload in FF3.6a1, r=peterv
content/base/src/nsGenericElement.cpp
content/xslt/tests/mochitest/Makefile.in
content/xslt/tests/mochitest/test_bug511487.html
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -4276,17 +4276,19 @@ nsGenericElement::AddScriptEventListener
   NS_PRECONDITION(aEventName, "Must have event name!");
   nsCOMPtr<nsISupports> target;
   PRBool defer = PR_TRUE;
   nsCOMPtr<nsIEventListenerManager> manager;
 
   GetEventListenerManagerForAttr(getter_AddRefs(manager),
                                  getter_AddRefs(target),
                                  &defer);
-  NS_ENSURE_STATE(manager);
+  if (!manager) {
+    return NS_OK;
+  }
 
   defer = defer && aDefer; // only defer if everyone agrees...
   PRUint32 lang = GetScriptTypeID();
   return
     manager->AddScriptEventListener(target, aEventName, aValue, lang, defer,
                                     !nsContentUtils::IsChromeDoc(ownerDoc));
 }
 
--- a/content/xslt/tests/mochitest/Makefile.in
+++ b/content/xslt/tests/mochitest/Makefile.in
@@ -44,12 +44,13 @@ relativesrcdir  = content/xslt/tests/moc
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = 	test_bug319374.xhtml \
 		test_bug440974.html \
 		test_bug427060.html \
 		test_bug468208.html \
 		test_bug453441.html \
+		test_bug511487.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/content/xslt/tests/mochitest/test_bug511487.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=511487
+-->
+<head>
+  <title>Test for Bug 511487</title>
+  <script type="application/javascript" src="/MochiKit/packed.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>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511487">Mozilla Bug 511487</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 511487 **/
+
+  var didTransform = false;
+  var processor = new XSLTProcessor();
+  var style =
+    '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml">' +
+      '<xsl:output method="xml" version="1.0" encoding="UTF-8" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />' +
+      '<xsl:template match="wml">' +
+        '<html xmlns="http://www.w3.org/1999/xhtml">' +
+          '<head>' +
+              '<title>XSLT test</title>' +
+          '</head>' +
+          '<body onload="window.alert(this)">' +
+          '</body>' +
+        '</html>' +
+      '</xsl:template>' +
+    '</xsl:stylesheet>';
+  var styleDoc = new DOMParser().parseFromString (style, "text/xml");
+
+  var data =
+    '<?xml version="1.0"?>' + 
+    '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">' + 
+    '<wml><card><p>paragraph</p></card></wml>';
+  var originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+  processor.importStylesheet(styleDoc);
+  try {
+    var transformedDocument = processor.transformToDocument(originalDoc);
+    didTransform = true;
+  } catch (e) {
+    ok(false, e);
+  }
+
+  ok(didTransform, "transformToDocument didn't succeed!");
+
+
+</script>
+</pre>
+</body>
+</html>