test_unregister_empty_scope.js (1063B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 function run_test() { 7 do_get_profile(); 8 setPrefs(); 9 run_next_test(); 10 } 11 12 add_task(async function test_unregister_empty_scope() { 13 let handshakeDone; 14 let handshakePromise = new Promise(resolve => (handshakeDone = resolve)); 15 PushService.init({ 16 serverURI: "wss://push.example.org/", 17 makeWebSocket(uri) { 18 return new MockWebSocket(uri, { 19 onHello() { 20 this.serverSendMsg( 21 JSON.stringify({ 22 messageType: "hello", 23 status: 200, 24 uaid: "5619557c-86fe-4711-8078-d1fd6987aef7", 25 }) 26 ); 27 handshakeDone(); 28 }, 29 }); 30 }, 31 }); 32 await handshakePromise; 33 34 await Assert.rejects( 35 PushService.unregister({ 36 scope: "", 37 originAttributes: ChromeUtils.originAttributesToSuffix({ 38 inIsolatedMozBrowser: false, 39 }), 40 }), 41 /Invalid page record/, 42 "Expected error for empty endpoint" 43 ); 44 });