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" type="text/css"?> |
michael@0 | 4 | |
michael@0 | 5 | <window title="Autocomplete Widget Test 4" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 7 | onload="runTest();"> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" |
michael@0 | 10 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="chrome://global/content/globalOverlay.js"/> |
michael@0 | 15 | |
michael@0 | 16 | <textbox id="autocomplete" |
michael@0 | 17 | type="autocomplete" |
michael@0 | 18 | completedefaultindex="true" |
michael@0 | 19 | onsearchcomplete="searchComplete();" |
michael@0 | 20 | timeout="0" |
michael@0 | 21 | autocompletesearch="simple"/> |
michael@0 | 22 | |
michael@0 | 23 | <script class="testbody" type="application/javascript"> |
michael@0 | 24 | <![CDATA[ |
michael@0 | 25 | |
michael@0 | 26 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 27 | |
michael@0 | 28 | function autoCompleteSimpleResult(aString) { |
michael@0 | 29 | this.searchString = aString; |
michael@0 | 30 | this.searchResult = Components.interfaces.nsIAutoCompleteResult.RESULT_SUCCESS; |
michael@0 | 31 | this.matchCount = 1; |
michael@0 | 32 | this._param = "Result"; |
michael@0 | 33 | } |
michael@0 | 34 | autoCompleteSimpleResult.prototype = { |
michael@0 | 35 | _param: "", |
michael@0 | 36 | searchString: null, |
michael@0 | 37 | searchResult: Components.interfaces.nsIAutoCompleteResult.RESULT_FAILURE, |
michael@0 | 38 | defaultIndex: 0, |
michael@0 | 39 | errorDescription: null, |
michael@0 | 40 | matchCount: 0, |
michael@0 | 41 | getValueAt: function() { return this._param; }, |
michael@0 | 42 | getCommentAt: function() { return null; }, |
michael@0 | 43 | getStyleAt: function() { return null; }, |
michael@0 | 44 | getImageAt: function() { return null; }, |
michael@0 | 45 | getFinalCompleteValueAt: function() { return this.getValueAt(); }, |
michael@0 | 46 | getLabelAt: function() { return null; }, |
michael@0 | 47 | removeValueAt: function() {} |
michael@0 | 48 | }; |
michael@0 | 49 | |
michael@0 | 50 | // A basic autocomplete implementation that returns one result. |
michael@0 | 51 | let autoCompleteSimple = { |
michael@0 | 52 | classID: Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca"), |
michael@0 | 53 | contractID: "@mozilla.org/autocomplete/search;1?name=simple", |
michael@0 | 54 | QueryInterface: XPCOMUtils.generateQI([ |
michael@0 | 55 | Components.interfaces.nsIFactory, |
michael@0 | 56 | Components.interfaces.nsIAutoCompleteSearch |
michael@0 | 57 | ]), |
michael@0 | 58 | createInstance: function (outer, iid) { |
michael@0 | 59 | return this.QueryInterface(iid); |
michael@0 | 60 | }, |
michael@0 | 61 | |
michael@0 | 62 | registerFactory: function () { |
michael@0 | 63 | let registrar = |
michael@0 | 64 | Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); |
michael@0 | 65 | registrar.registerFactory(this.classID, "Test Simple Autocomplete", |
michael@0 | 66 | this.contractID, this); |
michael@0 | 67 | }, |
michael@0 | 68 | unregisterFactory: function () { |
michael@0 | 69 | let registrar = |
michael@0 | 70 | Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); |
michael@0 | 71 | registrar.unregisterFactory(this.classID, this); |
michael@0 | 72 | }, |
michael@0 | 73 | |
michael@0 | 74 | startSearch: function (aString, aParam, aResult, aListener) { |
michael@0 | 75 | let result = new autoCompleteSimpleResult(aString); |
michael@0 | 76 | aListener.onSearchResult(this, result); |
michael@0 | 77 | }, |
michael@0 | 78 | stopSearch: function () {} |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 82 | |
michael@0 | 83 | // XPFE AutoComplete needs to register early. |
michael@0 | 84 | autoCompleteSimple.registerFactory(); |
michael@0 | 85 | |
michael@0 | 86 | let gACTimer; |
michael@0 | 87 | let gAutoComplete; |
michael@0 | 88 | |
michael@0 | 89 | function searchComplete() { |
michael@0 | 90 | is(gAutoComplete.value, "result", "Value should be autocompleted now"); |
michael@0 | 91 | ok(Date.now() - gACTimer > 500, "There should be a delay before autocomplete"); |
michael@0 | 92 | |
michael@0 | 93 | // Unregister the factory so that we don't get in the way of other tests |
michael@0 | 94 | autoCompleteSimple.unregisterFactory(); |
michael@0 | 95 | SimpleTest.finish(); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | function runTest() { |
michael@0 | 99 | gAutoComplete = $("autocomplete"); |
michael@0 | 100 | |
michael@0 | 101 | const SEARCH_STRING = "res"; |
michael@0 | 102 | |
michael@0 | 103 | function cbCallback() { |
michael@0 | 104 | gAutoComplete.focus(); |
michael@0 | 105 | synthesizeKey("v", { accelKey: true }); |
michael@0 | 106 | is(gAutoComplete.value, SEARCH_STRING, "Value should not be autocompleted immediately"); |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | SimpleTest.waitForClipboard(SEARCH_STRING, function () { |
michael@0 | 110 | gACTimer = Date.now(); |
michael@0 | 111 | Components.classes["@mozilla.org/widget/clipboardhelper;1"] |
michael@0 | 112 | .getService(Components.interfaces.nsIClipboardHelper) |
michael@0 | 113 | .copyStringToClipboard(SEARCH_STRING, Components.interfaces.nsIClipboard.kGlobalClipboard, document); |
michael@0 | 114 | }, cbCallback, cbCallback); |
michael@0 | 115 | } |
michael@0 | 116 | ]]> |
michael@0 | 117 | </script> |
michael@0 | 118 | |
michael@0 | 119 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 120 | <p id="display"> |
michael@0 | 121 | </p> |
michael@0 | 122 | <div id="content" style="display: none"> |
michael@0 | 123 | </div> |
michael@0 | 124 | <pre id="test"> |
michael@0 | 125 | </pre> |
michael@0 | 126 | </body> |
michael@0 | 127 | |
michael@0 | 128 | </window> |