browser/devtools/profiler/test/browser_profiler_io.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 const URL = "data:text/html;charset=utf8,<p>browser_profiler_io</p>";
     6 let temp = {};
     7 Cu.import("resource://gre/modules/FileUtils.jsm", temp);
     8 let FileUtils = temp.FileUtils;
     9 let gTab, gPanel;
    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 };
    53 function test() {
    54   waitForExplicitFinish();
    56   setUp(URL, function onSetUp(tab, browser, panel) {
    57     gTab = tab;
    58     gPanel = panel;
    60     let file = FileUtils.getFile("TmpD", ["tmpprofile.json"]);
    61     file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("666", 8));
    63     gPanel.saveProfile(file, gData)
    64       .then(gPanel.loadProfile.bind(gPanel, file))
    65       .then(checkData);
    66   });
    67 }
    69 function checkData() {
    70   let profile = gPanel.activeProfile;
    71   let item = gPanel.sidebar.getItemByProfile(profile);
    72   let data = profile.data;
    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");
    79   tearDown(gTab, () => { gPanel = null; gTab = null; });
    80 }

mercurial