michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const URL = "data:text/html;charset=utf8,

browser_profiler_io

"; michael@0: michael@0: let temp = {}; michael@0: Cu.import("resource://gre/modules/FileUtils.jsm", temp); michael@0: let FileUtils = temp.FileUtils; michael@0: let gTab, gPanel; michael@0: michael@0: let gData = { michael@0: "libs": "[]", // This property is not important for this test. michael@0: "meta": { michael@0: "version": 2, michael@0: "interval": 1, michael@0: "stackwalk": 0, michael@0: "jank": 0, michael@0: "processType": 0, michael@0: "platform": "Macintosh", michael@0: "oscpu": "Intel Mac OS X 10.8", michael@0: "misc": "rv:25.0", michael@0: "abi": "x86_64-gcc3", michael@0: "toolkit": "cocoa", michael@0: "product": "Firefox" michael@0: }, michael@0: "threads": [ michael@0: { michael@0: "samples": [ michael@0: { michael@0: "name": "(root)", michael@0: "frames": [ michael@0: { michael@0: "location": "Startup::XRE_Main", michael@0: "line": 3871 michael@0: }, michael@0: { michael@0: "location": "Events::ProcessGeckoEvents", michael@0: "line": 355 michael@0: }, michael@0: { michael@0: "location": "Events::ProcessGeckoEvents", michael@0: "line": 355 michael@0: } michael@0: ], michael@0: "responsiveness": -0.002963, michael@0: "time": 8.120823 michael@0: } michael@0: ] michael@0: } michael@0: ] michael@0: }; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: setUp(URL, function onSetUp(tab, browser, panel) { michael@0: gTab = tab; michael@0: gPanel = panel; michael@0: michael@0: let file = FileUtils.getFile("TmpD", ["tmpprofile.json"]); michael@0: file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("666", 8)); michael@0: michael@0: gPanel.saveProfile(file, gData) michael@0: .then(gPanel.loadProfile.bind(gPanel, file)) michael@0: .then(checkData); michael@0: }); michael@0: } michael@0: michael@0: function checkData() { michael@0: let profile = gPanel.activeProfile; michael@0: let item = gPanel.sidebar.getItemByProfile(profile); michael@0: let data = profile.data; michael@0: michael@0: is(item.attachment.state, PROFILE_COMPLETED, "Profile is COMPLETED"); michael@0: is(gData.meta.oscpu, data.meta.oscpu, "Meta data is correct"); michael@0: is(gData.threads[0].samples.length, 1, "There's one sample"); michael@0: is(gData.threads[0].samples[0].name, "(root)", "Sample is correct"); michael@0: michael@0: tearDown(gTab, () => { gPanel = null; gTab = null; }); michael@0: }