test_locked_prefs.js (1144B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 // Locked status should be communicated to children. 6 7 function isParentProcess() { 8 return Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; 9 } 10 11 function run_test() { 12 const pb = Services.prefs; 13 14 let bprefname = "Test.IPC.locked.bool"; 15 let iprefname = "Test.IPC.locked.int"; 16 let sprefname = "Test.IPC.locked.string"; 17 18 let isParent = isParentProcess(); 19 if (isParent) { 20 pb.setBoolPref(bprefname, true); 21 pb.lockPref(bprefname); 22 23 pb.setIntPref(iprefname, true); 24 pb.lockPref(iprefname); 25 26 pb.setStringPref(sprefname, true); 27 pb.lockPref(sprefname); 28 pb.unlockPref(sprefname); 29 30 run_test_in_child("test_locked_prefs.js"); 31 } 32 33 ok(pb.prefIsLocked(bprefname), bprefname + " should be locked in the child"); 34 ok(pb.prefIsLocked(iprefname), iprefname + " should be locked in the child"); 35 ok( 36 !pb.prefIsLocked(sprefname), 37 sprefname + " should be unlocked in the child" 38 ); 39 }