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