toolkit/components/contentprefs/tests/unit/test_bug248970.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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 function run_test() {
michael@0 6 let loadContext = { get usePrivateBrowsing() { return gInPrivateBrowsing; } };
michael@0 7
michael@0 8 ContentPrefTest.deleteDatabase();
michael@0 9 var cp = new ContentPrefInstance(loadContext);
michael@0 10 do_check_neq(cp, null, "Retrieving the content prefs service failed");
michael@0 11
michael@0 12 try {
michael@0 13 const uri1 = ContentPrefTest.getURI("http://www.example.com/");
michael@0 14 const uri2 = ContentPrefTest.getURI("http://www.anotherexample.com/");
michael@0 15 const pref_name = "browser.content.full-zoom";
michael@0 16 const zoomA = 1.5, zoomA_new = 0.8, zoomB = 1.3;
michael@0 17 // save Zoom-A
michael@0 18 cp.setPref(uri1, pref_name, zoomA);
michael@0 19 // make sure Zoom-A is retrievable
michael@0 20 do_check_eq(cp.getPref(uri1, pref_name), zoomA);
michael@0 21 // enter private browsing mode
michael@0 22 enterPBMode();
michael@0 23 // make sure Zoom-A is retrievable
michael@0 24 do_check_eq(cp.getPref(uri1, pref_name), zoomA);
michael@0 25 // save Zoom-B
michael@0 26 cp.setPref(uri2, pref_name, zoomB);
michael@0 27 // make sure Zoom-B is retrievable
michael@0 28 do_check_eq(cp.getPref(uri2, pref_name), zoomB);
michael@0 29 // update Zoom-A
michael@0 30 cp.setPref(uri1, pref_name, zoomA_new);
michael@0 31 // make sure Zoom-A has changed
michael@0 32 do_check_eq(cp.getPref(uri1, pref_name), zoomA_new);
michael@0 33 // exit private browsing mode
michael@0 34 exitPBMode();
michael@0 35 // make sure Zoom-A change has not persisted
michael@0 36 do_check_eq(cp.getPref(uri1, pref_name), zoomA);
michael@0 37 // make sure Zoom-B change has not persisted
michael@0 38 do_check_eq(cp.hasPref(uri2, pref_name), false);
michael@0 39 } catch (e) {
michael@0 40 do_throw("Unexpected exception: " + e);
michael@0 41 }
michael@0 42 }

mercurial