test_actors.js (1475B)
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 file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 getMarionetteCommandsActorProxy, 9 registerCommandsActor, 10 unregisterCommandsActor, 11 } = ChromeUtils.importESModule( 12 "chrome://remote/content/marionette/actors/MarionetteCommandsParent.sys.mjs" 13 ); 14 const { enableEventsActor, disableEventsActor } = ChromeUtils.importESModule( 15 "chrome://remote/content/marionette/actors/MarionetteEventsParent.sys.mjs" 16 ); 17 18 registerCleanupFunction(function () { 19 unregisterCommandsActor(); 20 disableEventsActor(); 21 }); 22 23 add_task(function test_commandsActor_register() { 24 registerCommandsActor(); 25 unregisterCommandsActor(); 26 27 registerCommandsActor(); 28 registerCommandsActor(); 29 unregisterCommandsActor(); 30 }); 31 32 add_task(async function test_commandsActor_getActorProxy_noBrowsingContext() { 33 registerCommandsActor(); 34 35 try { 36 await getMarionetteCommandsActorProxy(() => null).sendQuery("foo", "bar"); 37 ok(false, "Expected error not raised"); 38 } catch (e) { 39 ok( 40 e.message.includes("BrowsingContext does no longer exist"), 41 "Expected default error message found" 42 ); 43 } 44 45 unregisterCommandsActor(); 46 }); 47 48 add_task(function test_eventsActor_enable_disable() { 49 enableEventsActor(); 50 disableEventsActor(); 51 52 enableEventsActor(); 53 enableEventsActor(); 54 disableEventsActor(); 55 });