editor/libeditor/html/tests/test_bug468353.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial