Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | const URL = "data:text/html;charset=utf8,<p>browser_profiler_io</p>"; |
michael@0 | 5 | |
michael@0 | 6 | let temp = {}; |
michael@0 | 7 | Cu.import("resource://gre/modules/FileUtils.jsm", temp); |
michael@0 | 8 | let FileUtils = temp.FileUtils; |
michael@0 | 9 | let gTab, gPanel; |
michael@0 | 10 | |
michael@0 | 11 | let gData = { |
michael@0 | 12 | "libs": "[]", // This property is not important for this test. |
michael@0 | 13 | "meta": { |
michael@0 | 14 | "version": 2, |
michael@0 | 15 | "interval": 1, |
michael@0 | 16 | "stackwalk": 0, |
michael@0 | 17 | "jank": 0, |
michael@0 | 18 | "processType": 0, |
michael@0 | 19 | "platform": "Macintosh", |
michael@0 | 20 | "oscpu": "Intel Mac OS X 10.8", |
michael@0 | 21 | "misc": "rv:25.0", |
michael@0 | 22 | "abi": "x86_64-gcc3", |
michael@0 | 23 | "toolkit": "cocoa", |
michael@0 | 24 | "product": "Firefox" |
michael@0 | 25 | }, |
michael@0 | 26 | "threads": [ |
michael@0 | 27 | { |
michael@0 | 28 | "samples": [ |
michael@0 | 29 | { |
michael@0 | 30 | "name": "(root)", |
michael@0 | 31 | "frames": [ |
michael@0 | 32 | { |
michael@0 | 33 | "location": "Startup::XRE_Main", |
michael@0 | 34 | "line": 3871 |
michael@0 | 35 | }, |
michael@0 | 36 | { |
michael@0 | 37 | "location": "Events::ProcessGeckoEvents", |
michael@0 | 38 | "line": 355 |
michael@0 | 39 | }, |
michael@0 | 40 | { |
michael@0 | 41 | "location": "Events::ProcessGeckoEvents", |
michael@0 | 42 | "line": 355 |
michael@0 | 43 | } |
michael@0 | 44 | ], |
michael@0 | 45 | "responsiveness": -0.002963, |
michael@0 | 46 | "time": 8.120823 |
michael@0 | 47 | } |
michael@0 | 48 | ] |
michael@0 | 49 | } |
michael@0 | 50 | ] |
michael@0 | 51 | }; |
michael@0 | 52 | |
michael@0 | 53 | function test() { |
michael@0 | 54 | waitForExplicitFinish(); |
michael@0 | 55 | |
michael@0 | 56 | setUp(URL, function onSetUp(tab, browser, panel) { |
michael@0 | 57 | gTab = tab; |
michael@0 | 58 | gPanel = panel; |
michael@0 | 59 | |
michael@0 | 60 | let file = FileUtils.getFile("TmpD", ["tmpprofile.json"]); |
michael@0 | 61 | file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("666", 8)); |
michael@0 | 62 | |
michael@0 | 63 | gPanel.saveProfile(file, gData) |
michael@0 | 64 | .then(gPanel.loadProfile.bind(gPanel, file)) |
michael@0 | 65 | .then(checkData); |
michael@0 | 66 | }); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function checkData() { |
michael@0 | 70 | let profile = gPanel.activeProfile; |
michael@0 | 71 | let item = gPanel.sidebar.getItemByProfile(profile); |
michael@0 | 72 | let data = profile.data; |
michael@0 | 73 | |
michael@0 | 74 | is(item.attachment.state, PROFILE_COMPLETED, "Profile is COMPLETED"); |
michael@0 | 75 | is(gData.meta.oscpu, data.meta.oscpu, "Meta data is correct"); |
michael@0 | 76 | is(gData.threads[0].samples.length, 1, "There's one sample"); |
michael@0 | 77 | is(gData.threads[0].samples[0].name, "(root)", "Sample is correct"); |
michael@0 | 78 | |
michael@0 | 79 | tearDown(gTab, () => { gPanel = null; gTab = null; }); |
michael@0 | 80 | } |