test_census-tree-node-09.js (1199B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 /** 6 * Test that repeatedly converting the same census report to a CensusTreeNode 7 * tree results in the same CensusTreeNode tree. 8 */ 9 10 function run_test() { 11 const BREAKDOWN = { 12 by: "filename", 13 then: { 14 by: "internalType", 15 then: { by: "count", count: true, bytes: true }, 16 }, 17 noFilename: { 18 by: "internalType", 19 then: { by: "count", count: true, bytes: true }, 20 }, 21 }; 22 23 const REPORT = { 24 "http://example.com/app.js": { 25 JSScript: { count: 10, bytes: 100 }, 26 }, 27 "http://example.com/ads.js": { 28 "js::LazyScript": { count: 20, bytes: 200 }, 29 }, 30 "http://example.com/trackers.js": { 31 JSScript: { count: 30, bytes: 300 }, 32 }, 33 noFilename: { 34 "js::jit::JitCode": { count: 40, bytes: 400 }, 35 }, 36 }; 37 38 const first = censusReportToCensusTreeNode(BREAKDOWN, REPORT); 39 const second = censusReportToCensusTreeNode(BREAKDOWN, REPORT); 40 const third = censusReportToCensusTreeNode(BREAKDOWN, REPORT); 41 42 assertStructurallyEquivalent(first, second); 43 assertStructurallyEquivalent(second, third); 44 }