Bug 409481 - XML Parsing error if you open a bookmark in the sidebar. r=gavin, a=mconnor
authorrflint@ryanflint.com
Sun, 23 Dec 2007 12:41:53 -0800
changeset 9642 cd16ef8893532ec687c0fc5c19c92f9378808766
parent 9641 923634370b14a9e68386466d1669fe87a61d6d96
child 9643 34887bbde40d19882f585220d4076aa2d78c793e
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)
reviewersgavin, mconnor
bugs409481
milestone1.9b3pre
Bug 409481 - XML Parsing error if you open a bookmark in the sidebar. r=gavin, a=mconnor
browser/base/content/test/Makefile.in
browser/base/content/test/browser_bug409481.js
browser/base/content/web-panels.xul
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -45,16 +45,17 @@ include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =	test_feed_discovery.html \
 		feed_discovery.html \
 		test_bug395533.html \
 		bug395533-data.txt \
 		$(NULL)
 
 _BROWSER_FILES = browser_bug321000.js \
+                 browser_bug409481.js \
                  browser_autodiscovery.js \
                  autodiscovery.html \
                  moz.png \
     $(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_bug409481.js
@@ -0,0 +1,37 @@
+function test() {
+  waitForExplicitFinish();
+
+  // XXX This looks a bit odd, but is needed to avoid throwing when removing the
+  // event listeners below. See bug 310955.
+  document.getElementById("sidebar").addEventListener("load", function() { setTimeout(openPanelUrl, 100) }, true);
+  toggleSidebar("viewWebPanelsSidebar", true);
+}
+
+function openPanelUrl(event) {
+  ok(!document.getElementById("sidebar-box").hidden, "Sidebar showing");
+
+  var sidebar = document.getElementById("sidebar");
+  var root = sidebar.contentDocument.documentElement;
+  ok(root.nodeName != "parsererror", "Sidebar is well formed");
+
+  sidebar.removeEventListener("load", openPanelUrl, true);
+  // XXX See comment above
+  sidebar.contentDocument.addEventListener("load", function() { setTimeout(runTest, 100) }, true);
+  var url = 'data:text/html,<div%20id="test_bug409481">Content!</div>';
+  sidebar.contentWindow.loadWebPanel(url);
+}
+
+function runTest(event) {
+  var sidebar = document.getElementById("sidebar");
+  sidebar.contentDocument.removeEventListener("load", runTest, true);
+
+  var browser = sidebar.contentDocument.getElementById("web-panels-browser");
+  var div = browser && browser.contentDocument.getElementById("test_bug409481");
+  ok(div && div.textContent == "Content!", "Sidebar content loaded");
+
+  toggleSidebar("viewWebPanelsSidebar");
+
+  ok(document.getElementById("sidebar-box").hidden, "Sidebar successfully hidden");
+
+  finish();
+}
--- a/browser/base/content/web-panels.xul
+++ b/browser/base/content/web-panels.xul
@@ -42,16 +42,18 @@
 <?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
 
 <!DOCTYPE page [
 <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
 %browserDTD;
 <!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd">
 %textcontextDTD;
+<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
+%globalDTD;
 ]>
 
 <page id="webpanels-window"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="load()" onunload="unload()">
   <script type="application/x-javascript" src="chrome://global/content/contentAreaUtils.js"/>
   <script type="application/x-javascript" src="chrome://browser/content/browser.js"/>