michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function run_test() { michael@0: let loadContext = { get usePrivateBrowsing() { return gInPrivateBrowsing; } }; michael@0: michael@0: ContentPrefTest.deleteDatabase(); michael@0: var cp = new ContentPrefInstance(loadContext); michael@0: do_check_neq(cp, null, "Retrieving the content prefs service failed"); michael@0: michael@0: try { michael@0: const uri1 = ContentPrefTest.getURI("http://www.example.com/"); michael@0: const uri2 = ContentPrefTest.getURI("http://www.anotherexample.com/"); michael@0: const pref_name = "browser.content.full-zoom"; michael@0: const zoomA = 1.5, zoomA_new = 0.8, zoomB = 1.3; michael@0: // save Zoom-A michael@0: cp.setPref(uri1, pref_name, zoomA); michael@0: // make sure Zoom-A is retrievable michael@0: do_check_eq(cp.getPref(uri1, pref_name), zoomA); michael@0: // enter private browsing mode michael@0: enterPBMode(); michael@0: // make sure Zoom-A is retrievable michael@0: do_check_eq(cp.getPref(uri1, pref_name), zoomA); michael@0: // save Zoom-B michael@0: cp.setPref(uri2, pref_name, zoomB); michael@0: // make sure Zoom-B is retrievable michael@0: do_check_eq(cp.getPref(uri2, pref_name), zoomB); michael@0: // update Zoom-A michael@0: cp.setPref(uri1, pref_name, zoomA_new); michael@0: // make sure Zoom-A has changed michael@0: do_check_eq(cp.getPref(uri1, pref_name), zoomA_new); michael@0: // exit private browsing mode michael@0: exitPBMode(); michael@0: // make sure Zoom-A change has not persisted michael@0: do_check_eq(cp.getPref(uri1, pref_name), zoomA); michael@0: // make sure Zoom-B change has not persisted michael@0: do_check_eq(cp.hasPref(uri2, pref_name), false); michael@0: } catch (e) { michael@0: do_throw("Unexpected exception: " + e); michael@0: } michael@0: }