browser/base/content/test/general/browser_bug409624.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 XPCOMUtils.defineLazyModuleGetter(this, "FormHistory",
michael@0 6 "resource://gre/modules/FormHistory.jsm");
michael@0 7
michael@0 8 function test() {
michael@0 9 waitForExplicitFinish();
michael@0 10
michael@0 11 // This test relies on the form history being empty to start with delete
michael@0 12 // all the items first.
michael@0 13 FormHistory.update({ op: "remove" },
michael@0 14 { handleError: function (error) {
michael@0 15 do_throw("Error occurred updating form history: " + error);
michael@0 16 },
michael@0 17 handleCompletion: function (reason) { if (!reason) test2(); },
michael@0 18 });
michael@0 19 }
michael@0 20
michael@0 21 function test2()
michael@0 22 {
michael@0 23 let prefService = Cc["@mozilla.org/preferences-service;1"]
michael@0 24 .getService(Components.interfaces.nsIPrefBranch2);
michael@0 25
michael@0 26 let findBar = gFindBar;
michael@0 27 let textbox = gFindBar.getElement("findbar-textbox");
michael@0 28
michael@0 29 let tempScope = {};
michael@0 30 Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
michael@0 31 .loadSubScript("chrome://browser/content/sanitize.js", tempScope);
michael@0 32 let Sanitizer = tempScope.Sanitizer;
michael@0 33 let s = new Sanitizer();
michael@0 34 s.prefDomain = "privacy.cpd.";
michael@0 35 let prefBranch = prefService.getBranch(s.prefDomain);
michael@0 36
michael@0 37 prefBranch.setBoolPref("cache", false);
michael@0 38 prefBranch.setBoolPref("cookies", false);
michael@0 39 prefBranch.setBoolPref("downloads", false);
michael@0 40 prefBranch.setBoolPref("formdata", true);
michael@0 41 prefBranch.setBoolPref("history", false);
michael@0 42 prefBranch.setBoolPref("offlineApps", false);
michael@0 43 prefBranch.setBoolPref("passwords", false);
michael@0 44 prefBranch.setBoolPref("sessions", false);
michael@0 45 prefBranch.setBoolPref("siteSettings", false);
michael@0 46
michael@0 47 // Sanitize now so we can test that canClear is correct. Formdata is cleared asynchronously.
michael@0 48 s.sanitize().then(function() {
michael@0 49 s.canClearItem("formdata", clearDone1, s);
michael@0 50 });
michael@0 51 }
michael@0 52
michael@0 53 function clearDone1(aItemName, aResult, aSanitizer)
michael@0 54 {
michael@0 55 ok(!aResult, "pre-test baseline for sanitizer");
michael@0 56 gFindBar.getElement("findbar-textbox").value = "m";
michael@0 57 aSanitizer.canClearItem("formdata", inputEntered, aSanitizer);
michael@0 58 }
michael@0 59
michael@0 60 function inputEntered(aItemName, aResult, aSanitizer)
michael@0 61 {
michael@0 62 ok(aResult, "formdata can be cleared after input");
michael@0 63 aSanitizer.sanitize().then(function() {
michael@0 64 aSanitizer.canClearItem("formdata", clearDone2);
michael@0 65 });
michael@0 66 }
michael@0 67
michael@0 68 function clearDone2(aItemName, aResult)
michael@0 69 {
michael@0 70 is(gFindBar.getElement("findbar-textbox").value, "", "findBar textbox should be empty after sanitize");
michael@0 71 ok(!aResult, "canClear now false after sanitize");
michael@0 72 finish();
michael@0 73 }

mercurial