test_NetworkDecodedBodySizeMap.js (1052B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { NetworkDecodedBodySizeMap } = ChromeUtils.importESModule( 7 "chrome://remote/content/shared/NetworkDecodedBodySizeMap.sys.mjs" 8 ); 9 10 add_task(async function test_decodedBodySizeMap() { 11 const map = new NetworkDecodedBodySizeMap(); 12 const channelId = 1; 13 equal( 14 map.getDecodedBodySize(channelId), 15 0, 16 "By default the decode body size is 0" 17 ); 18 19 let expectedBodySize = 12; 20 map.setDecodedBodySize(channelId, expectedBodySize); 21 equal( 22 map.getDecodedBodySize(channelId), 23 expectedBodySize, 24 "The expected body size was set" 25 ); 26 27 expectedBodySize = 24; 28 map.setDecodedBodySize(channelId, expectedBodySize); 29 equal( 30 map.getDecodedBodySize(channelId), 31 expectedBodySize, 32 "The expected body size was updated" 33 ); 34 35 map.delete(channelId); 36 equal( 37 map.getDecodedBodySize(channelId), 38 0, 39 "After deleting the channel entry, the size is back to 0" 40 ); 41 42 map.destroy(); 43 });