1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug468353.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=468353 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 468353</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468353">Mozilla Bug 468353</a> 1.16 +<p id="display"></p> 1.17 +<div id="content"> 1.18 + <iframe></iframe> 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script class="testbody" type="text/javascript"> 1.22 + 1.23 +var styleSheets = null; 1.24 + 1.25 +function checkStylesheets() { 1.26 + // Evidently RemoveStyleSheet is the only method in nsIEditorStyleSheets 1.27 + // that would throw. RemoveOverrideStyleSheet returns NS_OK even if the 1.28 + // sheet is not there 1.29 + var removed = 0; 1.30 + try 1.31 + { 1.32 + styleSheets.removeStyleSheet("resource://gre/res/designmode.css"); 1.33 + removed++; 1.34 + } 1.35 + catch (ex) { } 1.36 + 1.37 + try { 1.38 + styleSheets.removeStyleSheet("resource://gre/res/contenteditable.css"); 1.39 + removed++; 1.40 + } 1.41 + catch (ex) { } 1.42 + 1.43 + is(removed, 0, "Should have thrown if stylesheet was not there"); 1.44 +} 1.45 + 1.46 +function runTest() { 1.47 + const Ci = SpecialPowers.Ci; 1.48 + 1.49 + /** Found while fixing bug 440614 **/ 1.50 + var editframe = window.frames[0]; 1.51 + var editdoc = editframe.document; 1.52 + var editor = null; 1.53 + editdoc.write(''); 1.54 + editdoc.close(); 1.55 + 1.56 + editdoc.designMode='on'; 1.57 + 1.58 + // Hold the reference to the editor 1.59 + editor = SpecialPowers.wrap(editframe) 1.60 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.61 + .getInterface(Ci.nsIWebNavigation) 1.62 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.63 + .getInterface(Ci.nsIEditingSession) 1.64 + .getEditorForWindow(editframe); 1.65 + 1.66 + styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets); 1.67 + 1.68 + editdoc.designMode='off'; 1.69 + 1.70 + checkStylesheets(); 1.71 + 1.72 + // Let go 1.73 + editor = null; 1.74 + styleSheets = null; 1.75 + 1.76 + editdoc.body.contentEditable = true; 1.77 + 1.78 + // Hold the reference to the editor 1.79 + editor = SpecialPowers.wrap(editframe) 1.80 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.81 + .getInterface(Ci.nsIWebNavigation) 1.82 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.83 + .getInterface(Ci.nsIEditingSession) 1.84 + .getEditorForWindow(editframe); 1.85 + 1.86 + styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets); 1.87 + 1.88 + editdoc.body.contentEditable = false; 1.89 + 1.90 + checkStylesheets(); 1.91 + 1.92 + editdoc.designMode = "on"; 1.93 + editdoc.body.contentEditable = true; 1.94 + editdoc.designMode = "off"; 1.95 + 1.96 + // Hold the reference to the editor 1.97 + editor = SpecialPowers.wrap(editframe) 1.98 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.99 + .getInterface(Ci.nsIWebNavigation) 1.100 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.101 + .getInterface(Ci.nsIEditingSession) 1.102 + .getEditorForWindow(editframe); 1.103 + 1.104 + styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets); 1.105 + 1.106 + editdoc.body.contentEditable = false; 1.107 + 1.108 + checkStylesheets(); 1.109 + 1.110 + SimpleTest.finish(); 1.111 +} 1.112 + 1.113 +//XXX I don't know if this is necessary, but we're dealing with iframes... 1.114 +SimpleTest.waitForExplicitFinish(); 1.115 +addLoadEvent(runTest); 1.116 + 1.117 +</script> 1.118 +</pre> 1.119 +</body> 1.120 +</html>