Sat, 03 Jan 2015 20:18:00 +0100
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 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 4 | type="text/css"?> |
michael@0 | 5 | <window title="Testing autocomplete with composition" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
michael@0 | 10 | <script type="application/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> |
michael@0 | 12 | <script type="text/javascript" |
michael@0 | 13 | src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js" /> |
michael@0 | 14 | <script type="text/javascript" |
michael@0 | 15 | src="file_autocomplete_with_composition.js" /> |
michael@0 | 16 | |
michael@0 | 17 | <textbox id="textbox" type="autocomplete" |
michael@0 | 18 | autocompletesearch="simpleForComposition"/> |
michael@0 | 19 | |
michael@0 | 20 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 21 | <div id="content" style="display: none"> |
michael@0 | 22 | </div> |
michael@0 | 23 | <pre id="test"> |
michael@0 | 24 | </pre> |
michael@0 | 25 | </body> |
michael@0 | 26 | |
michael@0 | 27 | <script class="testbody" type="application/javascript"> |
michael@0 | 28 | <![CDATA[ |
michael@0 | 29 | |
michael@0 | 30 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 31 | |
michael@0 | 32 | const nsIAutoCompleteResult = Components.interfaces.nsIAutoCompleteResult; |
michael@0 | 33 | |
michael@0 | 34 | // This result can't be constructed in-line, because otherwise we leak memory. |
michael@0 | 35 | function nsAutoCompleteSimpleResult(aString) |
michael@0 | 36 | { |
michael@0 | 37 | this.searchString = aString; |
michael@0 | 38 | if (aString == "" || aString == "Mozilla".substr(0, aString.length)) { |
michael@0 | 39 | this.searchResult = nsIAutoCompleteResult.RESULT_SUCCESS; |
michael@0 | 40 | this.matchCount = 1; |
michael@0 | 41 | this._value = "Mozilla"; |
michael@0 | 42 | } else { |
michael@0 | 43 | this.searchResult = nsIAutoCompleteResult.RESULT_NOMATCH; |
michael@0 | 44 | this.matchCount = 0; |
michael@0 | 45 | this._value = ""; |
michael@0 | 46 | } |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | nsAutoCompleteSimpleResult.prototype = { |
michael@0 | 50 | _value: "", |
michael@0 | 51 | searchString: null, |
michael@0 | 52 | searchResult: nsIAutoCompleteResult.RESULT_FAILURE, |
michael@0 | 53 | defaultIndex: 0, |
michael@0 | 54 | errorDescription: null, |
michael@0 | 55 | matchCount: 0, |
michael@0 | 56 | getValueAt: function(aIndex) { return aIndex == 0 ? this._value : null; }, |
michael@0 | 57 | getCommentAt: function() { return null; }, |
michael@0 | 58 | getStyleAt: function() { return null; }, |
michael@0 | 59 | getImageAt: function() { return null; }, |
michael@0 | 60 | getFinalCompleteValueAt: function(aIndex) { return this.getValueAt(aIndex); }, |
michael@0 | 61 | getLabelAt: function() { return null; }, |
michael@0 | 62 | removeValueAt: function() {} |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | // A basic autocomplete implementation that either returns one result or none |
michael@0 | 66 | var autoCompleteSimpleID = |
michael@0 | 67 | Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca"); |
michael@0 | 68 | var autoCompleteSimpleName = |
michael@0 | 69 | "@mozilla.org/autocomplete/search;1?name=simpleForComposition" |
michael@0 | 70 | var autoCompleteSimple = { |
michael@0 | 71 | QueryInterface: function(iid) { |
michael@0 | 72 | if (iid.equals(Components.interfaces.nsISupports) || |
michael@0 | 73 | iid.equals(Components.interfaces.nsIFactory) || |
michael@0 | 74 | iid.equals(Components.interfaces.nsIAutoCompleteSearch)) |
michael@0 | 75 | return this; |
michael@0 | 76 | |
michael@0 | 77 | throw Components.results.NS_ERROR_NO_INTERFACE; |
michael@0 | 78 | }, |
michael@0 | 79 | |
michael@0 | 80 | createInstance: function(outer, iid) { |
michael@0 | 81 | return this.QueryInterface(iid); |
michael@0 | 82 | }, |
michael@0 | 83 | |
michael@0 | 84 | startSearch: function(aString, aParam, aResult, aListener) { |
michael@0 | 85 | var result = new nsAutoCompleteSimpleResult(aString); |
michael@0 | 86 | aListener.onSearchResult(this, result); |
michael@0 | 87 | }, |
michael@0 | 88 | |
michael@0 | 89 | stopSearch: function() {} |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | var componentManager = |
michael@0 | 93 | Components.manager |
michael@0 | 94 | .QueryInterface(Components.interfaces.nsIComponentRegistrar); |
michael@0 | 95 | componentManager.registerFactory(autoCompleteSimpleID, |
michael@0 | 96 | "Test Simple Autocomplete for composition", |
michael@0 | 97 | autoCompleteSimpleName, autoCompleteSimple); |
michael@0 | 98 | |
michael@0 | 99 | function runTests() |
michael@0 | 100 | { |
michael@0 | 101 | var target = document.getElementById("textbox"); |
michael@0 | 102 | target.setAttribute("timeout", 1); |
michael@0 | 103 | var test1 = new nsDoTestsForAutoCompleteWithComposition( |
michael@0 | 104 | "Testing on XUL textbox (asynchronously search)", |
michael@0 | 105 | window, target, target.controller, is, |
michael@0 | 106 | function () { return target.value; }, |
michael@0 | 107 | function () { |
michael@0 | 108 | target.setAttribute("timeout", 0); |
michael@0 | 109 | var test2 = new nsDoTestsForAutoCompleteWithComposition( |
michael@0 | 110 | "Testing on XUL textbox (synchronously search)", |
michael@0 | 111 | window, target, target.controller, is, |
michael@0 | 112 | function () { return target.value; }, |
michael@0 | 113 | function () { |
michael@0 | 114 | // Unregister the factory so that we don't get in the way of other |
michael@0 | 115 | // tests |
michael@0 | 116 | componentManager.unregisterFactory(autoCompleteSimpleID, |
michael@0 | 117 | autoCompleteSimple); |
michael@0 | 118 | SimpleTest.finish(); |
michael@0 | 119 | }); |
michael@0 | 120 | }); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | SimpleTest.waitForFocus(runTests); |
michael@0 | 124 | ]]> |
michael@0 | 125 | </script> |
michael@0 | 126 | </window> |