Merge inbound to central, a=merge

MozReview-Commit-ID: I54WGOLqHI2
This commit is contained in:
Wes Kocher 2016-12-22 18:37:07 -08:00
commit 60785fce6d
626 changed files with 7133 additions and 4616 deletions

View File

@ -84,7 +84,6 @@ devtools/client/framework/**
!devtools/client/framework/selection.js
!devtools/client/framework/toolbox.js
devtools/client/jsonview/lib/**
devtools/client/memory/**
devtools/client/netmonitor/test/**
devtools/client/netmonitor/har/test/**
devtools/client/projecteditor/**

View File

@ -879,6 +879,7 @@ Ryan Flint <rflint@dslr.net>
Ryan Jones <sciguyryan@gmail.com>
Ryan VanderMeulen <ryanvm@gmail.com>
Ryoichi Furukawa <oliver@1000cp.com>
Sanyam Khurana <Sanyam.Khurana01@gmail.com>
sagdjb@softwareag.com
Samir Gehani <sgehani@netscape.com>
Sammy Ford

View File

@ -7,6 +7,7 @@
#include "mozilla/dom/AccessibleNodeBinding.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/DOMStringList.h"
#include "nsIPersistentProperties2.h"
#include "Accessible-inl.h"
#include "nsAccessibilityService.h"
@ -103,6 +104,44 @@ AccessibleNode::Is(const Sequence<nsString>& aFlavors)
return true;
}
bool
AccessibleNode::Has(const Sequence<nsString>& aAttributes)
{
if (!mIntl) {
return false;
}
nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes();
for (const auto& attr : aAttributes) {
bool has = false;
attrs->Has(NS_ConvertUTF16toUTF8(attr).get(), &has);
if (!has) {
return false;
}
}
return true;
}
void
AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv)
{
if (!mIntl) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes();
nsAutoString value;
attrs->GetStringProperty(NS_ConvertUTF16toUTF8(aAttribute), value);
JS::Rooted<JS::Value> jsval(aCX);
if (!ToJSValue(aCX, value, &jsval)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
}
aValue.set(jsval);
}
nsINode*
AccessibleNode::GetDOMNode()
{

View File

@ -8,6 +8,7 @@
#define A11Y_AOM_ACCESSIBLENODE_H
#include "nsWrapperCache.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
class nsINode;
@ -40,6 +41,10 @@ public:
nsINode* GetDOMNode();
bool Is(const Sequence<nsString>& aFlavors);
bool Has(const Sequence<nsString>& aAttributes);
void Get(JSContext* cx, const nsAString& aAttribute,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv);
a11y::Accessible* Internal() const { return mIntl; }

View File

@ -35,7 +35,7 @@
function createIframe() {
return new Promise((resolve) => {
let iframe = document.createElement("iframe");
iframe.src = "about:blank";
iframe.src = `data:text/html,<html><body>hey</body></html>`;
iframe.onload = () => resolve(iframe.contentDocument);
document.body.appendChild(iframe);
});
@ -80,6 +80,12 @@
ok(anode.is('document', 'focusable'),
'correct role and state on an accessible node');
is(anode.get('explicit-name'), 'true',
'correct object attribute value on an accessible node');
ok(anode.has('explicit-name'),
'object attributes are present');
finish();
}
</script>

View File

@ -210,8 +210,14 @@ pref("general.autoScroll", true);
pref("browser.shell.checkDefaultBrowser", true);
pref("browser.shell.shortcutFavicons",true);
pref("browser.shell.mostRecentDateSetAsDefault", "");
#ifdef RELEASE_OR_BETA
pref("browser.shell.skipDefaultBrowserCheckOnFirstRun", false);
#else
pref("browser.shell.skipDefaultBrowserCheckOnFirstRun", true);
#endif
pref("browser.shell.skipDefaultBrowserCheck", true);
pref("browser.shell.defaultBrowserCheckCount", 0);
pref("browser.defaultbrowser.notificationbar", false);
// 0 = blank, 1 = home (browser.startup.homepage), 2 = last visited page, 3 = resume previous browser session
// The behavior of option 3 is detailed at: http://wiki.mozilla.org/Session_Restore
@ -1440,8 +1446,6 @@ pref("extensions.interposition.prefetching", true);
pref("extensions.e10sBlocksEnabling", true);
#endif
pref("browser.defaultbrowser.notificationbar", false);
// How often to check for CPOW timeouts. CPOWs are only timed out by
// the hang monitor.
pref("dom.ipc.cpow.timeout", 500);

View File

@ -4848,13 +4848,13 @@
relatedToCurrent: true,
isPrerendered: true,
});
let partialSHistory = newTab.linkedBrowser.frameLoader.partialSessionHistory;
let partialSHistory = newTab.linkedBrowser.frameLoader.partialSHistory;
groupedSHistory.addPrerenderingPartialSHistory(partialSHistory, data.id);
break;
}
case "Prerender:Cancel": {
let groupedSHistory = browser.frameLoader.groupedSessionHistory;
let groupedSHistory = browser.frameLoader.groupedSHistory;
if (groupedSHistory) {
groupedSHistory.cancelPrerendering(data.id);
}
@ -4863,7 +4863,7 @@
case "Prerender:Swap": {
let frameloader = browser.frameLoader;
let groupedSHistory = browser.frameLoader.groupedSessionHistory;
let groupedSHistory = browser.frameLoader.groupedSHistory;
if (groupedSHistory) {
groupedSHistory.activatePrerendering(data.id).then(
() => frameloader.messageManager.sendAsyncMessage("Prerender:Swapped", data),

View File

@ -68,8 +68,7 @@ add_task(function* () {
isPrerendered: true,
});
yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
browser1.frameLoader.appendPartialSessionHistoryAndSwap(
tab2.linkedBrowser.frameLoader);
browser1.frameLoader.appendPartialSHistoryAndSwap(tab2.linkedBrowser.frameLoader);
yield awaitProcessChange(browser1);
});
yield closed2;

View File

@ -673,7 +673,7 @@ extensions.registerSchemaAPI("tabs", "addon_parent", context => {
pattern = new MatchPattern(queryInfo.url);
}
function matches(window, tab) {
function matches(tab) {
let props = ["active", "pinned", "highlighted", "status", "title", "index"];
for (let prop of props) {
if (queryInfo[prop] !== null && queryInfo[prop] != tab[prop]) {
@ -681,26 +681,6 @@ extensions.registerSchemaAPI("tabs", "addon_parent", context => {
}
}
let lastFocused = window == WindowManager.topWindow;
if (queryInfo.lastFocusedWindow !== null && queryInfo.lastFocusedWindow != lastFocused) {
return false;
}
let windowType = WindowManager.windowType(window);
if (queryInfo.windowType !== null && queryInfo.windowType != windowType) {
return false;
}
if (queryInfo.windowId !== null) {
if (queryInfo.windowId == WindowManager.WINDOW_ID_CURRENT) {
if (currentWindow(context) != window) {
return false;
}
} else if (queryInfo.windowId != tab.windowId) {
return false;
}
}
if (queryInfo.audible !== null) {
if (queryInfo.audible != tab.audible) {
return false;
@ -713,13 +693,6 @@ extensions.registerSchemaAPI("tabs", "addon_parent", context => {
}
}
if (queryInfo.currentWindow !== null) {
let eq = window == currentWindow(context);
if (queryInfo.currentWindow != eq) {
return false;
}
}
if (queryInfo.cookieStoreId !== null &&
tab.cookieStoreId != queryInfo.cookieStoreId) {
return false;
@ -734,9 +707,36 @@ extensions.registerSchemaAPI("tabs", "addon_parent", context => {
let result = [];
for (let window of WindowListManager.browserWindows()) {
let lastFocused = window === WindowManager.topWindow;
if (queryInfo.lastFocusedWindow !== null && queryInfo.lastFocusedWindow !== lastFocused) {
continue;
}
let windowType = WindowManager.windowType(window);
if (queryInfo.windowType !== null && queryInfo.windowType !== windowType) {
continue;
}
if (queryInfo.windowId !== null) {
if (queryInfo.windowId === WindowManager.WINDOW_ID_CURRENT) {
if (currentWindow(context) !== window) {
continue;
}
} else if (queryInfo.windowId !== WindowManager.getId(window)) {
continue;
}
}
if (queryInfo.currentWindow !== null) {
let eq = window === currentWindow(context);
if (queryInfo.currentWindow != eq) {
continue;
}
}
let tabs = TabManager.for(extension).getTabs(window);
for (let tab of tabs) {
if (matches(window, tab)) {
if (matches(tab)) {
result.push(tab);
}
}

View File

@ -675,7 +675,7 @@ ExtensionTabManager.prototype = {
active: tab.selected,
pinned: tab.pinned,
status: TabManager.getStatus(tab),
incognito: PrivateBrowsingUtils.isBrowserPrivate(browser),
incognito: WindowManager.isBrowserPrivate(browser),
width: browser.frameLoader.lazyWidth || browser.clientWidth,
height: browser.frameLoader.lazyHeight || browser.clientHeight,
audible: tab.soundPlaying,
@ -925,6 +925,11 @@ extensions.on("shutdown", (type, extension) => {
});
/* eslint-enable mozilla/balanced-listeners */
function memoize(fn) {
let weakMap = new DefaultWeakMap(fn);
return weakMap.get.bind(weakMap);
}
// Manages mapping between XUL windows and extension window IDs.
global.WindowManager = {
// Note: These must match the values in windows.json.
@ -964,13 +969,16 @@ global.WindowManager = {
}
},
getId(window) {
if (!window.QueryInterface) {
return null;
isBrowserPrivate: memoize(browser => {
return PrivateBrowsingUtils.isBrowserPrivate(browser);
}),
getId: memoize(window => {
if (window instanceof Ci.nsIInterfaceRequestor) {
return window.getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
}
return window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
},
return null;
}),
getWindow(id, context) {
if (id == this.WINDOW_ID_CURRENT) {

View File

@ -1095,14 +1095,15 @@ BrowserGlue.prototype = {
if (ShellService) {
let shouldCheck = AppConstants.DEBUG ? false :
ShellService.shouldCheckDefaultBrowser;
let promptCount;
let skipDefaultBrowserCheck = false;
if (!AppConstants.RELEASE_OR_BETA) {
promptCount =
Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount");
skipDefaultBrowserCheck =
Services.prefs.getBoolPref("browser.shell.skipDefaultBrowserCheck");
}
const skipDefaultBrowserCheck =
Services.prefs.getBoolPref("browser.shell.skipDefaultBrowserCheckOnFirstRun") &&
Services.prefs.getBoolPref("browser.shell.skipDefaultBrowserCheck");
const usePromptLimit = !AppConstants.RELEASE_OR_BETA;
let promptCount =
usePromptLimit ? Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount") : 0;
let willRecoverSession = false;
try {
let ss = Cc["@mozilla.org/browser/sessionstartup;1"].
@ -1137,16 +1138,13 @@ BrowserGlue.prototype = {
} else {
promptCount++;
}
if (promptCount > 3) {
if (usePromptLimit && promptCount > 3) {
willPrompt = false;
}
}
if (!AppConstants.RELEASE_OR_BETA) {
if (willPrompt) {
Services.prefs.setIntPref("browser.shell.defaultBrowserCheckCount",
promptCount);
}
if (usePromptLimit && willPrompt) {
Services.prefs.setIntPref("browser.shell.defaultBrowserCheckCount", promptCount);
}
try {

View File

@ -655,6 +655,16 @@ PlacesController.prototype = {
}
}
// Make sure correct PluralForms are diplayed when multiple pages are selected.
var deleteHistoryItem = document.getElementById("placesContext_delete_history");
deleteHistoryItem.label = PlacesUIUtils.getPluralString("cmd.deletePages.label",
metadata.length);
deleteHistoryItem.accessKey = PlacesUIUtils.getString("cmd.deletePages.accesskey");
var createBookmarkItem = document.getElementById("placesContext_createBookmark");
createBookmarkItem.label = PlacesUIUtils.getPluralString("cmd.bookmarkPages.label",
metadata.length);
createBookmarkItem.accessKey = PlacesUIUtils.getString("cmd.bookmarkPages.accesskey");
return usableItemCount > 0;
},

View File

@ -161,8 +161,6 @@
<menuseparator id="placesContext_newSeparator"/>
<menuitem id="placesContext_createBookmark"
command="placesCmd_createBookmark"
label="&cmd.bookmarkLink.label;"
accesskey="&cmd.bookmarkLink.accesskey;"
selection="link"
forcehideselection="bookmark|tagChild"/>
<menuitem id="placesContext_cut"
@ -194,8 +192,6 @@
selection="bookmark|tagChild|folder|query|dynamiccontainer|separator|host"/>
<menuitem id="placesContext_delete_history"
command="placesCmd_delete"
label="&cmd.delete.label;"
accesskey="&cmd.delete.accesskey;"
closemenu="single"
selection="link"
forcehideselection="bookmark"/>

View File

@ -3641,7 +3641,7 @@ var SessionStoreInternal = {
// process, or we have a browser with a grouped session history (as we don't
// support restoring into browsers with grouped session histories directly).
let newFrameloader =
aReloadInFreshProcess || !!browser.frameLoader.groupedSessionHistory;
aReloadInFreshProcess || !!browser.frameLoader.groupedSHistory;
let isRemotenessUpdate =
tabbrowser.updateBrowserRemotenessByURL(browser, uri, {
freshProcess: aReloadInFreshProcess,

View File

@ -70,8 +70,7 @@ add_task(function* () {
isPrerendered: true,
});
yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
browser1.frameLoader.appendPartialSessionHistoryAndSwap(
tab2.linkedBrowser.frameLoader);
browser1.frameLoader.appendPartialSHistoryAndSwap(tab2.linkedBrowser.frameLoader);
yield awaitProcessChange(browser1);
yield* validate(browser1, 3, 3);
@ -113,8 +112,7 @@ add_task(function* () {
isPrerendered: true,
});
yield BrowserTestUtils.browserLoaded(tab3.linkedBrowser);
browser1.frameLoader.appendPartialSessionHistoryAndSwap(
tab3.linkedBrowser.frameLoader);
browser1.frameLoader.appendPartialSHistoryAndSwap(tab3.linkedBrowser.frameLoader);
yield awaitProcessChange(browser1);
yield* validate(browser1, 5, 5);

View File

@ -1,8 +1,8 @@
[
{
"version": "gcc 4.8.5 + PR64905",
"size": 80160264,
"digest": "c1a9dc9da289b8528874d16300b9d13a997cec99195bb0bc46ff665216d8535d6d6cb5af6b4b1f2749af6815dab12e703fdb3849014e5c23a70eff351a0baf4e",
"version": "gcc 4.9.4 + PR64905",
"size": 101297752,
"digest": "42aa2e3fdd232b5e390472a788e7f7db71a1fee4221e260b6cb58c9a1d73e6cdd10afcbac137f7844290169cd6b561b424ecc92b159e9726b0ad5de3f478a8be",
"algorithm": "sha512",
"filename": "gcc.tar.xz",
"unpack": true

View File

@ -1,8 +1,8 @@
[
{
"version": "gcc 4.8.5 + PR64905",
"size": 80160264,
"digest": "c1a9dc9da289b8528874d16300b9d13a997cec99195bb0bc46ff665216d8535d6d6cb5af6b4b1f2749af6815dab12e703fdb3849014e5c23a70eff351a0baf4e",
"version": "gcc 4.9.4 + PR64905",
"size": 101297752,
"digest": "42aa2e3fdd232b5e390472a788e7f7db71a1fee4221e260b6cb58c9a1d73e6cdd10afcbac137f7844290169cd6b561b424ecc92b159e9726b0ad5de3f478a8be",
"algorithm": "sha512",
"filename": "gcc.tar.xz",
"unpack": true

View File

@ -1,10 +1,10 @@
[
{
"size": 102421980,
"version": "gcc 4.9.3",
"filename": "gcc.tar.xz",
"version": "gcc 4.9.4 + PR64905",
"size": 101297752,
"digest": "42aa2e3fdd232b5e390472a788e7f7db71a1fee4221e260b6cb58c9a1d73e6cdd10afcbac137f7844290169cd6b561b424ecc92b159e9726b0ad5de3f478a8be",
"algorithm": "sha512",
"digest": "f25292aa93dc449e0472eee511c0ac15b5f1a4272ab76cf53ce5d20dc57f29e83da49ae1a9d9e994192647f75e13ae60f75ba2ac3cb9d26d5f5d6cabf88de921",
"filename": "gcc.tar.xz",
"unpack": true
},
{

View File

@ -1,8 +1,8 @@
[
{
"version": "gcc 4.8.5 + PR64905",
"size": 80160264,
"digest": "c1a9dc9da289b8528874d16300b9d13a997cec99195bb0bc46ff665216d8535d6d6cb5af6b4b1f2749af6815dab12e703fdb3849014e5c23a70eff351a0baf4e",
"version": "gcc 4.9.4 + PR64905",
"size": 101297752,
"digest": "42aa2e3fdd232b5e390472a788e7f7db71a1fee4221e260b6cb58c9a1d73e6cdd10afcbac137f7844290169cd6b561b424ecc92b159e9726b0ad5de3f478a8be",
"algorithm": "sha512",
"filename": "gcc.tar.xz",
"unpack": true

View File

@ -1,8 +1,8 @@
[
{
"version": "gcc 4.8.5 + PR64905",
"size": 80160264,
"digest": "c1a9dc9da289b8528874d16300b9d13a997cec99195bb0bc46ff665216d8535d6d6cb5af6b4b1f2749af6815dab12e703fdb3849014e5c23a70eff351a0baf4e",
"version": "gcc 4.9.4 + PR64905",
"size": 101297752,
"digest": "42aa2e3fdd232b5e390472a788e7f7db71a1fee4221e260b6cb58c9a1d73e6cdd10afcbac137f7844290169cd6b561b424ecc92b159e9726b0ad5de3f478a8be",
"algorithm": "sha512",
"filename": "gcc.tar.xz",
"unpack": true

View File

@ -1,8 +1,8 @@
[
{
"version": "gcc 4.8.5 + PR64905",
"size": 80160264,
"digest": "c1a9dc9da289b8528874d16300b9d13a997cec99195bb0bc46ff665216d8535d6d6cb5af6b4b1f2749af6815dab12e703fdb3849014e5c23a70eff351a0baf4e",
"version": "gcc 4.9.4 + PR64905",
"size": 101297752,
"digest": "42aa2e3fdd232b5e390472a788e7f7db71a1fee4221e260b6cb58c9a1d73e6cdd10afcbac137f7844290169cd6b561b424ecc92b159e9726b0ad5de3f478a8be",
"algorithm": "sha512",
"filename": "gcc.tar.xz",
"unpack": true

View File

@ -41,10 +41,6 @@
<!ENTITY cmd.restoreFromFile.label "Choose File…">
<!ENTITY cmd.restoreFromFile.accesskey "C">
<!ENTITY cmd.bookmarkLink.label "Bookmark This Page…">
<!ENTITY cmd.bookmarkLink.accesskey "B">
<!ENTITY cmd.delete.label "Delete This Page">
<!ENTITY cmd.delete.accesskey "D">
<!ENTITY cmd.deleteDomainData.label "Forget About This Site">
<!ENTITY cmd.deleteDomainData.accesskey "F">

View File

@ -90,3 +90,13 @@ lockPrompt.title=Browser Startup Error
lockPrompt.text=The bookmarks and history system will not be functional because one of %Ss files is in use by another application. Some security software can cause this problem.
lockPromptInfoButton.label=Learn More
lockPromptInfoButton.accessKey=L
# LOCALIZATION NOTE (deletePagesLabel): Semi-colon list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
cmd.deletePages.label=Delete Page;Delete Pages
cmd.deletePages.accesskey=D
# LOCALIZATION NOTE (bookmarkPagesLabel): Semi-colon list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
cmd.bookmarkPages.label=Bookmark Page;Bookmark Pages
cmd.bookmarkPages.accesskey=B

View File

@ -204,6 +204,9 @@ def bootstrap(topsrcdir, mozilla_dir=None):
import mach.main
from mozboot.util import get_state_dir
from mozbuild.util import patch_main
patch_main()
def telemetry_handler(context, data):
# We have not opted-in to telemetry
if 'BUILD_SYSTEM_TELEMETRY' not in os.environ:

View File

@ -370,13 +370,11 @@ def check_compiler(compiler, language, target):
if info.type == 'clang-cl' and info.language_version != 201402:
append_flag('-std=c++14')
# We force clang-cl to emulate Visual C++ 2015 Update 3 with fallback to
# cl.exe.
# We force clang-cl to emulate Visual C++ 2015 Update 3.
if info.type == 'clang-cl' and info.version != '19.00.24213':
# Those flags are direct clang-cl flags that don't need -Xclang, add
# them directly.
# This flag is a direct clang-cl flag that doesn't need -Xclang,
# add it directly.
flags.append('-fms-compatibility-version=19.00.24213')
flags.append('-fallback')
# Check compiler target
# --------------------------------------------------------------------

View File

@ -1,5 +1,7 @@
# Options to enable rust in automation builds.
TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir}
# Tell configure to use the tooltool rustc.
RUSTC="$topsrcdir/rustc/bin/rustc"
CARGO="$topsrcdir/rustc/bin/cargo"
RUSTC="$TOOLTOOL_DIR/rustc/bin/rustc"
CARGO="$TOOLTOOL_DIR/rustc/bin/cargo"

View File

@ -1,6 +1,6 @@
#!/bin/bash
gcc_version=4.8.5
gcc_version=4.9.4
binutils_version=2.25.1
this_path=$(readlink -f $(dirname $0))
make_flags='-j12'

View File

@ -329,6 +329,10 @@ CONFIG_STATUS_DEPS := \
$(OBJDIR)/.mozconfig.json \
$(NULL)
# Include a dep file emitted by configure to track Python files that
# may influence the result of configure.
-include $(OBJDIR)/configure.d
CONFIGURE_ENV_ARGS += \
MAKE='$(MAKE)' \
$(NULL)

Binary file not shown.

View File

@ -5,6 +5,7 @@
from __future__ import print_function, unicode_literals
import codecs
import itertools
import os
import subprocess
import sys
@ -14,6 +15,8 @@ import textwrap
base_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(base_dir, 'python', 'mozbuild'))
from mozbuild.configure import ConfigureSandbox
from mozbuild.makeutil import Makefile
from mozbuild.pythonutil import iter_modules_in_path
from mozbuild.util import (
indented_repr,
encode,
@ -46,7 +49,8 @@ def config_status(config):
sanitized_config = {}
sanitized_config['substs'] = {
k: sanitized_bools(v) for k, v in config.iteritems()
if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR')
if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR',
'ALL_CONFIGURE_PATHS')
}
sanitized_config['defines'] = {
k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems()
@ -79,11 +83,24 @@ def config_status(config):
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
fh.write(textwrap.dedent('''
if __name__ == '__main__':
from mozbuild.util import patch_main
patch_main()
from mozbuild.config_status import config_status
args = dict([(name, globals()[name]) for name in __all__])
config_status(**args)
'''))
# Write out a depfile so Make knows to re-run configure when relevant Python
# changes.
mk = Makefile()
rule = mk.create_rule()
rule.add_targets(["$(OBJDIR)/config.status"])
rule.add_dependencies(itertools.chain(config['ALL_CONFIGURE_PATHS'],
iter_modules_in_path(config['TOPOBJDIR'],
config['TOPSRCDIR'])))
with open('configure.d', 'w') as fh:
mk.dump(fh)
# Other things than us are going to run this file, so we need to give it
# executable permissions.
os.chmod('config.status', 0o755)

View File

@ -0,0 +1,11 @@
"use strict";
module.exports = {
"env": {
"browser": true,
},
"globals": {
"d3": true,
"dagreD3": true,
}
};

View File

@ -25,7 +25,8 @@ const setCensusDisplay = exports.setCensusDisplay = function (display) {
&& display
&& display.breakdown
&& display.breakdown.by,
`Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`);
"Breakdowns must be an object with a \`by\` property, attempted to set: " +
uneval(display));
return {
type: actions.SET_CENSUS_DISPLAY,

View File

@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert, reportException } = require("devtools/shared/DevToolsUtils");
@ -12,13 +13,11 @@ const {
snapshotIsDiffable,
findSelectedSnapshot,
} = require("../utils");
// This is a circular dependency, so do not destructure the needed properties.
const snapshotActions = require("./snapshot");
/**
* Toggle diffing mode on or off.
*/
const toggleDiffing = exports.toggleDiffing = function () {
exports.toggleDiffing = function () {
return function (dispatch, getState) {
dispatch({
type: actions.CHANGE_VIEW,
@ -155,7 +154,7 @@ const refreshDiffing = exports.refreshDiffing = function (heapWorker) {
* @param {HeapAnalysesClient} heapWorker
* @param {snapshotModel} snapshot
*/
const selectSnapshotForDiffingAndRefresh = exports.selectSnapshotForDiffingAndRefresh = function (heapWorker, snapshot) {
exports.selectSnapshotForDiffingAndRefresh = function (heapWorker, snapshot) {
return function* (dispatch, getState) {
assert(getState().diffing,
"If we are selecting for diffing, we must be in diffing mode");
@ -169,7 +168,7 @@ const selectSnapshotForDiffingAndRefresh = exports.selectSnapshotForDiffingAndRe
*
* @param {CensusTreeNode} node
*/
const expandDiffingCensusNode = exports.expandDiffingCensusNode = function (node) {
exports.expandDiffingCensusNode = function (node) {
return {
type: actions.EXPAND_DIFFING_CENSUS_NODE,
node,
@ -181,7 +180,7 @@ const expandDiffingCensusNode = exports.expandDiffingCensusNode = function (node
*
* @param {CensusTreeNode} node
*/
const collapseDiffingCensusNode = exports.collapseDiffingCensusNode = function (node) {
exports.collapseDiffingCensusNode = function (node) {
return {
type: actions.COLLAPSE_DIFFING_CENSUS_NODE,
node,
@ -193,7 +192,7 @@ const collapseDiffingCensusNode = exports.collapseDiffingCensusNode = function (
*
* @param {DominatorTreeNode} node
*/
const focusDiffingCensusNode = exports.focusDiffingCensusNode = function (node) {
exports.focusDiffingCensusNode = function (node) {
return {
type: actions.FOCUS_DIFFING_CENSUS_NODE,
node,

View File

@ -4,16 +4,14 @@
"use strict";
const { immutableUpdate, reportException, assert } = require("devtools/shared/DevToolsUtils");
const { snapshotState: states, actions, viewState } = require("../constants");
const { snapshotState: states, actions} = require("../constants");
const { L10N, openFilePicker, createSnapshot } = require("../utils");
const telemetry = require("../telemetry");
const { OS } = require("resource://gre/modules/osfile.jsm");
const {
selectSnapshot,
computeSnapshotData,
readSnapshot,
takeCensus,
takeTreeMap
readSnapshot
} = require("./snapshot");
const VALID_EXPORT_STATES = [states.SAVED, states.READ];
@ -54,7 +52,7 @@ const exportSnapshot = exports.exportSnapshot = function (snapshot, dest) {
};
};
const pickFileAndImportSnapshotAndCensus = exports.pickFileAndImportSnapshotAndCensus = function (heapWorker) {
exports.pickFileAndImportSnapshotAndCensus = function (heapWorker) {
return function* (dispatch, getState) {
let input = yield openFilePicker({
title: L10N.getFormatStr("snapshot.io.import.window"),
@ -70,7 +68,7 @@ const pickFileAndImportSnapshotAndCensus = exports.pickFileAndImportSnapshotAndC
};
};
const importSnapshotAndCensus = exports.importSnapshotAndCensus = function (heapWorker, path) {
const importSnapshotAndCensus = function (heapWorker, path) {
return function* (dispatch, getState) {
telemetry.countImportSnapshot();
@ -95,3 +93,4 @@ const importSnapshotAndCensus = exports.importSnapshotAndCensus = function (heap
dispatch({ type: actions.IMPORT_SNAPSHOT_END, id });
};
};
exports.importSnapshotAndCensus = importSnapshotAndCensus;

View File

@ -29,7 +29,8 @@ const setLabelDisplay = exports.setLabelDisplay = function (display) {
&& display
&& display.breakdown
&& display.breakdown.by,
`Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`);
"Breakdowns must be an object with a \`by\` property, attempted to set: " +
uneval(display));
return {
type: actions.SET_LABEL_DISPLAY,

View File

@ -34,7 +34,7 @@ const TaskCache = require("./task-cache");
* @param {HeapAnalysesClient}
* @param {Object}
*/
const takeSnapshotAndCensus = exports.takeSnapshotAndCensus = function (front, heapWorker) {
exports.takeSnapshotAndCensus = function (front, heapWorker) {
return function* (dispatch, getState) {
const id = yield dispatch(takeSnapshot(front));
if (id === null) {
@ -82,7 +82,7 @@ const computeSnapshotData = exports.computeSnapshotData = function (heapWorker,
* @param {HeapAnalysesClient} heapWorker
* @param {snapshotId} id
*/
const selectSnapshotAndRefresh = exports.selectSnapshotAndRefresh = function (heapWorker, id) {
exports.selectSnapshotAndRefresh = function (heapWorker, id) {
return function* (dispatch, getState) {
if (getState().diffing || getState().individuals) {
dispatch(view.changeView(viewState.CENSUS));
@ -200,7 +200,9 @@ function makeTakeCensusTask({ getDisplay, getFilter, getCensus, beginAction,
// Assert that snapshot is in a valid state
assert(canTakeCensus(snapshot),
`Attempting to take a census when the snapshot is not in a ready state. snapshot.state = ${snapshot.state}, census.state = ${(getCensus(snapshot) || { state: null }).state}`);
"Attempting to take a census when the snapshot is not in a ready state. " +
`snapshot.state = ${snapshot.state}, ` +
`census.state = ${(getCensus(snapshot) || { state: null }).state}`);
let report, parentMap;
let display = getDisplay(getState());
@ -322,7 +324,7 @@ const getCurrentCensusTaker = exports.getCurrentCensusTaker = function (currentV
*
* @param {DominatorTreeNode} node.
*/
const focusIndividual = exports.focusIndividual = function (node) {
exports.focusIndividual = function (node) {
return {
type: actions.FOCUS_INDIVIDUAL,
node,
@ -412,7 +414,7 @@ function (heapWorker, id, censusBreakdown, reportLeafIndex) {
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshIndividuals = exports.refreshIndividuals = function (heapWorker) {
exports.refreshIndividuals = function (heapWorker) {
return function* (dispatch, getState) {
assert(getState().view.state === viewState.INDIVIDUALS,
"Should be in INDIVIDUALS view.");
@ -453,7 +455,7 @@ const refreshIndividuals = exports.refreshIndividuals = function (heapWorker) {
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshSelectedCensus = exports.refreshSelectedCensus = function (heapWorker) {
exports.refreshSelectedCensus = function (heapWorker) {
return function* (dispatch, getState) {
let snapshot = getState().snapshots.find(s => s.selected);
if (!snapshot || snapshot.state !== states.READ) {
@ -479,7 +481,7 @@ const refreshSelectedCensus = exports.refreshSelectedCensus = function (heapWork
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshSelectedTreeMap = exports.refreshSelectedTreeMap = function (heapWorker) {
exports.refreshSelectedTreeMap = function (heapWorker) {
return function* (dispatch, getState) {
let snapshot = getState().snapshots.find(s => s.selected);
if (!snapshot || snapshot.state !== states.READ) {
@ -596,8 +598,7 @@ TaskCache.declareCacheableTask({
* @param {SnapshotId} id
* @param {DominatorTreeLazyChildren} lazyChildren
*/
const fetchImmediatelyDominated = exports.fetchImmediatelyDominated =
TaskCache.declareCacheableTask({
exports.fetchImmediatelyDominated = TaskCache.declareCacheableTask({
getCacheKey(_, id, lazyChildren) {
return `${id}-${lazyChildren.key()}`;
},
@ -630,7 +631,7 @@ TaskCache.declareCacheableTask({
removeFromCache();
reportException("actions/snapshot/fetchImmediatelyDominated", error);
dispatch({ type: actions.DOMINATOR_TREE_ERROR, id, error });
return null;
return;
}
}
while (display !== getState().labelDisplay);
@ -643,6 +644,7 @@ TaskCache.declareCacheableTask({
nodes: response.nodes,
moreChildrenAvailable: response.moreChildrenAvailable,
});
return;
}
});
@ -684,7 +686,7 @@ TaskCache.declareCacheableTask({
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshSelectedDominatorTree = exports.refreshSelectedDominatorTree = function (heapWorker) {
exports.refreshSelectedDominatorTree = function (heapWorker) {
return function* (dispatch, getState) {
let snapshot = getState().snapshots.find(s => s.selected);
if (!snapshot) {
@ -731,7 +733,7 @@ const selectSnapshot = exports.selectSnapshot = function (id) {
*
* @param {HeapAnalysesClient} heapWorker
*/
const clearSnapshots = exports.clearSnapshots = function (heapWorker) {
exports.clearSnapshots = function (heapWorker) {
return function* (dispatch, getState) {
let snapshots = getState().snapshots.filter(s => {
let snapshotReady = s.state === states.READ || s.state === states.ERROR;
@ -769,7 +771,7 @@ const clearSnapshots = exports.clearSnapshots = function (heapWorker) {
* @param {HeapAnalysesClient} heapWorker
* @param {snapshotModel} snapshot
*/
const deleteSnapshot = exports.deleteSnapshot = function (heapWorker, snapshot) {
exports.deleteSnapshot = function (heapWorker, snapshot) {
return function* (dispatch, getState) {
dispatch({ type: actions.DELETE_SNAPSHOTS_START, ids: [snapshot.id] });
@ -789,7 +791,7 @@ const deleteSnapshot = exports.deleteSnapshot = function (heapWorker, snapshot)
*
* @param {CensusTreeNode} node
*/
const expandCensusNode = exports.expandCensusNode = function (id, node) {
exports.expandCensusNode = function (id, node) {
return {
type: actions.EXPAND_CENSUS_NODE,
id,
@ -802,7 +804,7 @@ const expandCensusNode = exports.expandCensusNode = function (id, node) {
*
* @param {CensusTreeNode} node
*/
const collapseCensusNode = exports.collapseCensusNode = function (id, node) {
exports.collapseCensusNode = function (id, node) {
return {
type: actions.COLLAPSE_CENSUS_NODE,
id,
@ -816,7 +818,7 @@ const collapseCensusNode = exports.collapseCensusNode = function (id, node) {
* @param {SnapshotId} id
* @param {DominatorTreeNode} node
*/
const focusCensusNode = exports.focusCensusNode = function (id, node) {
exports.focusCensusNode = function (id, node) {
return {
type: actions.FOCUS_CENSUS_NODE,
id,
@ -829,7 +831,7 @@ const focusCensusNode = exports.focusCensusNode = function (id, node) {
*
* @param {DominatorTreeTreeNode} node
*/
const expandDominatorTreeNode = exports.expandDominatorTreeNode = function (id, node) {
exports.expandDominatorTreeNode = function (id, node) {
return {
type: actions.EXPAND_DOMINATOR_TREE_NODE,
id,
@ -842,7 +844,7 @@ const expandDominatorTreeNode = exports.expandDominatorTreeNode = function (id,
*
* @param {DominatorTreeTreeNode} node
*/
const collapseDominatorTreeNode = exports.collapseDominatorTreeNode = function (id, node) {
exports.collapseDominatorTreeNode = function (id, node) {
return {
type: actions.COLLAPSE_DOMINATOR_TREE_NODE,
id,
@ -856,7 +858,7 @@ const collapseDominatorTreeNode = exports.collapseDominatorTreeNode = function (
* @param {SnapshotId} id
* @param {DominatorTreeNode} node
*/
const focusDominatorTreeNode = exports.focusDominatorTreeNode = function (id, node) {
exports.focusDominatorTreeNode = function (id, node) {
return {
type: actions.FOCUS_DOMINATOR_TREE_NODE,
id,

View File

@ -28,7 +28,8 @@ const setTreeMap = exports.setTreeMap = function (display) {
&& display
&& display.breakdown
&& display.breakdown.by,
`Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`);
"Breakdowns must be an object with a \`by\` property, attempted to set: " +
uneval(display));
return {
type: actions.SET_TREE_MAP_DISPLAY,

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert } = require("devtools/shared/DevToolsUtils");
const { appinfo } = require("Services");
const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react");
@ -54,10 +56,24 @@ const MemoryApp = createClass({
propTypes: appModel,
childContextTypes: {
front: PropTypes.any,
heapWorker: PropTypes.any,
toolbox: PropTypes.any,
},
getDefaultProps() {
return {};
},
getChildContext() {
return {
front: this.props.front,
heapWorker: this.props.heapWorker,
toolbox: this.props.toolbox,
};
},
componentDidMount() {
// Attach the keydown listener directly to the window. When an element that
// has the focus (such as a tree node) is removed from the DOM, the focus
@ -69,20 +85,6 @@ const MemoryApp = createClass({
window.removeEventListener("keydown", this.onKeyDown);
},
childContextTypes: {
front: PropTypes.any,
heapWorker: PropTypes.any,
toolbox: PropTypes.any,
},
getChildContext() {
return {
front: this.props.front,
heapWorker: this.props.heapWorker,
toolbox: this.props.toolbox,
};
},
onKeyDown(e) {
let { snapshots, dispatch, heapWorker } = this.props;
const selectedSnapshot = snapshots.find(s => s.selected);
@ -219,7 +221,8 @@ const MemoryApp = createClass({
Heap({
snapshot: selectedSnapshot,
diffing,
onViewSourceInDebugger: frame => toolbox.viewSourceInDebugger(frame.source, frame.line),
onViewSourceInDebugger: frame =>
toolbox.viewSourceInDebugger(frame.source, frame.line),
onSnapshotClick: () =>
dispatch(takeSnapshotAndCensus(front, heapWorker)),
onLoadMoreSiblings: lazyChildren =>
@ -249,7 +252,8 @@ const MemoryApp = createClass({
dispatch(expandDiffingCensusNode(node));
} else {
assert(selectedSnapshot && selectedSnapshot.census === census,
"If not diffing, should be expanding on selected snapshot's census");
"If not diffing, " +
"should be expanding on selected snapshot's census");
dispatch(expandCensusNode(selectedSnapshot.id, node));
}
},
@ -260,7 +264,8 @@ const MemoryApp = createClass({
dispatch(collapseDiffingCensusNode(node));
} else {
assert(selectedSnapshot && selectedSnapshot.census === census,
"If not diffing, should be collapsing on selected snapshot's census");
"If not diffing, " +
"should be collapsing on selected snapshot's census");
dispatch(collapseCensusNode(selectedSnapshot.id, node));
}
},
@ -271,13 +276,15 @@ const MemoryApp = createClass({
dispatch(focusDiffingCensusNode(node));
} else {
assert(selectedSnapshot && selectedSnapshot.census === census,
"If not diffing, should be focusing on nodes in selected snapshot's census");
"If not diffing, " +
"should be focusing on nodes in selected snapshot's census");
dispatch(focusCensusNode(selectedSnapshot.id, node));
}
},
onDominatorTreeExpand: node => {
assert(view.state === viewState.DOMINATOR_TREE,
"If expanding dominator tree nodes, should be in dominator tree view");
"If expanding dominator tree nodes, " +
"should be in dominator tree view");
assert(selectedSnapshot, "...and we should have a selected snapshot");
assert(selectedSnapshot.dominatorTree,
"...and that snapshot should have a dominator tree");
@ -285,7 +292,8 @@ const MemoryApp = createClass({
},
onDominatorTreeCollapse: node => {
assert(view.state === viewState.DOMINATOR_TREE,
"If collapsing dominator tree nodes, should be in dominator tree view");
"If collapsing dominator tree nodes, " +
"should be in dominator tree view");
assert(selectedSnapshot, "...and we should have a selected snapshot");
assert(selectedSnapshot.dominatorTree,
"...and that snapshot should have a dominator tree");
@ -293,7 +301,8 @@ const MemoryApp = createClass({
},
onDominatorTreeFocus: node => {
assert(view.state === viewState.DOMINATOR_TREE,
"If focusing dominator tree nodes, should be in dominator tree view");
"If focusing dominator tree nodes, " +
"should be in dominator tree view");
assert(selectedSnapshot, "...and we should have a selected snapshot");
assert(selectedSnapshot.dominatorTree,
"...and that snapshot should have a dominator tree");

View File

@ -2,11 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react");
const { L10N } = require("../utils");
const models = require("../models");
const CensusHeader = module.exports = createClass({
module.exports = createClass({
displayName: "CensusHeader",
propTypes: {

View File

@ -9,7 +9,7 @@ const { L10N, formatNumber, formatPercent } = require("../utils");
const Frame = createFactory(require("devtools/client/shared/components/frame"));
const { TREE_ROW_HEIGHT } = require("../constants");
const CensusTreeItem = module.exports = createClass({
module.exports = createClass({
displayName: "CensusTreeItem",
shouldComponentUpdate(nextProps, nextState) {
@ -20,6 +20,31 @@ const CensusTreeItem = module.exports = createClass({
|| this.props.diffing != nextProps.diffing;
},
toLabel(name, linkToDebugger) {
if (isSavedFrame(name)) {
return Frame({
frame: name,
onClick: () => linkToDebugger(name),
showFunctionName: true,
showHost: true,
});
}
if (name === null) {
return L10N.getStr("tree-item.root");
}
if (name === "noStack") {
return L10N.getStr("tree-item.nostack");
}
if (name === "noFilename") {
return L10N.getStr("tree-item.nofilename");
}
return String(name);
},
render() {
let {
item,
@ -106,29 +131,4 @@ const CensusTreeItem = module.exports = createClass({
)
);
},
toLabel(name, linkToDebugger) {
if (isSavedFrame(name)) {
return Frame({
frame: name,
onClick: () => linkToDebugger(name),
showFunctionName: true,
showHost: true,
});
}
if (name === null) {
return L10N.getStr("tree-item.root");
}
if (name === "noStack") {
return L10N.getStr("tree-item.nostack");
}
if (name === "noFilename") {
return L10N.getStr("tree-item.nofilename");
}
return String(name);
},
});

View File

@ -2,14 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
"use strict";
const { createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const Tree = createFactory(require("devtools/client/shared/components/tree"));
const CensusTreeItem = createFactory(require("./census-tree-item"));
const { createParentMap } = require("../utils");
const { TREE_ROW_HEIGHT } = require("../constants");
const { censusModel, diffingModel } = require("../models");
const Census = module.exports = createClass({
module.exports = createClass({
displayName: "Census",
propTypes: {

View File

@ -2,10 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
"use strict";
const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react");
const { L10N } = require("../utils");
const DominatorTreeHeader = module.exports = createClass({
module.exports = createClass({
displayName: "DominatorTreeHeader",
propTypes: { },

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert, isSavedFrame } = require("devtools/shared/DevToolsUtils");
const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react");
const { L10N, formatNumber, formatPercent } = require("../utils");
@ -16,7 +18,7 @@ const Separator = createFactory(createClass({
}
}));
const DominatorTreeItem = module.exports = createClass({
module.exports = createClass({
displayName: "DominatorTreeItem",
propTypes: {

View File

@ -2,8 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const { assert, safeErrorString } = require("devtools/shared/DevToolsUtils");
const { assert } = require("devtools/shared/DevToolsUtils");
const { createParentMap } = require("devtools/shared/heapsnapshot/CensusUtils");
const Tree = createFactory(require("devtools/client/shared/components/tree"));
const DominatorTreeItem = createFactory(require("./dominator-tree-item"));
@ -21,16 +23,16 @@ const DOMINATOR_TREE_AUTO_EXPAND_DEPTH = 3;
const DominatorTreeSubtreeFetching = createFactory(createClass({
displayName: "DominatorTreeSubtreeFetching",
shouldComponentUpdate(nextProps, nextState) {
return this.props.depth !== nextProps.depth
|| this.props.focused !== nextProps.focused;
},
propTypes: {
depth: PropTypes.number.isRequired,
focused: PropTypes.bool.isRequired,
},
shouldComponentUpdate(nextProps, nextState) {
return this.props.depth !== nextProps.depth
|| this.props.focused !== nextProps.focused;
},
render() {
let {
depth,
@ -103,7 +105,7 @@ const DominatorTreeSiblingLink = createFactory(createClass({
/**
* The actual dominator tree rendered as an expandable and collapsible tree.
*/
const DominatorTree = module.exports = createClass({
module.exports = createClass({
displayName: "DominatorTree",
propTypes: {

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const { assert, safeErrorString } = require("devtools/shared/DevToolsUtils");
const Census = createFactory(require("./census"));
@ -178,7 +180,7 @@ function getError(snapshot, diffing, individuals) {
* state of only a button to take a snapshot, loading states, the census view
* tree, the dominator tree, etc.
*/
const Heap = module.exports = createClass({
module.exports = createClass({
displayName: "Heap",
propTypes: {
@ -202,68 +204,6 @@ const Heap = module.exports = createClass({
sizes: PropTypes.object.isRequired,
},
render() {
let {
snapshot,
diffing,
onSnapshotClick,
onLoadMoreSiblings,
onViewSourceInDebugger,
onViewIndividuals,
individuals,
view,
} = this.props;
if (!diffing && !snapshot && !individuals) {
return this._renderInitial(onSnapshotClick);
}
const state = getState(view, snapshot, diffing, individuals);
const statusText = getStateStatusText(state, diffing);
if (shouldDisplayStatus(state, view, snapshot)) {
return this._renderStatus(state, statusText, diffing);
}
const error = getError(snapshot, diffing, individuals);
if (error) {
return this._renderError(state, statusText, error);
}
if (view.state === viewState.CENSUS || view.state === viewState.DIFFING) {
const census = view.state === viewState.CENSUS
? snapshot.census
: diffing.census;
if (!census) {
return this._renderStatus(state, statusText, diffing);
}
return this._renderCensus(state, census, diffing, onViewSourceInDebugger,
onViewIndividuals);
}
if (view.state === viewState.TREE_MAP) {
return this._renderTreeMap(state, snapshot.treeMap);
}
if (view.state === viewState.INDIVIDUALS) {
assert(individuals.state === individualsState.FETCHED,
"Should have fetched the individuals -- other states are rendered as statuses");
return this._renderIndividuals(state, individuals,
individuals.dominatorTree,
onViewSourceInDebugger);
}
assert(view.state === viewState.DOMINATOR_TREE,
"If we aren't in progress, looking at a census, or diffing, then we " +
"must be looking at a dominator tree");
assert(!diffing, "Should not have diffing");
assert(snapshot.dominatorTree, "Should have a dominator tree");
return this._renderDominatorTree(state, onViewSourceInDebugger, snapshot.dominatorTree,
onLoadMoreSiblings);
},
/**
* Render the heap view's container panel with the given contents inside of
* it.
@ -325,9 +265,10 @@ const Heap = module.exports = createClass({
assert(census.report, "Should not render census that does not have a report");
if (!census.report.children) {
const censusFilterMsg = census.filter ? L10N.getStr("heapview.none-match")
: L10N.getStr("heapview.empty");
const msg = diffing ? L10N.getStr("heapview.no-difference")
: census.filter ? L10N.getStr("heapview.none-match")
: L10N.getStr("heapview.empty");
: censusFilterMsg;
return this._renderHeapView(state, dom.div({ className: "empty" }, msg));
}
@ -452,4 +393,67 @@ const Heap = module.exports = createClass({
})
);
},
render() {
let {
snapshot,
diffing,
onSnapshotClick,
onLoadMoreSiblings,
onViewSourceInDebugger,
onViewIndividuals,
individuals,
view,
} = this.props;
if (!diffing && !snapshot && !individuals) {
return this._renderInitial(onSnapshotClick);
}
const state = getState(view, snapshot, diffing, individuals);
const statusText = getStateStatusText(state, diffing);
if (shouldDisplayStatus(state, view, snapshot)) {
return this._renderStatus(state, statusText, diffing);
}
const error = getError(snapshot, diffing, individuals);
if (error) {
return this._renderError(state, statusText, error);
}
if (view.state === viewState.CENSUS || view.state === viewState.DIFFING) {
const census = view.state === viewState.CENSUS
? snapshot.census
: diffing.census;
if (!census) {
return this._renderStatus(state, statusText, diffing);
}
return this._renderCensus(state, census, diffing, onViewSourceInDebugger,
onViewIndividuals);
}
if (view.state === viewState.TREE_MAP) {
return this._renderTreeMap(state, snapshot.treeMap);
}
if (view.state === viewState.INDIVIDUALS) {
assert(individuals.state === individualsState.FETCHED,
"Should have fetched the individuals -- " +
"other states are rendered as statuses");
return this._renderIndividuals(state, individuals,
individuals.dominatorTree,
onViewSourceInDebugger);
}
assert(view.state === viewState.DOMINATOR_TREE,
"If we aren't in progress, looking at a census, or diffing, then we " +
"must be looking at a dominator tree");
assert(!diffing, "Should not have diffing");
assert(snapshot.dominatorTree, "Should have a dominator tree");
return this._renderDominatorTree(state, onViewSourceInDebugger,
snapshot.dominatorTree,
onLoadMoreSiblings);
},
});

View File

@ -2,10 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
"use strict";
const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react");
const { L10N } = require("../utils");
const IndividualsHeader = module.exports = createClass({
module.exports = createClass({
displayName: "IndividualsHeader",
propTypes: { },

View File

@ -2,19 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const { assert } = require("devtools/shared/DevToolsUtils");
const { createParentMap } = require("devtools/shared/heapsnapshot/CensusUtils");
"use strict";
const { createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const Tree = createFactory(require("devtools/client/shared/components/tree"));
const DominatorTreeItem = createFactory(require("./dominator-tree-item"));
const { L10N } = require("../utils");
const { TREE_ROW_HEIGHT } = require("../constants");
const models = require("../models");
/**
* The list of individuals in a census group.
*/
const Individuals = module.exports = createClass({
module.exports = createClass({
displayName: "Individuals",
propTypes: {

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
/**
@ -9,7 +11,7 @@ const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/ven
* the children nodes as `itemComponent`, and a list of items to render
* as that component with a click handler.
*/
const List = module.exports = createClass({
module.exports = createClass({
displayName: "List",
propTypes: {

View File

@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {
@ -29,7 +30,8 @@ function stringifyLabel(label, id) {
if (isSavedFrame(piece)) {
const { short } = getSourceNames(piece.source);
sanitized[i] = `${piece.functionDisplayName} @ ${short}:${piece.line}:${piece.column}`;
sanitized[i] = `${piece.functionDisplayName} @ ` +
`${short}:${piece.line}:${piece.column}`;
} else if (piece === NO_STACK) {
sanitized[i] = L10N.getStr("tree-item.nostack");
} else if (piece === NO_FILENAME) {
@ -62,16 +64,16 @@ module.exports = createClass({
return { zoom: null };
},
shouldComponentUpdate(nextProps) {
return this.props.graph != nextProps.graph;
},
componentDidMount() {
if (this.props.graph) {
this._renderGraph(this.refs.container, this.props.graph);
}
},
shouldComponentUpdate(nextProps) {
return this.props.graph != nextProps.graph;
},
componentDidUpdate() {
if (this.props.graph) {
this._renderGraph(this.refs.container, this.props.graph);
@ -84,44 +86,6 @@ module.exports = createClass({
}
},
render() {
let contents;
if (this.props.graph) {
// Let the componentDidMount or componentDidUpdate method draw the graph
// with DagreD3. We just provide the container for the graph here.
contents = dom.div({
ref: "container",
style: {
flex: 1,
height: "100%",
width: "100%",
}
});
} else {
contents = dom.div(
{
id: "shortest-paths-select-node-msg"
},
L10N.getStr("shortest-paths.select-node")
);
}
return dom.div(
{
id: "shortest-paths",
className: "vbox",
},
dom.label(
{
id: "shortest-paths-header",
className: "header",
},
L10N.getStr("shortest-paths.header")
),
contents
);
},
_renderGraph(container, { nodes, edges }) {
if (!container.firstChild) {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@ -181,4 +145,42 @@ module.exports = createClass({
const layout = dagreD3.layout();
renderer.layout(layout).run(graph, target);
},
render() {
let contents;
if (this.props.graph) {
// Let the componentDidMount or componentDidUpdate method draw the graph
// with DagreD3. We just provide the container for the graph here.
contents = dom.div({
ref: "container",
style: {
flex: 1,
height: "100%",
width: "100%",
}
});
} else {
contents = dom.div(
{
id: "shortest-paths-select-node-msg"
},
L10N.getStr("shortest-paths.select-node")
);
}
return dom.div(
{
id: "shortest-paths",
className: "vbox",
},
dom.label(
{
id: "shortest-paths-header",
className: "header",
},
L10N.getStr("shortest-paths.header")
),
contents
);
},
});

View File

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { assert } = require("devtools/shared/DevToolsUtils");
"use strict";
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
const {
L10N,
@ -12,15 +13,10 @@ const {
snapshotIsDiffable,
getSavedCensus
} = require("../utils");
const {
snapshotState: states,
diffingState,
censusState,
treeMapState
} = require("../constants");
const { diffingState } = require("../constants");
const { snapshot: snapshotModel } = require("../models");
const SnapshotListItem = module.exports = createClass({
module.exports = createClass({
displayName: "SnapshotListItem",
propTypes: {
@ -32,7 +28,7 @@ const SnapshotListItem = module.exports = createClass({
},
render() {
let { index, item: snapshot, onClick, onSave, onDelete, diffing } = this.props;
let { item: snapshot, onClick, onSave, onDelete, diffing } = this.props;
let className = `snapshot-list-item ${snapshot.selected ? " selected" : ""}`;
let statusText = getStatusText(snapshot.state);
let wantThrobber = !!statusText;
@ -75,7 +71,8 @@ const SnapshotListItem = module.exports = createClass({
// If there is census data, fill in the total bytes.
if (census) {
let { bytes } = getSnapshotTotals(census);
let formatBytes = L10N.getFormatStr("aggregate.mb", L10N.numberWithDecimals(bytes / 1000000, 2));
let formatBytes = L10N.getFormatStr("aggregate.mb",
L10N.numberWithDecimals(bytes / 1000000, 2));
details = dom.span({ className: "snapshot-totals" },
dom.span({ className: "total-bytes" }, formatBytes)
@ -99,7 +96,9 @@ const SnapshotListItem = module.exports = createClass({
return (
dom.li({ className, onClick },
dom.span({ className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}` },
dom.span({
className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}`
},
checkbox,
title,
deleteButton

View File

@ -260,7 +260,8 @@ module.exports = createClass({
dom.button(
{
id: "diff-snapshots",
className: "devtools-button devtools-monospace" + (!!diffing ? " checked" : ""),
className: "devtools-button devtools-monospace" +
(diffing ? " checked" : ""),
disabled: snapshots.length < 2,
onClick: onToggleDiffing,
title: L10N.getStr("diff-snapshots.tooltip"),

View File

@ -9,12 +9,12 @@ const { treeMapModel } = require("../models");
const startVisualization = require("./tree-map/start");
module.exports = createClass({
displayName: "TreeMap",
propTypes: {
treeMap: treeMapModel
},
displayName: "TreeMap",
getInitialState() {
return {};
},

View File

@ -51,7 +51,7 @@ Canvases.prototype = {
*
* @return {type} description
*/
destroy : function () {
destroy: function () {
this.removeHandlers();
this.container.removeChild(this.main.canvas);
this.container.removeChild(this.zoom.canvas);

View File

@ -238,7 +238,6 @@ function setScrollHandlers(container, dragZoom, emitChanged, update) {
let scrollDelta = getScrollDelta(event, window);
let prevZoom = dragZoom.zoom;
dragZoom.zoom = Math.max(0, dragZoom.zoom - scrollDelta * ZOOM_SPEED);
let deltaZoom = dragZoom.zoom - prevZoom;
// Calculate the updated width and height
let prevZoomedWidth = container.offsetWidth * (1 + prevZoom);

View File

@ -122,7 +122,10 @@ actions.RESIZE_SHORTEST_PATHS = "resize-shortest-paths";
const COUNT = Object.freeze({ by: "count", count: true, bytes: true });
const INTERNAL_TYPE = Object.freeze({ by: "internalType", then: COUNT });
const ALLOCATION_STACK = Object.freeze({ by: "allocationStack", then: COUNT, noStack: COUNT });
const ALLOCATION_STACK = Object.freeze({
by: "allocationStack", then: COUNT,
noStack: COUNT
});
const OBJECT_CLASS = Object.freeze({ by: "objectClass", then: COUNT, other: COUNT });
const COARSE_TYPE = Object.freeze({
by: "coarseType",

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* The `DominatorTreeLazyChildren` is a placeholder that represents a future
* subtree in an existing `DominatorTreeNode` tree that is currently being

View File

@ -2,9 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* exported initialize, destroy */
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const { utils: Cu } = Components;
const BrowserLoaderModule = {};
Cu.import("resource://devtools/client/shared/browser-loader.js", BrowserLoaderModule);
const { require } = BrowserLoaderModule.BrowserLoader({
@ -20,19 +22,21 @@ const Store = require("devtools/client/memory/store");
const { assert } = require("devtools/shared/DevToolsUtils");
/**
* The current target, toolbox, MemoryFront, and HeapAnalysesClient, set by this tool's host.
* The current target, toolbox, MemoryFront, and HeapAnalysesClient,
* set by this tool's host.
*/
var gToolbox, gTarget, gFront, gHeapAnalysesClient;
var gToolbox, gFront, gHeapAnalysesClient;
/**
* Variables set by `initialize()`
*/
var gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted, telemetry;
var gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted;
var initialize = Task.async(function* () {
gRoot = document.querySelector("#app");
gStore = Store();
gApp = createElement(App, { toolbox: gToolbox, front: gFront, heapWorker: gHeapAnalysesClient });
gApp = createElement(App,
{ toolbox: gToolbox, front: gFront, heapWorker: gHeapAnalysesClient });
gProvider = createElement(Provider, { store: gStore }, gApp);
ReactDOM.render(gProvider, gRoot);
unsubscribe = gStore.subscribe(onStateChange);
@ -44,7 +48,7 @@ var destroy = Task.async(function* () {
unsubscribe();
gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted;
gStore = gRoot = gApp = gProvider = unsubscribe = isHighlighted = null;
});
/**

View File

@ -2,6 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global treeMapState, censusState */
/* eslint no-shadow: ["error", { "allow": ["app"] }] */
"use strict";
const { assert } = require("devtools/shared/DevToolsUtils");
const { MemoryFront } = require("devtools/shared/fronts/memory");
const HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient");
@ -39,7 +44,9 @@ function catchAndIgnore(fn) {
return function (...args) {
try {
fn(...args);
} catch (err) { }
} catch (err) {
// continue regardless of error
}
return null;
};
@ -103,6 +110,7 @@ const treeMapModel = exports.treeMapModel = PropTypes.shape({
assert(!treeMap.report, "Should not have a report");
assert(!treeMap.error, "Should not have an error");
break;
case treeMapState.SAVED:
assert(treeMap.report, "Should have a report");
assert(!treeMap.error, "Should not have an error");
@ -443,7 +451,7 @@ const individualsModel = exports.individuals = PropTypes.shape({
}),
});
let appModel = exports.app = {
exports.app = {
// {MemoryFront} Used to communicate with platform
front: PropTypes.instanceOf(MemoryFront),
@ -494,7 +502,7 @@ let appModel = exports.app = {
break;
default:
assert(false, `Unexpected type of view: ${view.state}`);
assert(false, `Unexpected type of view: ${app.view.state}`);
}
})(app);
@ -512,7 +520,7 @@ let appModel = exports.app = {
break;
default:
assert(false, `Unexpected type of view: ${view.state}`);
assert(false, `Unexpected type of view: ${app.view.state}`);
}
})(app);
},

View File

@ -4,12 +4,10 @@
"use strict";
const { Cc, Ci, Cu, Cr } = require("chrome");
const { Task } = require("devtools/shared/task");
const EventEmitter = require("devtools/shared/event-emitter");
const { MemoryFront } = require("devtools/shared/fronts/memory");
const HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient");
const promise = require("promise");
function MemoryPanel(iframeWindow, toolbox) {
this.panelWin = iframeWindow;

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert } = require("devtools/shared/DevToolsUtils");
const { actions } = require("../constants");

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { ERROR_TYPE: TASK_ERROR_TYPE } = require("devtools/client/shared/redux/middleware/task");
/**

View File

@ -8,7 +8,7 @@ const { actions } = require("../constants");
module.exports = function (filterString = null, action) {
if (action.type === actions.SET_FILTER_STRING) {
return action.filter || null;
} else {
return filterString;
}
return filterString;
};

View File

@ -240,23 +240,24 @@ handlers[actions.COMPUTE_DOMINATOR_TREE_START] = function (snapshots, { id }) {
});
};
handlers[actions.COMPUTE_DOMINATOR_TREE_END] = function (snapshots, { id, dominatorTreeId }) {
return snapshots.map(snapshot => {
if (snapshot.id !== id) {
return snapshot;
}
handlers[actions.COMPUTE_DOMINATOR_TREE_END] =
function (snapshots, { id, dominatorTreeId }) {
return snapshots.map(snapshot => {
if (snapshot.id !== id) {
return snapshot;
}
assert(snapshot.dominatorTree, "Should have a dominator tree model");
assert(snapshot.dominatorTree.state == dominatorTreeState.COMPUTING,
"Should be in the COMPUTING state");
assert(snapshot.dominatorTree, "Should have a dominator tree model");
assert(snapshot.dominatorTree.state == dominatorTreeState.COMPUTING,
"Should be in the COMPUTING state");
const dominatorTree = immutableUpdate(snapshot.dominatorTree, {
state: dominatorTreeState.COMPUTED,
dominatorTreeId,
const dominatorTree = immutableUpdate(snapshot.dominatorTree, {
state: dominatorTreeState.COMPUTED,
dominatorTreeId,
});
return immutableUpdate(snapshot, { dominatorTree });
});
return immutableUpdate(snapshot, { dominatorTree });
});
};
};
handlers[actions.FETCH_DOMINATOR_TREE_START] = function (snapshots, { id, display }) {
return snapshots.map(snapshot => {
@ -267,7 +268,8 @@ handlers[actions.FETCH_DOMINATOR_TREE_START] = function (snapshots, { id, displa
assert(snapshot.dominatorTree, "Should have a dominator tree model");
assert(snapshot.dominatorTree.state !== dominatorTreeState.COMPUTING &&
snapshot.dominatorTree.state !== dominatorTreeState.ERROR,
`Should have already computed the dominator tree, found state = ${snapshot.dominatorTree.state}`);
"Should have already computed the dominator tree, found state = " +
snapshot.dominatorTree.state);
const dominatorTree = immutableUpdate(snapshot.dominatorTree, {
state: dominatorTreeState.FETCHING,

View File

@ -2,10 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { combineReducers } = require("../shared/vendor/redux");
const createStore = require("../shared/redux/create-store");
const reducers = require("./reducers");
const { viewState } = require("./constants");
const flags = require("devtools/shared/flags");
module.exports = function () {

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// This module exports methods to record telemetry data for memory tool usage.
//
// NB: Ensure that *every* exported function is wrapped in `makeInfallible` so
@ -10,7 +12,7 @@
const { telemetry } = require("Services");
const { makeInfallible, immutableUpdate } = require("devtools/shared/DevToolsUtils");
const { labelDisplays, treeMapDisplays, censusDisplays } = require("./constants");
const { labelDisplays, censusDisplays } = require("./constants");
exports.countTakeSnapshot = makeInfallible(function () {
const histogram = telemetry.getHistogramById("DEVTOOLS_MEMORY_TAKE_SNAPSHOT_COUNT");
@ -80,7 +82,8 @@ exports.countDominatorTree = makeInfallible(function ({ display }) {
let histogram = telemetry.getHistogramById("DEVTOOLS_MEMORY_DOMINATOR_TREE_COUNT");
histogram.add(1);
histogram = telemetry.getKeyedHistogramById("DEVTOOLS_MEMORY_BREAKDOWN_DOMINATOR_TREE_COUNT");
histogram =
telemetry.getKeyedHistogramById("DEVTOOLS_MEMORY_BREAKDOWN_DOMINATOR_TREE_COUNT");
if (display === labelDisplays.coarseType) {
histogram.add(COARSE_TYPE);
} else if (display === labelDisplays.allocationStack) {

View File

@ -2,5 +2,16 @@
module.exports = {
// Extend from the shared list of defined globals for mochitests.
"extends": "../../../../.eslintrc.mochitests.js"
"extends": "../../../../.eslintrc.mochitests.js",
"globals": {
"addTab": true,
"censusState": true,
"refreshTab": true,
"removeTab": true,
"waitForTime": true,
"waitUntilState": true
},
"rules": {
"no-unused-vars": ["error", { "vars": "local", "args": "none" }],
}
};

View File

@ -1,36 +1,38 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests taking and then clearing snapshots.
*/
const { treeMapState } = require("devtools/client/memory/constants");
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
const { treeMapState } = require("devtools/client/memory/constants");
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const { gStore, document } = panel.panelWin;
const { getState, dispatch } = gStore;
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const { gStore, document } = panel.panelWin;
const { getState } = gStore;
let snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 0, "Starts with no snapshots in store");
is(snapshotEls.length, 0, "No snapshots visible");
let snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 0, "Starts with no snapshots in store");
is(snapshotEls.length, 0, "No snapshots visible");
info("Take two snapshots");
takeSnapshot(panel.panelWin);
takeSnapshot(panel.panelWin);
yield waitUntilState(gStore, state =>
state.snapshots.length === 2 &&
state.snapshots[0].treeMap && state.snapshots[1].treeMap &&
state.snapshots[0].treeMap.state === treeMapState.SAVED &&
state.snapshots[1].treeMap.state === treeMapState.SAVED);
info("Take two snapshots");
takeSnapshot(panel.panelWin);
takeSnapshot(panel.panelWin);
yield waitUntilState(gStore, state =>
state.snapshots.length === 2 &&
state.snapshots[0].treeMap && state.snapshots[1].treeMap &&
state.snapshots[0].treeMap.state === treeMapState.SAVED &&
state.snapshots[1].treeMap.state === treeMapState.SAVED);
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(snapshotEls.length, 2, "Two snapshots visible");
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(snapshotEls.length, 2, "Two snapshots visible");
info("Click on Clear Snapshots");
yield clearSnapshots(panel.panelWin);
is(getState().snapshots.length, 0, "No snapshots in store");
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(snapshotEls.length, 0, "No snapshot visible");
});
info("Click on Clear Snapshots");
yield clearSnapshots(panel.panelWin);
is(getState().snapshots.length, 0, "No snapshots in store");
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(snapshotEls.length, 0, "No snapshot visible");
});

View File

@ -6,7 +6,6 @@
"use strict";
const {
snapshotState,
diffingState,
treeMapState
} = require("devtools/client/memory/constants");
@ -14,10 +13,8 @@ const {
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const { getState } = store;
const doc = panel.panelWin.document;
ok(!getState().diffing, "Not diffing by default.");

View File

@ -111,7 +111,9 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
// Find the most up-to-date version of the node whose children we just
// incrementally fetched.
const newDeepest = (function findNewDeepest(node = getState().snapshots[0].dominatorTree.root) {
const newDeepest = (function findNewDeepest(node = getState().snapshots[0]
.dominatorTree
.root) {
if (node.nodeId === deepest.nodeId) {
return node;
}

View File

@ -7,7 +7,6 @@
const {
dominatorTreeState,
snapshotState,
viewState,
censusState,
} = require("devtools/client/memory/constants");
@ -17,9 +16,8 @@ const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const { dispatch } = store;
const doc = panel.panelWin.document;
dispatch(changeView(viewState.CENSUS));
@ -49,7 +47,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
let nameElem = doc.querySelector(".heap-tree-item-field.heap-tree-item-name");
ok(nameElem, "Should get a tree item row with a name");
is(nameElem.textContent.trim(), "js::Shape", "the tree item should be the one we filtered for");
is(nameElem.textContent.trim(), "js::Shape",
"the tree item should be the one we filtered for");
is(filterInput.value, "js::Shape",
"and filter input contains the user value");

View File

@ -11,15 +11,13 @@ const {
viewState,
censusState,
} = require("devtools/client/memory/constants");
const { changeViewAndRefresh, changeView } = require("devtools/client/memory/actions/view");
const { changeView } = require("devtools/client/memory/actions/view");
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const { dispatch } = store;
const doc = panel.panelWin.document;
dispatch(changeView(viewState.CENSUS));

View File

@ -6,7 +6,6 @@
"use strict";
const {
snapshotState,
viewState,
censusState
} = require("devtools/client/memory/constants");

View File

@ -7,7 +7,6 @@
"use strict";
const {
snapshotState,
censusState,
viewState
} = require("devtools/client/memory/constants");

View File

@ -35,5 +35,6 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
"Should still not be recording allocagtions");
ok(doc.querySelector(".no-allocation-stacks"),
"Because we did not record allocations, the no-allocation-stack warning should be visible");
"Because we did not record allocations, " +
"the no-allocation-stack warning should be visible");
});

View File

@ -27,7 +27,9 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
EventUtils.synthesizeMouseAtCenter(recordingCheckbox, {}, panel.panelWin);
is(getState().allocations.recording, true);
const nameElems = [...doc.querySelectorAll(".heap-tree-item-field.heap-tree-item-name")];
const nameElems = [
...doc.querySelectorAll(".heap-tree-item-field.heap-tree-item-name")
];
for (let el of nameElems) {
dumpn(`Found ${el.textContent.trim()}`);

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* global ChromeUtils */
// Test that refreshing the page with devtools open does not leak the old
// windows from previous navigations.
//
@ -9,7 +11,6 @@
"use strict";
const HeapSnapshotFileUtils = require("devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
const { getLabelAndShallowSize } = require("devtools/shared/heapsnapshot/DominatorTreeNode");
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_empty.html";
@ -50,14 +51,11 @@ const DESCRIPTION = {
};
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const doc = panel.panelWin.document;
const startWindows = yield getWindowsInSnapshot(front);
dumpn("Initial windows found = " + startWindows.map(w => "0x" + w.toString(16)).join(", "));
dumpn("Initial windows found = " + startWindows.map(w => "0x" +
w.toString(16)).join(", "));
is(startWindows.length, 1);
yield refreshTab(tab);
@ -84,7 +82,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const paths = snapshot.computeShortestPaths(dominatorTree.root, startWindows, 50);
for (let i = 0; i < startWindows.length; i++) {
dumpn("Shortest retaining paths for leaking Window 0x" + startWindows[i].toString(16) + " =========================");
dumpn("Shortest retaining paths for leaking Window 0x" +
startWindows[i].toString(16) + " =========================");
let j = 0;
for (let retainingPath of paths.get(startWindows[i])) {
if (retainingPath.find(part => part.predecessor === startWindows[i])) {
@ -92,7 +91,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
continue;
}
dumpn(" Path #" + (++j) + ": --------------------------------------------------------------------");
dumpn(" Path #" + (++j) +
": --------------------------------------------------------------------");
for (let part of retainingPath) {
const { label } = getLabelAndShallowSize(part.predecessor, snapshot, DESCRIPTION);
dumpn(" 0x" + part.predecessor.toString(16) +

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests taking snapshots and default states.
*/
@ -23,17 +25,20 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 1, "One snapshot was created in store");
is(snapshotEls.length, 1, "One snapshot was rendered");
ok(snapshotEls[0].classList.contains("selected"), "Only snapshot has `selected` class");
ok(snapshotEls[0].classList.contains("selected"),
"Only snapshot has `selected` class");
yield takeSnapshot(panel.panelWin);
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 2, "Two snapshots created in store");
is(snapshotEls.length, 2, "Two snapshots rendered");
ok(!snapshotEls[0].classList.contains("selected"), "First snapshot no longer has `selected` class");
ok(snapshotEls[1].classList.contains("selected"), "Second snapshot has `selected` class");
ok(!snapshotEls[0].classList.contains("selected"),
"First snapshot no longer has `selected` class");
ok(snapshotEls[1].classList.contains("selected"),
"Second snapshot has `selected` class");
yield waitUntilCensusState(gStore, s => s.census, [censusState.SAVED,
censusState.SAVED]);
yield waitUntilCensusState(gStore, s => s.census,
[censusState.SAVED, censusState.SAVED]);
ok(document.querySelector(".heap-tree-item-name"),
"Should have rendered some tree items");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* global ChromeUtils, HeapSnapshot */
// Test that we can save a heap snapshot and transfer it over the RDP in e10s
// where the child process is sandboxed and so we have to use
// HeapSnapshotFileActor to get the heap snapshot file.

View File

@ -23,8 +23,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
width: "100px",
height: "200px",
position: "absolute",
left:0,
top:0
left: 0,
top: 0
});
let rafMock = createRAFMock();
@ -78,8 +78,6 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
info("Dragging correctly translates the div");
{
let initialX = dragZoom.translateX;
let initialY = dragZoom.translateY;
div.dispatchEvent(new MouseEvent("mousemove", {
clientX: 10,
clientY: 10,

View File

@ -1,15 +1,17 @@
<!DOCTYPE html>
<html>
<body>
<script>
window.big = (function makeBig(depth = 0) {
var big = Array(5);
big.fill(undefined);
if (depth < 5) {
big = big.map(_ => makeBig(depth + 1));
}
return big;
}());
</script>
</body>
<body>
<script>
"use strict";
window.big = (function makeBig(depth = 0) {
let big = Array(5);
big.fill(undefined);
if (depth < 5) {
big = big.map(_ => makeBig(depth + 1));
}
return big;
}());
</script>
</body>
</html>

View File

@ -1,16 +1,18 @@
<!DOCTYPE html>
<html>
<body>
<script>
var objects = window.objects = [];
<body>
<script>
"use strict";
var allocate = this.allocate = function allocate() {
for (var i = 0; i < 100; i++)
objects.push({});
setTimeout(allocate, 10);
}
var objects = window.objects = [];
var allocate = this.allocate = function allocate() {
for (let i = 0; i < 100; i++) {
objects.push({});
}
setTimeout(allocate, 10);
};
allocate();
</script>
</body>
allocate();
</script>
</body>
</html>

View File

@ -109,7 +109,8 @@ function takeSnapshot(window) {
let snapshotCount = gStore.getState().snapshots.length;
info("Taking snapshot...");
document.querySelector(".devtools-toolbar .take-snapshot").click();
return waitUntilState(gStore, () => gStore.getState().snapshots.length === snapshotCount + 1);
return waitUntilState(gStore,
() => gStore.getState().snapshots.length === snapshotCount + 1);
}
function clearSnapshots(window) {
@ -176,7 +177,6 @@ function waitUntilSnapshotSelected(store, snapshotIndex) {
state.snapshots[snapshotIndex].selected === true);
}
/**
* Wait until the state has censuses in a certain state.
*
@ -219,7 +219,7 @@ function createRAFMock() {
mock.nextFrame = function () {
let thisQueue = queuedFns;
queuedFns = [];
for (var i = 0; i < thisQueue.length; i++) {
for (let i = 0; i < thisQueue.length; i++) {
thisQueue[i]();
}
};

View File

@ -0,0 +1,14 @@
"use strict";
module.exports = {
// Extend from the shared list of defined globals for mochitests.
"extends": "../../../../.eslintrc.mochitests.js",
"globals": {
"SimpleTest": true,
"ok": true,
"requestAnimationFrame": true
},
"rules": {
"no-unused-vars": ["error", { "vars": "local", "args": "none" }],
}
};

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
@ -17,8 +18,9 @@ var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0;
SimpleTest.registerCleanupFunction(function () {
if (DevToolsUtils.assertionFailureCount !== EXPECTED_DTU_ASSERT_FAILURE_COUNT) {
ok(false, "Should have had the expected number of DevToolsUtils.assert() failures. Expected " +
EXPECTED_DTU_ASSERT_FAILURE_COUNT + ", got " + DevToolsUtils.assertionFailureCount);
ok(false, "Should have had the expected number of DevToolsUtils.assert() failures." +
"Expected " + EXPECTED_DTU_ASSERT_FAILURE_COUNT +
", got " + DevToolsUtils.assertionFailureCount);
}
});
@ -115,7 +117,9 @@ function makeTestDominatorTreeNode(opts, children) {
}, opts);
if (children && children.length) {
children.map(c => c.parentId = node.nodeId);
children.map(c => {
c.parentId = node.nodeId;
});
}
return node;

View File

@ -2,5 +2,11 @@
module.exports = {
// Extend from the shared list of defined globals for mochitests.
"extends": "../../../../.eslintrc.xpcshell.js"
"extends": "../../../../.eslintrc.xpcshell.js",
"rules": {
"no-unused-vars": ["error", {
"vars": "local",
"varsIgnorePattern": "^run_test$"
}]
}
};

View File

@ -26,7 +26,8 @@ var HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClien
var { addDebuggerToGlobal } = require("resource://gre/modules/jsdebugger.jsm");
var Store = require("devtools/client/memory/store");
var { L10N } = require("devtools/client/memory/utils");
var SYSTEM_PRINCIPAL = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
var SYSTEM_PRINCIPAL =
Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0;
@ -59,17 +60,20 @@ StubbedMemoryFront.prototype.detach = Task.async(function* () {
this.state = "detached";
});
StubbedMemoryFront.prototype.saveHeapSnapshot = expectState("attached", Task.async(function* () {
return ThreadSafeChromeUtils.saveHeapSnapshot({ runtime: true });
}), "saveHeapSnapshot");
StubbedMemoryFront.prototype.saveHeapSnapshot = expectState("attached",
Task.async(function* () {
return ThreadSafeChromeUtils.saveHeapSnapshot({ runtime: true });
}), "saveHeapSnapshot");
StubbedMemoryFront.prototype.startRecordingAllocations = expectState("attached", Task.async(function* () {
this.recordingAllocations = true;
}));
StubbedMemoryFront.prototype.startRecordingAllocations = expectState("attached",
Task.async(function* () {
this.recordingAllocations = true;
}));
StubbedMemoryFront.prototype.stopRecordingAllocations = expectState("attached", Task.async(function* () {
this.recordingAllocations = false;
}));
StubbedMemoryFront.prototype.stopRecordingAllocations = expectState("attached",
Task.async(function* () {
this.recordingAllocations = false;
}));
function waitUntilSnapshotState(store, expected) {
let predicate = () => {

View File

@ -1,10 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes snapshots with READ censuses
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");
let { snapshotState: states, actions } = require("devtools/client/memory/constants");
let { actions } = require("devtools/client/memory/constants");
const { treeMapState } = require("devtools/client/memory/constants");
function run_test() {

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots preserves snapshots with state != READ or ERROR
let { takeSnapshotAndCensus, clearSnapshots, takeSnapshot } = require("devtools/client/memory/actions/snapshot");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes snapshots with state ERROR
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes several snapshots
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");
@ -22,8 +24,7 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.treeMap,
[treeMapState.SAVED, treeMapState.SAVED,
treeMapState.SAVED]);
[treeMapState.SAVED, treeMapState.SAVED, treeMapState.SAVED]);
ok(true, "snapshots created with a saved census");
ok(true, "set first snapshot state to error");

View File

@ -1,10 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes several snapshots
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");
let { snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants");
let { actions, treeMapState } = require("devtools/client/memory/constants");
function run_test() {
run_next_test();

View File

@ -10,7 +10,6 @@ const {
clearSnapshots
} = require("devtools/client/memory/actions/snapshot");
const {
snapshotState: states,
actions,
treeMapState
} = require("devtools/client/memory/constants");

View File

@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test exporting a snapshot to a user specified location on disk.
let { exportSnapshot } = require("devtools/client/memory/actions/io");
let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot");
let { snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants");
let { actions, treeMapState } = require("devtools/client/memory/constants");
function run_test() {
run_next_test();
@ -30,7 +32,7 @@ add_task(function* () {
dispatch(exportSnapshot(getState().snapshots[0], destPath));
yield exportEvents;
stat = yield OS.File.stat(destPath);
let stat = yield OS.File.stat(destPath);
do_print(stat.size);
ok(stat.size > 0, "destination file is more than 0 bytes");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test setting the filter string.
let { setFilterString } = require("devtools/client/memory/actions/filter");

View File

@ -1,13 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that changing filter state properly refreshes the selected census.
let { snapshotState: states, viewState, censusState } = require("devtools/client/memory/constants");
let { viewState, censusState } = require("devtools/client/memory/constants");
let { setFilterStringAndRefresh } = require("devtools/client/memory/actions/filter");
let { takeSnapshotAndCensus, selectSnapshotAndRefresh } = require("devtools/client/memory/actions/snapshot");
let { setCensusDisplay } = require("devtools/client/memory/actions/census-display");
let { changeView } = require("devtools/client/memory/actions/view");
function run_test() {
@ -30,24 +30,18 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
ok(true, "saved 3 snapshots and took a census of each of them");
dispatch(setFilterStringAndRefresh("str", heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVING]);
[censusState.SAVED, censusState.SAVED, censusState.SAVING]);
ok(true, "setting filter string should recompute the selected snapshot's census");
equal(getState().filter, "str", "now inverted");
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[0].census.filter, null);
equal(getState().snapshots[1].census.filter, null);
@ -55,15 +49,11 @@ add_task(function* () {
dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVING,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVING, censusState.SAVED]);
ok(true, "selecting non-inverted census should trigger a recompute");
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[0].census.filter, null);
equal(getState().snapshots[1].census.filter, "str");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that changing filter state in the middle of taking a snapshot results in
// the properly fitered census.

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
@ -61,13 +62,19 @@ add_task(function* () {
let unsubscribe = subscribe(expectStates);
dispatch(importSnapshotAndCensus(heapWorker, destPath));
yield waitUntilState(store, () => { return snapshotI === snapshotStates.length &&
censusI === censusStates.length; });
yield waitUntilState(store, () => {
return snapshotI === snapshotStates.length &&
censusI === censusStates.length;
});
unsubscribe();
equal(snapshotI, snapshotStates.length, "importSnapshotAndCensus() produces the correct sequence of states in a snapshot");
equal(getState().snapshots[1].state, states.READ, "imported snapshot is in READ state");
equal(censusI, censusStates.length, "importSnapshotAndCensus() produces the correct sequence of states in a census");
equal(getState().snapshots[1].treeMap.state, treeMapState.SAVED, "imported snapshot is in READ state");
equal(snapshotI, snapshotStates.length,
"importSnapshotAndCensus() produces the correct sequence of states in a snapshot");
equal(getState().snapshots[1].state, states.READ,
"imported snapshot is in READ state");
equal(censusI, censusStates.length,
"importSnapshotAndCensus() produces the correct sequence of states in a census");
equal(getState().snapshots[1].treeMap.state, treeMapState.SAVED,
"imported snapshot is in READ state");
ok(getState().snapshots[1].selected, "imported snapshot is selected");
// Check snapshot data
@ -82,7 +89,8 @@ add_task(function* () {
let census1 = stripUnique(JSON.parse(JSON.stringify(snapshot1.treeMap.report)));
let census2 = stripUnique(JSON.parse(JSON.stringify(snapshot2.treeMap.report)));
equal(JSON.stringify(census1), JSON.stringify(census2), "Imported snapshot has correct census");
equal(JSON.stringify(census1), JSON.stringify(census2),
"Imported snapshot has correct census");
function stripUnique(obj) {
let children = obj.children || [];

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the reducer responding to the action `selectSnapshot(snapshot)`
*/
@ -21,7 +23,8 @@ add_task(function* () {
store.dispatch(actions.takeSnapshot(front));
}
yield waitUntilState(store, ({ snapshots }) => snapshots.length === 5 && snapshots.every(isDone));
yield waitUntilState(store,
({ snapshots }) => snapshots.length === 5 && snapshots.every(isDone));
for (let i = 0; i < 5; i++) {
do_print(`Selecting snapshot[${i}]`);
@ -30,8 +33,11 @@ add_task(function* () {
let { snapshots } = store.getState();
ok(snapshots[i].selected, `snapshot[${i}] selected`);
equal(snapshots.filter(s => !s.selected).length, 4, "All other snapshots are unselected");
equal(snapshots.filter(s => !s.selected).length, 4,
"All other snapshots are unselected");
}
});
function isDone(s) { return s.state === states.SAVED; }
function isDone(s) {
return s.state === states.SAVED;
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
@ -9,7 +10,7 @@
* `setCensusDisplayAndRefresh`.
*/
let { censusDisplays, snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants");
let { censusDisplays, censusState, viewState } = require("devtools/client/memory/constants");
let { setCensusDisplayAndRefresh } = require("devtools/client/memory/actions/census-display");
let { takeSnapshotAndCensus, selectSnapshotAndRefresh } = require("devtools/client/memory/actions/snapshot");
const { changeView } = require("devtools/client/memory/actions/view");
@ -63,51 +64,49 @@ add_task(function* () {
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[1].census.display, censusDisplays.coarseType,
"Changing display while saving a snapshot results in a census using the new display");
"Changing display while saving a snapshot results " +
"in a census using the new display");
// Updates when changing display during `SAVING_CENSUS`
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVING]);
[censusState.SAVED, censusState.SAVED, censusState.SAVING]);
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[2].census.display, censusDisplays.allocationStack,
"Display can be changed while saving census, stores updated display in snapshot");
// Updates census on currently selected snapshot when changing display
ok(getState().snapshots[2].selected, "Third snapshot currently selected");
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.coarseType));
yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVING);
yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVED);
yield waitUntilState(store,
state => state.snapshots[2].census.state === censusState.SAVING);
yield waitUntilState(store,
state => state.snapshots[2].census.state === censusState.SAVED);
equal(getState().snapshots[2].census.display, censusDisplays.coarseType,
"Snapshot census updated when changing displays after already generating one census");
"Snapshot census updated when changing displays " +
"after already generating one census");
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack));
yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVED);
yield waitUntilState(store,
state => state.snapshots[2].census.state === censusState.SAVED);
equal(getState().snapshots[2].census.display, censusDisplays.allocationStack,
"Snapshot census updated when changing displays after already generating one census");
"Snapshot census updated when changing displays " +
"after already generating one census");
// Does not update unselected censuses.
ok(!getState().snapshots[1].selected, "Second snapshot selected currently");
equal(getState().snapshots[1].census.display, censusDisplays.coarseType,
"Second snapshot using `coarseType` display still and not yet updated to correct display");
"Second snapshot using `coarseType` display still and " +
"not yet updated to correct display");
// Updates to current display when switching to stale snapshot.
dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVING,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVING, censusState.SAVED]);
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
ok(getState().snapshots[1].selected, "Second snapshot selected currently");
equal(getState().snapshots[1].census.display, censusDisplays.allocationStack,

Some files were not shown because too many files have changed in this diff Show More