1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/profiler/test/browser_profiler_io.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +const URL = "data:text/html;charset=utf8,<p>browser_profiler_io</p>"; 1.8 + 1.9 +let temp = {}; 1.10 +Cu.import("resource://gre/modules/FileUtils.jsm", temp); 1.11 +let FileUtils = temp.FileUtils; 1.12 +let gTab, gPanel; 1.13 + 1.14 +let gData = { 1.15 + "libs": "[]", // This property is not important for this test. 1.16 + "meta": { 1.17 + "version": 2, 1.18 + "interval": 1, 1.19 + "stackwalk": 0, 1.20 + "jank": 0, 1.21 + "processType": 0, 1.22 + "platform": "Macintosh", 1.23 + "oscpu": "Intel Mac OS X 10.8", 1.24 + "misc": "rv:25.0", 1.25 + "abi": "x86_64-gcc3", 1.26 + "toolkit": "cocoa", 1.27 + "product": "Firefox" 1.28 + }, 1.29 + "threads": [ 1.30 + { 1.31 + "samples": [ 1.32 + { 1.33 + "name": "(root)", 1.34 + "frames": [ 1.35 + { 1.36 + "location": "Startup::XRE_Main", 1.37 + "line": 3871 1.38 + }, 1.39 + { 1.40 + "location": "Events::ProcessGeckoEvents", 1.41 + "line": 355 1.42 + }, 1.43 + { 1.44 + "location": "Events::ProcessGeckoEvents", 1.45 + "line": 355 1.46 + } 1.47 + ], 1.48 + "responsiveness": -0.002963, 1.49 + "time": 8.120823 1.50 + } 1.51 + ] 1.52 + } 1.53 + ] 1.54 +}; 1.55 + 1.56 +function test() { 1.57 + waitForExplicitFinish(); 1.58 + 1.59 + setUp(URL, function onSetUp(tab, browser, panel) { 1.60 + gTab = tab; 1.61 + gPanel = panel; 1.62 + 1.63 + let file = FileUtils.getFile("TmpD", ["tmpprofile.json"]); 1.64 + file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("666", 8)); 1.65 + 1.66 + gPanel.saveProfile(file, gData) 1.67 + .then(gPanel.loadProfile.bind(gPanel, file)) 1.68 + .then(checkData); 1.69 + }); 1.70 +} 1.71 + 1.72 +function checkData() { 1.73 + let profile = gPanel.activeProfile; 1.74 + let item = gPanel.sidebar.getItemByProfile(profile); 1.75 + let data = profile.data; 1.76 + 1.77 + is(item.attachment.state, PROFILE_COMPLETED, "Profile is COMPLETED"); 1.78 + is(gData.meta.oscpu, data.meta.oscpu, "Meta data is correct"); 1.79 + is(gData.threads[0].samples.length, 1, "There's one sample"); 1.80 + is(gData.threads[0].samples[0].name, "(root)", "Sample is correct"); 1.81 + 1.82 + tearDown(gTab, () => { gPanel = null; gTab = null; }); 1.83 +} 1.84 \ No newline at end of file