Fix bug 392338. r=mrbkap, sr=jst, a=schrep
authorbzbarsky@mit.edu
Sun, 06 Jan 2008 14:07:25 -0800
changeset 9933 34d67d9baa4c34891a1b74de6f7d30a25b0a3a5b
parent 9932 ed8a27781493a3a00eab6acab643fd681f793afc
child 9934 e758408e8a71869a444de4d2af918686f291c8f2
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, jst, schrep
bugs392338
milestone1.9b3pre
Fix bug 392338. r=mrbkap, sr=jst, a=schrep
content/xml/document/test/Makefile.in
content/xml/document/test/test_bug392338.html
dom/src/base/nsDOMClassInfo.cpp
--- a/content/xml/document/test/Makefile.in
+++ b/content/xml/document/test/Makefile.in
@@ -42,13 +42,14 @@ VPATH		= @srcdir@
 relativesrcdir  = content/xml/document/test
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = 	test_bug232004.xhtml \
 		test_bug343870.xhtml \
 		test_bug355213.xhtml \
+		test_bug392338.html \
 		test_bug399502.xhtml \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/content/xml/document/test/test_bug392338.html
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=392338
+-->
+<head>
+  <title>Test for Bug 392338</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/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=392338">Mozilla Bug 392338</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 392338 **/
+function obs () {
+  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+  this.observerService = Components.classes["@mozilla.org/observer-service;1"]
+                                     .getService(Components.interfaces.nsIObserverService);
+  this.observerService.addObserver(this,"http-on-modify-request", false);
+  this.window = window;
+}
+
+obs.prototype = {
+  observe: function obs_observe (theSubject, theTopic, theData)
+  {
+    try{
+      this.window.netscape.security
+          .PrivilegeManager.enablePrivilege("UniversalXPConnect");
+      var ir = theSubject.QueryInterface(this.window.Components.interfaces
+                                             .nsIChannel).notificationCallbacks;
+      if (!(ir instanceof this.window.Components.interfaces.nsIDOMDocument)) {
+        return;
+      }
+
+      this.window.is(ir instanceof
+                       this.window.Components.interfaces.nsIInterfaceRequestor,
+                     true, "Must be an interface requestor");
+
+      var count = {};
+      var interfaces = ir.
+                   QueryInterface(this.window.Components
+                                      .interfaces.nsIClassInfo).
+                   getInterfaces(count).
+                   map(function(id) {
+                              return this.window.Components
+                                                .interfacesByID[id].toString();
+                       });
+      this.window.isnot(interfaces.indexOf("nsIInterfaceRequestor"), -1,
+                        "Must have interface requestor classinfo");
+    } catch(ex) {
+      this.window.is(true, false, "Exception thrown " + ex);
+    } finally {
+      this.remove();
+      this.window.SimpleTest.finish();
+      this.window = null;
+    }
+  },
+
+  remove: function obs_remove()
+  {
+    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+    this.observerService.removeObserver(this,"http-on-modify-request");
+    this.observerService = null;
+  }
+}
+
+var o;
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+  var doc = document.implementation.createDocument("", "", null);
+  o = new obs();
+  doc.load(window.location.href);
+});
+
+</script>
+</pre>
+</body>
+</html>
+
--- a/dom/src/base/nsDOMClassInfo.cpp
+++ b/dom/src/base/nsDOMClassInfo.cpp
@@ -1946,16 +1946,17 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(XMLDocument, nsIDOMXMLDocument)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXMLDocument)
+    DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
     DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(DocumentType, nsIDOMDocumentType)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentType)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
   DOM_CLASSINFO_MAP_END