1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug409624.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +XPCOMUtils.defineLazyModuleGetter(this, "FormHistory", 1.9 + "resource://gre/modules/FormHistory.jsm"); 1.10 + 1.11 +function test() { 1.12 + waitForExplicitFinish(); 1.13 + 1.14 + // This test relies on the form history being empty to start with delete 1.15 + // all the items first. 1.16 + FormHistory.update({ op: "remove" }, 1.17 + { handleError: function (error) { 1.18 + do_throw("Error occurred updating form history: " + error); 1.19 + }, 1.20 + handleCompletion: function (reason) { if (!reason) test2(); }, 1.21 + }); 1.22 +} 1.23 + 1.24 +function test2() 1.25 +{ 1.26 + let prefService = Cc["@mozilla.org/preferences-service;1"] 1.27 + .getService(Components.interfaces.nsIPrefBranch2); 1.28 + 1.29 + let findBar = gFindBar; 1.30 + let textbox = gFindBar.getElement("findbar-textbox"); 1.31 + 1.32 + let tempScope = {}; 1.33 + Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader) 1.34 + .loadSubScript("chrome://browser/content/sanitize.js", tempScope); 1.35 + let Sanitizer = tempScope.Sanitizer; 1.36 + let s = new Sanitizer(); 1.37 + s.prefDomain = "privacy.cpd."; 1.38 + let prefBranch = prefService.getBranch(s.prefDomain); 1.39 + 1.40 + prefBranch.setBoolPref("cache", false); 1.41 + prefBranch.setBoolPref("cookies", false); 1.42 + prefBranch.setBoolPref("downloads", false); 1.43 + prefBranch.setBoolPref("formdata", true); 1.44 + prefBranch.setBoolPref("history", false); 1.45 + prefBranch.setBoolPref("offlineApps", false); 1.46 + prefBranch.setBoolPref("passwords", false); 1.47 + prefBranch.setBoolPref("sessions", false); 1.48 + prefBranch.setBoolPref("siteSettings", false); 1.49 + 1.50 + // Sanitize now so we can test that canClear is correct. Formdata is cleared asynchronously. 1.51 + s.sanitize().then(function() { 1.52 + s.canClearItem("formdata", clearDone1, s); 1.53 + }); 1.54 +} 1.55 + 1.56 +function clearDone1(aItemName, aResult, aSanitizer) 1.57 +{ 1.58 + ok(!aResult, "pre-test baseline for sanitizer"); 1.59 + gFindBar.getElement("findbar-textbox").value = "m"; 1.60 + aSanitizer.canClearItem("formdata", inputEntered, aSanitizer); 1.61 +} 1.62 + 1.63 +function inputEntered(aItemName, aResult, aSanitizer) 1.64 +{ 1.65 + ok(aResult, "formdata can be cleared after input"); 1.66 + aSanitizer.sanitize().then(function() { 1.67 + aSanitizer.canClearItem("formdata", clearDone2); 1.68 + }); 1.69 +} 1.70 + 1.71 +function clearDone2(aItemName, aResult) 1.72 +{ 1.73 + is(gFindBar.getElement("findbar-textbox").value, "", "findBar textbox should be empty after sanitize"); 1.74 + ok(!aResult, "canClear now false after sanitize"); 1.75 + finish(); 1.76 +}