editor/libeditor/html/tests/test_bug468353.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=468353
     5 -->
     6 <head>
     7   <title>Test for Bug 468353</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468353">Mozilla Bug 468353</a>
    13 <p id="display"></p>
    14 <div id="content">
    15   <iframe></iframe>
    16 </div>
    17 <pre id="test">
    18 <script class="testbody" type="text/javascript">
    20 var styleSheets = null;
    22 function checkStylesheets() {
    23   // Evidently RemoveStyleSheet is the only method in nsIEditorStyleSheets
    24   // that would throw. RemoveOverrideStyleSheet returns NS_OK even if the
    25   // sheet is not there
    26   var removed = 0;
    27   try
    28   {
    29     styleSheets.removeStyleSheet("resource://gre/res/designmode.css");
    30     removed++;
    31   }
    32   catch (ex) { }
    34   try {
    35     styleSheets.removeStyleSheet("resource://gre/res/contenteditable.css");
    36     removed++;
    37   }
    38   catch (ex) { }
    40   is(removed, 0, "Should have thrown if stylesheet was not there");
    41 }
    43 function runTest() {
    44   const Ci = SpecialPowers.Ci;
    46   /** Found while fixing bug 440614 **/
    47   var editframe = window.frames[0];
    48   var editdoc = editframe.document;
    49   var editor = null;
    50   editdoc.write('');
    51   editdoc.close();
    53   editdoc.designMode='on';
    55   // Hold the reference to the editor
    56   editor = SpecialPowers.wrap(editframe)
    57                         .QueryInterface(Ci.nsIInterfaceRequestor)
    58                         .getInterface(Ci.nsIWebNavigation)
    59                         .QueryInterface(Ci.nsIInterfaceRequestor)
    60                         .getInterface(Ci.nsIEditingSession)
    61                         .getEditorForWindow(editframe);
    63   styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
    65   editdoc.designMode='off';
    67   checkStylesheets();
    69   // Let go
    70   editor = null;
    71   styleSheets = null;
    73   editdoc.body.contentEditable = true;
    75   // Hold the reference to the editor
    76   editor = SpecialPowers.wrap(editframe)
    77                         .QueryInterface(Ci.nsIInterfaceRequestor)
    78                         .getInterface(Ci.nsIWebNavigation)
    79                         .QueryInterface(Ci.nsIInterfaceRequestor)
    80                         .getInterface(Ci.nsIEditingSession)
    81                         .getEditorForWindow(editframe);
    83   styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
    85   editdoc.body.contentEditable = false;
    87   checkStylesheets();
    89   editdoc.designMode = "on";
    90   editdoc.body.contentEditable = true;
    91   editdoc.designMode = "off";
    93   // Hold the reference to the editor
    94   editor = SpecialPowers.wrap(editframe)
    95                         .QueryInterface(Ci.nsIInterfaceRequestor)
    96                         .getInterface(Ci.nsIWebNavigation)
    97                         .QueryInterface(Ci.nsIInterfaceRequestor)
    98                         .getInterface(Ci.nsIEditingSession)
    99                         .getEditorForWindow(editframe);
   101   styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
   103   editdoc.body.contentEditable = false;
   105   checkStylesheets();
   107   SimpleTest.finish();
   108 }
   110 //XXX I don't know if this is necessary, but we're dealing with iframes...
   111 SimpleTest.waitForExplicitFinish();
   112 addLoadEvent(runTest);
   114 </script>
   115 </pre>
   116 </body>
   117 </html>

mercurial