--- a/.eslintignore
+++ b/.eslintignore
@@ -123,17 +123,16 @@ devtools/client/webide/**
devtools/server/actors/webconsole.js
devtools/server/actors/object.js
devtools/server/actors/script.js
devtools/server/actors/styleeditor.js
devtools/server/actors/stylesheets.js
devtools/server/tests/browser/storage-*.html
!devtools/server/tests/browser/storage-unsecured-iframe.html
devtools/server/tests/browser/stylesheets-nested-iframes.html
-devtools/server/tests/mochitest/**
devtools/server/tests/unit/**
devtools/shared/heapsnapshot/**
devtools/shared/platform/content/test/test_clipboard.html
devtools/shared/qrcode/tests/mochitest/test_decode.html
devtools/shared/tests/mochitest/*.html
devtools/shared/webconsole/test/test_*.html
# Ignore devtools pre-processed files
--- a/devtools/server/tests/mochitest/Debugger.Source.prototype.element-2.js
+++ b/devtools/server/tests/mochitest/Debugger.Source.prototype.element-2.js
@@ -1,1 +1,4 @@
+"use strict";
+
+// eslint-disable-next-line no-debugger
debugger;
--- a/devtools/server/tests/mochitest/Debugger.Source.prototype.element.html
+++ b/devtools/server/tests/mochitest/Debugger.Source.prototype.element.html
@@ -1,11 +1,19 @@
<head>
<!-- Static (not dynamically inserted) inline script. -->
- <script id='franz'>function franz() { debugger; }</script>
+ <script id='franz'>
+ /* exported franz */
+ "use strict";
+
+ function franz() {
+ // eslint-disable-next-line no-debugger
+ debugger;
+ }
+ </script>
<!-- Static out-of-line script element. -->
<script id='heinrich' src='Debugger.Source.prototype.element.js'></script>
</head>
<!-- HTML requires some body element onfoo attributes to add handlers to the
*window*, not the element --- but Debugger.Source.prototype.element should
return the element. Here, that rule should apply to the body's 'onresize'
--- a/devtools/server/tests/mochitest/Debugger.Source.prototype.element.js
+++ b/devtools/server/tests/mochitest/Debugger.Source.prototype.element.js
@@ -1,1 +1,6 @@
-function heinrichFun() { franz(); }
+/* exported heinrichFun */
+"use strict";
+
+function heinrichFun() {
+ franz();
+}
--- a/devtools/server/tests/mochitest/animation-data.html
+++ b/devtools/server/tests/mochitest/animation-data.html
@@ -96,18 +96,20 @@
@keyframes no-compositor {
100% {
margin-right: 600px;
}
}
</style>
<script type="text/javascript">
- window.onload = function() {
- window.opener.postMessage('ready', '*');
+ "use strict";
+
+ window.onload = function () {
+ window.opener.postMessage("ready", "*");
};
</script>
</head>
</body>
<div class="ball still"></div>
<div class="ball animated"></div>
<div class="ball multi"></div>
<div class="ball delayed"></div>
--- a/devtools/server/tests/mochitest/director-helpers.js
+++ b/devtools/server/tests/mochitest/director-helpers.js
@@ -1,9 +1,13 @@
-var Cu = Components.utils;
+/* exported DirectorRegistryFront, DirectorManagerFront, Task,
+ newConnectedDebuggerClient, purgeInstalledDirectorScripts */
+"use strict";
+
+const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const {DebuggerClient} = require("devtools/shared/client/main");
const {DebuggerServer} = require("devtools/server/main");
const Services = require("Services");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
Services.prefs.setBoolPref("dom.mozBrowserFramesEnabled", true);
@@ -20,22 +24,22 @@ const { DirectorManagerFront } = require
const { Task } = require("devtools/shared/task");
/** *********************************
* director helpers functions
**********************************/
function* newConnectedDebuggerClient(opts) {
- var transport = DebuggerServer.connectPipe();
- var client = new DebuggerClient(transport);
+ let transport = DebuggerServer.connectPipe();
+ let client = new DebuggerClient(transport);
yield client.connect();
- var root = yield client.listTabs();
+ let root = yield client.listTabs();
return {
client: client,
root: root,
transport: transport
};
}
--- a/devtools/server/tests/mochitest/hello-actor.js
+++ b/devtools/server/tests/mochitest/hello-actor.js
@@ -1,10 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+/* exported HelloActor */
+"use strict";
const protocol = require("devtools/shared/protocol");
const helloSpec = protocol.generateActorSpec({
typeName: "helloActor",
methods: {
count: {
--- a/devtools/server/tests/mochitest/inspector-eyedropper.html
+++ b/devtools/server/tests/mochitest/inspector-eyedropper.html
@@ -1,18 +1,20 @@
-<html>
-<head>
- <meta charset="UTF-8">
- <title>Inspector Eyedropper tests</title>
- <style>
- html {
- background: black;
- }
- </style>
- <script type="text/javascript">
- window.onload = function() {
- window.opener.postMessage('ready', '*');
- };
- </script>
-</head>
-</body>
-</body>
-</html>
\ No newline at end of file
+<html>
+<head>
+ <meta charset="UTF-8">
+ <title>Inspector Eyedropper tests</title>
+ <style>
+ html {
+ background: black;
+ }
+ </style>
+ <script type="text/javascript">
+ "use strict";
+
+ window.onload = function () {
+ window.opener.postMessage("ready", "*");
+ };
+ </script>
+</head>
+</body>
+</body>
+</html>
--- a/devtools/server/tests/mochitest/inspector-helpers.js
+++ b/devtools/server/tests/mochitest/inspector-helpers.js
@@ -1,8 +1,14 @@
+/* exported attachURL, promiseDone, assertOwnershipTrees, checkMissing, checkAvailable,
+ promiseOnce, isSrcChange, isUnretained, isNewRoot, assertSrcChange, assertUnload,
+ assertFrameLoad, assertChildList, waitForMutation, addTest, addAsyncTest,
+ runNextTest */
+"use strict";
+
var Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const {DebuggerClient} = require("devtools/shared/client/main");
const {DebuggerServer} = require("devtools/server/main");
const { Task } = require("devtools/shared/task");
const Services = require("Services");
@@ -10,17 +16,16 @@ const promise = require("promise");
const {_documentWalker} = require("devtools/server/actors/inspector");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log");
});
-
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
SimpleTest.registerCleanupFunction(function () {
DebuggerServer.destroy();
});
}
@@ -35,18 +40,18 @@ SimpleTest.registerCleanupFunction(funct
/**
* Open a tab, load the url, wait for it to signal its readiness,
* find the tab with the debugger server, and call the callback.
*
* Returns a function which can be called to close the opened ta
* and disconnect its debugger client.
*/
function attachURL(url, callback) {
- var win = window.open(url, "_blank");
- var client = null;
+ let win = window.open(url, "_blank");
+ let client = null;
let cleanup = () => {
if (client) {
client.close();
client = null;
}
if (win) {
win.close();
@@ -58,17 +63,18 @@ function attachURL(url, callback) {
window.addEventListener("message", function loadListener(event) {
if (event.data === "ready") {
client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(([applicationType, traits]) => {
client.listTabs(response => {
for (let tab of response.tabs) {
if (tab.url === url) {
window.removeEventListener("message", loadListener);
- client.attachTab(tab.actor, function (aResponse, aTabClient) {
+ // eslint-disable-next-line max-nested-callbacks
+ client.attachTab(tab.actor, function (_response, _tabClient) {
try {
callback(null, client, tab, win.document);
} catch (ex) {
Cu.reportError(ex);
dump(ex);
}
});
break;
@@ -120,25 +126,28 @@ function serverOwnershipSubtree(walker,
};
}
function serverOwnershipTree(walker) {
let serverWalker = DebuggerServer._searchAllConnectionsForActor(walker.actorID);
return {
root: serverOwnershipSubtree(serverWalker, serverWalker.rootDoc),
- orphaned: [...serverWalker._orphaned].map(o => serverOwnershipSubtree(serverWalker, o.rawNode)),
- retained: [...serverWalker._retainedOrphans].map(o => serverOwnershipSubtree(serverWalker, o.rawNode))
+ orphaned: [...serverWalker._orphaned]
+ .map(o => serverOwnershipSubtree(serverWalker, o.rawNode)),
+ retained: [...serverWalker._retainedOrphans]
+ .map(o => serverOwnershipSubtree(serverWalker, o.rawNode))
};
}
function clientOwnershipSubtree(node) {
return {
name: node.actorID,
- children: sortOwnershipChildren(node.treeChildren().map(child => clientOwnershipSubtree(child)))
+ children: sortOwnershipChildren(node.treeChildren()
+ .map(child => clientOwnershipSubtree(child)))
};
}
function clientOwnershipTree(walker) {
return {
root: clientOwnershipSubtree(walker.rootNode),
orphaned: [...walker._orphaned].map(o => clientOwnershipSubtree(o)),
retained: [...walker._retainedOrphans].map(o => clientOwnershipSubtree(o))
@@ -151,17 +160,18 @@ function ownershipTreeSize(tree) {
size += ownershipTreeSize(child);
}
return size;
}
function assertOwnershipTrees(walker) {
let serverTree = serverOwnershipTree(walker);
let clientTree = clientOwnershipTree(walker);
- is(JSON.stringify(clientTree, null, " "), JSON.stringify(serverTree, null, " "), "Server and client ownership trees should match.");
+ is(JSON.stringify(clientTree, null, " "), JSON.stringify(serverTree, null, " "),
+ "Server and client ownership trees should match.");
return ownershipTreeSize(clientTree.root);
}
// Verify that an actorID is inaccessible both from the client library and the server.
function checkMissing(client, actorID) {
let deferred = promise.defer();
let front = client.getActor(actorID);
@@ -184,38 +194,35 @@ function checkAvailable(client, actorID)
let front = client.getActor(actorID);
ok(front, "Front should be accessible from the client for actorID: " + actorID);
deferred = promise.defer();
client.request({
to: actorID,
type: "garbageAvailableTest",
}, response => {
- is(response.error, "unrecognizedPacketType", "node list actor should be contactable.");
+ is(response.error, "unrecognizedPacketType",
+ "node list actor should be contactable.");
deferred.resolve(undefined);
});
return deferred.promise;
}
-function promiseDone(promise) {
- promise.then(null, err => {
+function promiseDone(currentPromise) {
+ currentPromise.then(null, err => {
ok(false, "Promise failed: " + err);
if (err.stack) {
dump(err.stack);
}
SimpleTest.finish();
});
}
// Mutation list testing
-function isSrcChange(change) {
- return (change.type === "attributes" && change.attributeName === "src");
-}
-
function assertAndStrip(mutations, message, test) {
let size = mutations.length;
mutations = mutations.filter(test);
ok((mutations.size != size), message);
return mutations;
}
function isSrcChange(change) {
@@ -240,17 +247,18 @@ function isChildList(change) {
function isNewRoot(change) {
return change.type === "newRoot";
}
// Make sure an iframe's src attribute changed and then
// strip that mutation out of the list.
function assertSrcChange(mutations) {
- return assertAndStrip(mutations, "Should have had an iframe source change.", isSrcChange);
+ return assertAndStrip(mutations, "Should have had an iframe source change.",
+ isSrcChange);
}
// Make sure there's an unload in the mutation list and strip
// that mutation out of the list
function assertUnload(mutations) {
return assertAndStrip(mutations, "Should have had a document unload change.", isUnload);
}
@@ -280,31 +288,30 @@ function waitForMutation(walker, test, m
waitForMutation(walker, test, mutations.concat(newMutations)).then(finalMutations => {
deferred.resolve(finalMutations);
});
});
return deferred.promise;
}
-
var _tests = [];
function addTest(test) {
_tests.push(test);
}
function addAsyncTest(generator) {
_tests.push(() => Task.spawn(generator).then(null, ok.bind(null, false)));
}
function runNextTest() {
if (_tests.length == 0) {
SimpleTest.finish();
return;
}
- var fn = _tests.shift();
+ let fn = _tests.shift();
try {
fn();
} catch (ex) {
info("Test function " + (fn.name ? "'" + fn.name + "' " : "") +
"threw an exception: " + ex);
}
}
--- a/devtools/server/tests/mochitest/inspector-search-data.html
+++ b/devtools/server/tests/mochitest/inspector-search-data.html
@@ -10,18 +10,20 @@
#pseudo:before {
content: "before element";
}
#pseudo:after {
content: "after element";
}
</style>
<script type="text/javascript">
- window.onload = function() {
- window.opener.postMessage('ready', '*');
+ "use strict";
+
+ window.onload = function () {
+ window.opener.postMessage("ready", "*");
};
</script>
</head>
</body>
<!-- A comment
spread across multiple lines -->
<img width="100" height="100" src="large-image.jpg" />
@@ -44,9 +46,9 @@
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h4>Heading 4</h4>
<h4>Heading 4</h4>
<div class="💩" id="💩" 💩="💩"></div>
</body>
-</html>
\ No newline at end of file
+</html>
--- a/devtools/server/tests/mochitest/inspector-styles-data.html
+++ b/devtools/server/tests/mochitest/inspector-styles-data.html
@@ -1,13 +1,15 @@
<html>
<script>
+ "use strict";
+
window.onload = () => {
- window.opener.postMessage('ready', '*')
- }
+ window.opener.postMessage("ready", "*");
+ };
</script>
<style>
.inheritable-rule {
font-size: 15px;
}
.uninheritable-rule {
background-color: #f06;
}
--- a/devtools/server/tests/mochitest/inspector-traversal-data.html
+++ b/devtools/server/tests/mochitest/inspector-traversal-data.html
@@ -13,36 +13,37 @@
#pseudo-empty::before {
content: "before an empty element";
}
#shadow::before {
content: "Testing ::before on a shadow host";
}
</style>
<script type="text/javascript">
- window.onload = function() {
+ "use strict";
+ window.onload = function () {
// Set up a basic shadow DOM
- var host = document.querySelector('#shadow');
+ let host = document.querySelector("#shadow");
if (host.createShadowRoot) {
- var root = host.createShadowRoot();
- root.innerHTML = '<h3>Shadow <em>DOM</em></h3><select multiple></select>';
+ let root = host.createShadowRoot();
+ root.innerHTML = "<h3>Shadow <em>DOM</em></h3><select multiple></select>";
}
// Put a copy of the body in an iframe to test frame traversal.
- var body = document.querySelector("body");
- var data = "data:text/html,<html>" + body.outerHTML + "<html>";
- var iframe = document.createElement("iframe");
+ let body = document.querySelector("body");
+ let data = "data:text/html,<html>" + body.outerHTML + "<html>";
+ let iframe = document.createElement("iframe");
iframe.setAttribute("id", "childFrame");
- iframe.onload = function() {
- window.opener.postMessage('ready', '*')
+ iframe.onload = function () {
+ window.opener.postMessage("ready", "*");
};
iframe.src = data;
body.appendChild(iframe);
- }
+ };
</script>
</head>
<body style="background-color:white">
<h1>Inspector Actor Tests</h1>
<span id="longstring">longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong</span>
<span id="shortstring">short</span>
<span id="empty"></span>
<div id="longlist" data-test="exists">
--- a/devtools/server/tests/mochitest/inspector_css-properties.html
+++ b/devtools/server/tests/mochitest/inspector_css-properties.html
@@ -1,10 +1,12 @@
<html>
<head>
<body>
<script type="text/javascript">
- window.onload = function() {
- window.opener.postMessage('ready', '*');
+ "use strict";
+
+ window.onload = function () {
+ window.opener.postMessage("ready", "*");
};
</script>
</body>
</html>
--- a/devtools/server/tests/mochitest/inspector_getImageData.html
+++ b/devtools/server/tests/mochitest/inspector_getImageData.html
@@ -2,20 +2,22 @@
<head>
<body>
<img class="custom">
<img class="big-horizontal" src="large-image.jpg" style="width:500px;">
<canvas class="big-vertical" style="width:500px;"></canvas>
<img class="small" src="small-image.gif">
<img class="data" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAJklEQVRIie3NMREAAAgAoe9fWls4eAzMVM0xoVAoFAqFQqFQ+C9chp4NHvu+4Q4AAAAASUVORK5CYII=">
<script>
+ "use strict";
+
window.onload = () => {
var canvas = document.querySelector("canvas"), ctx = canvas.getContext("2d");
canvas.width = 1000;
canvas.height = 2000;
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 1000, 2000);
- window.opener.postMessage('ready', '*')
- }
+ window.opener.postMessage("ready", "*");
+ };
</script>
</body>
</html>
--- a/devtools/server/tests/mochitest/memory-helpers.js
+++ b/devtools/server/tests/mochitest/memory-helpers.js
@@ -1,36 +1,38 @@
-var Cu = Components.utils;
-var Cc = Components.classes;
-var Ci = Components.interfaces;
+/* exported Task, startServerAndGetSelectedTabMemory, destroyServerAndFinish,
+ waitForTime, waitUntil */
+"use strict";
-var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+const Cu = Components.utils;
+
+const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+const Services = require("Services");
const { Task } = require("devtools/shared/task");
-var Services = require("Services");
-var { DebuggerClient } = require("devtools/shared/client/main");
-var { DebuggerServer } = require("devtools/server/main");
+const { DebuggerClient } = require("devtools/shared/client/main");
+const { DebuggerServer } = require("devtools/server/main");
-var { MemoryFront } = require("devtools/shared/fronts/memory");
+const { MemoryFront } = require("devtools/shared/fronts/memory");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log");
});
function startServerAndGetSelectedTabMemory() {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
- var client = new DebuggerClient(DebuggerServer.connectPipe());
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
return client.connect()
.then(() => client.listTabs())
.then(response => {
- var form = response.tabs[response.selected];
- var memory = MemoryFront(client, form, response);
+ let form = response.tabs[response.selected];
+ let memory = MemoryFront(client, form, response);
return { memory, client };
});
}
function destroyServerAndFinish(client) {
client.close().then(() => {
DebuggerServer.destroy();
@@ -43,10 +45,11 @@ function waitForTime(ms) {
setTimeout(resolve, ms);
});
}
function waitUntil(predicate) {
if (predicate()) {
return Promise.resolve(true);
}
- return new Promise(resolve => setTimeout(() => waitUntil(predicate).then(() => resolve(true)), 10));
+ return new Promise(resolve => setTimeout(() => waitUntil(predicate)
+ .then(() => resolve(true)), 10));
}
--- a/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html
+++ b/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html
@@ -1,8 +1,10 @@
<!DOCTYPE HTML>
<html>
<script>
-var xhr = new XMLHttpRequest;
+"use strict";
+
+var xhr = new XMLHttpRequest();
xhr.timeout = 1742;
-xhr.expando = 'Expando!';
+xhr.expando = "Expando!";
</script>
</html>
--- a/devtools/server/tests/mochitest/setup-in-child.js
+++ b/devtools/server/tests/mochitest/setup-in-child.js
@@ -1,11 +1,13 @@
+"use strict";
+
const {Cc, Ci} = require("chrome");
-const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"].
- getService(Ci.nsIMessageListenerManager);
+const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
+ .getService(Ci.nsIMessageListenerManager);
const { DebuggerServer } = require("devtools/server/main");
exports.setupChild = function (a, b, c) {
cpmm.sendAsyncMessage("test:setupChild", [a, b, c]);
};
exports.callParent = function () {
// Hack! Fetch DebuggerServerConnection objects directly within DebuggerServer guts.
--- a/devtools/server/tests/mochitest/setup-in-parent.js
+++ b/devtools/server/tests/mochitest/setup-in-parent.js
@@ -1,8 +1,10 @@
+"use strict";
+
var {Ci} = require("chrome");
var Services = require("Services");
exports.setupParent = function ({mm, prefix}) {
let args = [
!!mm.QueryInterface(Ci.nsIMessageSender),
prefix
];
--- a/devtools/server/tests/mochitest/test_Debugger.Script.prototype.global.html
+++ b/devtools/server/tests/mochitest/test_Debugger.Script.prototype.global.html
@@ -9,40 +9,40 @@ Debugger.Script.prototype.global should
<meta charset="utf-8">
<title>Debugger.Script.prototype.global should return inner windows</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var iframe = document.createElement("iframe");
+ let iframe = document.createElement("iframe");
iframe.src = "data:text/html,<script>function glorp() { }<\/script>";
iframe.onload = firstOnLoadHandler;
document.body.appendChild(iframe);
function firstOnLoadHandler() {
- var dbg = new Debugger;
- var iframeDO = dbg.addDebuggee(iframe.contentWindow);
+ let dbg = new Debugger();
+ let iframeDO = dbg.addDebuggee(iframe.contentWindow);
// For sanity: check that the debuggee global is the inner window,
// and that the outer window gets a distinct D.O.
- var iframeWindowProxyDO = iframeDO.makeDebuggeeValue(iframe.contentWindow);
+ let iframeWindowProxyDO = iframeDO.makeDebuggeeValue(iframe.contentWindow);
ok(iframeDO !== iframeWindowProxyDO);
// The real test: Debugger.Script.prototype.global returns inner windows.
- ok(iframeDO.getOwnPropertyDescriptor('glorp').value.script.global === iframeDO);
+ ok(iframeDO.getOwnPropertyDescriptor("glorp").value.script.global === iframeDO);
SimpleTest.finish();
}
-}
-
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_Debugger.Source.prototype.element.html
+++ b/devtools/server/tests/mochitest/test_Debugger.Source.prototype.element.html
@@ -10,173 +10,173 @@ element to which code is attached (if an
<meta charset="utf-8">
<title>Debugger.Source.prototype.element should return owning element</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var log = '';
- var doc, dieter, ulrich, isolde, albrecht;
- var dbg, iframeDO, DOFor;
+ let log = "";
+ let doc, dieter, ulrich, isolde, albrecht;
+ let dbg, iframeDO, DOFor;
// Create an iframe to debug.
// We can't use a data: URL here, because we want to test script elements
// that refer to the JavaScript via 'src' attributes, and data: documents
// can't refer to those. So we use a separate HTML document.
- var iframe = document.createElement("iframe");
+ let iframe = document.createElement("iframe");
iframe.src = "Debugger.Source.prototype.element.html";
iframe.onload = onLoadHandler;
document.body.appendChild(iframe);
function onLoadHandler() {
- log += 'l';
+ log += "l";
// Now that the iframe's window has been created, we can add
// it as a debuggee.
- dbg = new Debugger;
+ dbg = new Debugger();
dbg.onDebuggerStatement = franzDebuggerHandler;
iframeDO = dbg.addDebuggee(iframe.contentWindow);
DOFor = iframeDO.makeDebuggeeValue.bind(iframeDO);
// Send a click event to heidi.
doc = iframe.contentWindow.document;
- doc.getElementById('heidi').dispatchEvent(new Event('click'));
+ doc.getElementById("heidi").dispatchEvent(new Event("click"));
}
function franzDebuggerHandler(frame) {
- log += 'f';
+ log += "f";
// The top stack frame should be franz, belonging to the script element.
- ok(frame.callee.displayName === 'franz', 'top frame is franz');
- ok(frame.script.source.element === DOFor(doc.getElementById('franz')),
- 'top frame source belongs to element franz');
+ ok(frame.callee.displayName === "franz", "top frame is franz");
+ ok(frame.script.source.element === DOFor(doc.getElementById("franz")),
+ "top frame source belongs to element franz");
ok(frame.script.source.elementAttributeName === undefined,
"top frame source doesn't belong to an attribute");
// The second stack frame should belong to heinrich.
- ok(frame.older.script.source.element === DOFor(doc.getElementById('heinrich')),
+ ok(frame.older.script.source.element === DOFor(doc.getElementById("heinrich")),
"second frame source belongs to element heinrich");
ok(frame.older.script.source.elementAttributeName === undefined,
"second frame source doesn't belong to an attribute");
// The next stack frame should belong to heidi's onclick handler.
- ok(frame.older.older.script.source.element === DOFor(doc.getElementById('heidi')),
- 'third frame source belongs to element heidi');
- ok(frame.older.older.script.source.elementAttributeName === 'onclick',
+ ok(frame.older.older.script.source.element === DOFor(doc.getElementById("heidi")),
+ "third frame source belongs to element heidi");
+ ok(frame.older.older.script.source.elementAttributeName === "onclick",
"third frame source belongs to 'onclick' attribute");
// Try a dynamically inserted inline script element.
- ulrich = doc.createElement('script');
- ulrich.text = 'debugger;'
+ ulrich = doc.createElement("script");
+ ulrich.text = "debugger;";
dbg.onDebuggerStatement = ulrichDebuggerHandler;
doc.body.appendChild(ulrich);
}
function ulrichDebuggerHandler(frame) {
- log += 'u';
+ log += "u";
// The top frame should be ulrich's text.
ok(frame.script.source.element === DOFor(ulrich),
"top frame belongs to ulrich");
ok(frame.script.source.elementAttributeName === undefined,
"top frame is not on an attribute of ulrich");
// Try a dynamically inserted out-of-line script element.
- isolde = doc.createElement('script');
- isolde.setAttribute('src', 'Debugger.Source.prototype.element-2.js');
- isolde.setAttribute('id', 'idolde, my dear');
+ isolde = doc.createElement("script");
+ isolde.setAttribute("src", "Debugger.Source.prototype.element-2.js");
+ isolde.setAttribute("id", "idolde, my dear");
dbg.onDebuggerStatement = isoldeDebuggerHandler;
doc.body.appendChild(isolde);
}
function isoldeDebuggerHandler(frame) {
- log += 'i';
+ log += "i";
// The top frame should belong to isolde.
ok(frame.script.source.element === DOFor(isolde),
"top frame belongs to isolde");
info("frame.script.source.element is: " + uneval(frame.script.source.element));
- if (typeof frame.script.source.element.unsafeDereference() == 'object') {
- info(" toString: " + frame.script.source.element.unsafeDereference());
- info(" id: " + frame.script.source.element.unsafeDereference().id);
+ if (typeof frame.script.source.element.unsafeDereference() == "object") {
+ info(" toString: " + frame.script.source.element.unsafeDereference());
+ info(" id: " + frame.script.source.element.unsafeDereference().id);
}
ok(frame.script.source.elementAttributeName === undefined,
"top frame source is not an attribute of isolde");
info("frame.script.source.elementAttributeName is: " +
uneval(frame.script.source.elementAttributeName));
// Try a dynamically created div element with a handler.
- dieter = doc.createElement('div');
- dieter.setAttribute('id', 'dieter');
- dieter.setAttribute('ondrag', 'debugger;');
+ dieter = doc.createElement("div");
+ dieter.setAttribute("id", "dieter");
+ dieter.setAttribute("ondrag", "debugger;");
dbg.onDebuggerStatement = dieterDebuggerHandler;
- dieter.dispatchEvent(new Event('drag'));
- }
+ dieter.dispatchEvent(new Event("drag"));
+ }
- function dieterDebuggerHandler(frame) {
- log += 'd';
+ function dieterDebuggerHandler(frame) {
+ log += "d";
// The top frame should belong to dieter's ondrag handler.
ok(frame.script.source.element === DOFor(dieter),
"second event's handler belongs to dieter");
- ok(frame.script.source.elementAttributeName === 'ondrag',
+ ok(frame.script.source.elementAttributeName === "ondrag",
"second event's handler is on dieter's 'ondrag' element");
// Try sending an 'onresize' event to the window.
//
// Note that we only want Debugger to see the events we send, not any
// genuine resize events accidentally generated by the test harness (see bug
// 1162067). So we mark our events as cancelable; that seems to be the only
// bit chrome can fiddle on an Event that content code will see and that
// won't affect propagation. Then, the content event only runs its
// 'debugger' statement when the event is cancelable. It's a kludge.
dbg.onDebuggerStatement = resizeDebuggerHandler;
- iframe.contentWindow.dispatchEvent(new Event('resize', { cancelable: true }));
+ iframe.contentWindow.dispatchEvent(new Event("resize", { cancelable: true }));
}
function resizeDebuggerHandler(frame) {
- log += 'e';
+ log += "e";
// The top frame should belong to the body's 'onresize' handler, even
// though we sent the message to the window and it was handled.
ok(frame.script.source.element === DOFor(doc.body),
"onresize event handler belongs to body element");
- ok(frame.script.source.elementAttributeName === 'onresize',
+ ok(frame.script.source.elementAttributeName === "onresize",
"onresize event handler is on body element's 'onresize' attribute");
// In SVG, the event and the attribute that holds that event's handler
// have different names. Debugger.Source.prototype.elementAttributeName
// should report (as one might infer) the attribute name, not the event
// name.
- albrecht = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
- albrecht.setAttribute('onload', 'debugger;');
+ albrecht = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
+ albrecht.setAttribute("onload", "debugger;");
dbg.onDebuggerStatement = SVGLoadHandler;
albrecht.dispatchEvent(new Event("SVGLoad"));
}
function SVGLoadHandler(frame) {
- log += 's';
+ log += "s";
// The top frame's source should be on albrecht's 'onload' attribute.
ok(frame.script.source.element === DOFor(albrecht),
"SVGLoad event handler belongs to albrecht");
- ok(frame.script.source.elementAttributeName === 'onload',
+ ok(frame.script.source.elementAttributeName === "onload",
"SVGLoad event handler is on albrecht's 'onload' attribute");
- ok(log === 'lfuides', "all tests actually ran");
+ ok(log === "lfuides", "all tests actually ran");
SimpleTest.finish();
}
-}
-
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_Debugger.Source.prototype.introductionScript.html
+++ b/devtools/server/tests/mochitest/test_Debugger.Source.prototype.introductionScript.html
@@ -10,88 +10,89 @@ behave when 'eval' is called with no scr
<meta charset="utf-8">
<title>Debugger.Source.prototype.introductionScript with no caller</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var dbg, iframeDO, doc, script2DO;
+ let dbg, iframeDO, doc, script2DO;
// Create an iframe to debug.
- var iframe = document.createElement("iframe");
+ let iframe = document.createElement("iframe");
iframe.src = "data:text/html,<div>Hi!</div>";
iframe.onload = onLoadHandler;
document.body.appendChild(iframe);
function onLoadHandler() {
// Now that the iframe's window has been created, we can add
// it as a debuggee.
- dbg = new Debugger;
+ dbg = new Debugger();
iframeDO = dbg.addDebuggee(iframe.contentWindow);
doc = iframe.contentWindow.document;
- var script = doc.createElement('script');
+ let script = doc.createElement("script");
script.text = "setTimeout(eval.bind(null, 'debugger;'), 0);";
dbg.onDebuggerStatement = timerHandler;
doc.body.appendChild(script);
}
function timerHandler(frame) {
// The top stack frame's source should have an undefined
// introduction script and introduction offset.
- var source = frame.script.source;
+ let source = frame.script.source;
ok(source.introductionScript === undefined,
"setTimeout eval introductionScript is undefined");
ok(source.introductionOffset === undefined,
"setTimeout eval introductionOffset is undefined");
// Check that the above isn't just some quirk of iframes, or the
// browser milieu destroying information: an eval script should indeed
// have proper introduction information.
- var script2 = doc.createElement('script');
+ let script2 = doc.createElement("script");
script2.text = "eval('debugger;');";
script2DO = iframeDO.makeDebuggeeValue(script2);
dbg.onDebuggerStatement = evalHandler;
doc.body.appendChild(script2);
}
function evalHandler(frame) {
// The top stack frame's source should be introduced by the script that
// called eval.
- var source = frame.script.source;
- var frame2 = frame.older;
+ let source = frame.script.source;
+ let frame2 = frame.older;
- ok(source.introductionType === 'eval',
+ ok(source.introductionType === "eval",
"top frame's source was introduced by 'eval'");
ok(source.introductionScript === frame2.script,
"eval frame's introduction script is the older frame's script");
ok(source.introductionOffset === frame2.offset,
"eval frame's introduction offset is current offset in older frame");
ok(source.introductionScript.source.element === script2DO,
"eval frame's introducer belongs to script2 element");
// The frame that called eval, in turn, should have no introduction
// information. (In the future, we certainly could point at the call
// that inserted the script element into the document; if that happens,
// we can update this test.)
- ok(frame2.script.source.introductionType === 'scriptElement',
+ ok(frame2.script.source.introductionType === "scriptElement",
"older frame has no introduction type");
ok(frame2.script.source.introductionScript === undefined,
"older frame has no introduction script");
ok(frame2.script.source.introductionOffset === undefined,
"older frame has no introduction offset");
SimpleTest.finish();
}
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_Debugger.Source.prototype.introductionType.html
+++ b/devtools/server/tests/mochitest/test_Debugger.Source.prototype.introductionType.html
@@ -11,171 +11,164 @@ JavaScrip appearing in an inline event h
<title>Debugger.Source.prototype.introductionType should identify event handlers</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="inspector-helpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
-var dbg;
-var iframeDO, doc;
-var Tootles, TootlesDO;
+let dbg;
+let iframeDO, doc;
+let Tootles, TootlesDO;
window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
};
addTest(function setup() {
// Create an iframe to debug.
- var iframe = document.createElement("iframe");
+ let iframe = document.createElement("iframe");
iframe.src = "data:text/html," +
"<div id='Tootles' onclick='debugger;'>I'm a DIV!</div>" +
"<script id='Auddie'>function auddie() { debugger; }<\/script>";
iframe.onload = onLoadHandler;
document.body.appendChild(iframe);
function onLoadHandler() {
// Now that the iframe's window has been created, we can add
// it as a debuggee.
- dbg = new Debugger;
+ dbg = new Debugger();
iframeDO = dbg.addDebuggee(iframe.contentWindow);
doc = iframe.contentWindow.document;
- Tootles = doc.getElementById('Tootles');
+ Tootles = doc.getElementById("Tootles");
TootlesDO = iframeDO.makeDebuggeeValue(Tootles);
runNextTest();
}
});
-
// Check the introduction type of in-markup event handler code.
// Send a click event to Tootles, whose handler has a 'debugger' statement,
// and check that script's introduction type.
addTest(function ClickOnTootles() {
dbg.onDebuggerStatement = TootlesClickDebugger;
- Tootles.dispatchEvent(new Event('click'));
+ Tootles.dispatchEvent(new Event("click"));
function TootlesClickDebugger(frame) {
// some sanity checks
ok(frame.script.source.element === TootlesDO,
"top frame source belongs to element 'Tootles'");
- is(frame.script.source.elementAttributeName, 'onclick',
+ is(frame.script.source.elementAttributeName, "onclick",
"top frame source belongs to 'onclick' attribute");
// And, the actual point of this test:
- is(frame.script.source.introductionType, 'eventHandler',
+ is(frame.script.source.introductionType, "eventHandler",
"top frame source's introductionType is 'eventHandler'");
runNextTest();
}
});
-
// Check the introduction type of dynamically added event handler code.
// Add a drag event handler to Tootles as a string, and then send
// Tootles a drag event.
addTest(function DragTootles() {
dbg.onDebuggerStatement = TootlesDragDebugger;
- Tootles.setAttribute('ondrag', 'debugger;');
- Tootles.dispatchEvent(new Event('drag'));
+ Tootles.setAttribute("ondrag", "debugger;");
+ Tootles.dispatchEvent(new Event("drag"));
function TootlesDragDebugger(frame) {
// sanity checks
ok(frame.script.source.element === TootlesDO,
"top frame source belongs to element 'Tootles'");
- is(frame.script.source.elementAttributeName, 'ondrag',
+ is(frame.script.source.elementAttributeName, "ondrag",
"top frame source belongs to 'ondrag' attribute");
// And, the actual point of this test:
- is(frame.script.source.introductionType, 'eventHandler',
+ is(frame.script.source.introductionType, "eventHandler",
"top frame source's introductionType is 'eventHandler'");
runNextTest();
}
});
-
// Check the introduction type of an in-markup script element.
addTest(function checkAuddie() {
- var fnDO = iframeDO.getOwnPropertyDescriptor('auddie').value;
- var AuddieDO = iframeDO.makeDebuggeeValue(doc.getElementById('Auddie'));
+ let fnDO = iframeDO.getOwnPropertyDescriptor("auddie").value;
+ let AuddieDO = iframeDO.makeDebuggeeValue(doc.getElementById("Auddie"));
- is(fnDO.class, 'Function',
+ is(fnDO.class, "Function",
"Script element 'Auddie' defined function 'auddie'.");
ok(fnDO.script.source.element === AuddieDO,
"Function auddie's script belongs to script element 'Auddie'");
is(fnDO.script.source.elementAttributeName, undefined,
"Function auddie's script doesn't belong to any attribute of 'Auddie'");
- is(fnDO.script.source.introductionType, 'scriptElement',
+ is(fnDO.script.source.introductionType, "scriptElement",
"Function auddie's script's source was introduced by a script element");
runNextTest();
});
-
// Check the introduction type of a dynamically inserted script element.
addTest(function InsertRover() {
dbg.onDebuggerStatement = RoverDebugger;
- var rover = doc.createElement('script');
- var roverDO = iframeDO.makeDebuggeeValue(rover);
- rover.text = 'debugger;';
+ let rover = doc.createElement("script");
+ let roverDO = iframeDO.makeDebuggeeValue(rover);
+ rover.text = "debugger;";
doc.body.appendChild(rover);
function RoverDebugger(frame) {
// sanity checks
ok(frame.script.source.element === roverDO,
"Rover script belongs to Rover");
ok(frame.script.source.elementAttributeName === undefined,
"Rover script doesn't belong to an attribute of Rover");
// Check the introduction type.
- ok(frame.script.source.introductionType === 'scriptElement',
+ ok(frame.script.source.introductionType === "scriptElement",
"Rover script's introduction type is 'scriptElement'");
runNextTest();
}
});
-
// Create a XUL document with a script element, and check its introduction type.
addTest(function XULDocumentScript() {
- var xulFrame = document.createElement('iframe');
+ let xulFrame = document.createElement("iframe");
xulFrame.src = "data:application/vnd.mozilla.xul+xml;charset=utf-8," +
"<?xml version=\"1.0\"?>" +
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'>" +
"<script id='xulie'>function xulScriptFunc() { debugger; }<\/script>" +
"</window>";
xulFrame.onload = xulLoaded;
info("Appending iframe containing XUL document");
document.body.appendChild(xulFrame);
function xulLoaded() {
info("Loaded XUL document");
- var xulFrameDO = dbg.addDebuggee(xulFrame.contentWindow);
- var xulDoc = xulFrame.contentWindow.document;
- var xulieDO = xulFrameDO.makeDebuggeeValue(xulDoc.getElementById('xulie'));
- var xulFnDO = xulFrameDO.getOwnPropertyDescriptor('xulScriptFunc').value;
- is(typeof xulFnDO, 'object', "XUL script element defined 'xulScriptFunc'");
- is(xulFnDO.class, 'Function',
+ let xulFrameDO = dbg.addDebuggee(xulFrame.contentWindow);
+ let xulFnDO = xulFrameDO.getOwnPropertyDescriptor("xulScriptFunc").value;
+ is(typeof xulFnDO, "object", "XUL script element defined 'xulScriptFunc'");
+ is(xulFnDO.class, "Function",
"XUL global 'xulScriptFunc' is indeed a function");
// A XUL document's script elements' code gets shared amongst all
// instantiations of the document, so there's no specific DOM element
// we can attribute the code to.
is(xulFnDO.script.source.element, undefined,
"XUL script code should not be attributed to any individual element");
- is(xulFnDO.script.source.introductionType, 'scriptElement',
+ is(xulFnDO.script.source.introductionType, "scriptElement",
"xulScriptFunc's introduction type is 'scriptElement'");
runNextTest();
}
});
-
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_animation_actor-lifetime.html
+++ b/devtools/server/tests/mochitest/test_animation_actor-lifetime.html
@@ -6,85 +6,82 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 1247243</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-window.onload = function() {
- const Ci = Components.interfaces;
+"use strict";
+
+window.onload = function () {
const {AnimationsFront} = require("devtools/shared/fronts/animation");
const {InspectorFront} = require("devtools/shared/fronts/inspector");
SimpleTest.waitForExplicitFinish();
let gWalker = null;
- let gClient = null;
let animationsFront = null;
addTest(function setup() {
- info ("Setting up inspector and animation actors.");
+ info("Setting up inspector and animation actors.");
let url = document.getElementById("animationContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let inspector = InspectorFront(client, tab);
animationsFront = new AnimationsFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
-
});
});
addAsyncTest(function* testActorLifetime() {
-
- info ("Testing animated node actor");
+ info("Testing animated node actor");
let animatedNodeActor = yield gWalker.querySelector(gWalker.rootNode,
".animated");
yield animationsFront.getAnimationPlayersForNode(animatedNodeActor);
- let animationsActor = DebuggerServer._searchAllConnectionsForActor(animationsFront.actorID);
+ let animationsActor = DebuggerServer
+ ._searchAllConnectionsForActor(animationsFront.actorID);
is(animationsActor.actors.length, 1,
"AnimationActor have 1 AnimationPlayerActors");
- info ("Testing AnimationPlayerActors release");
+ info("Testing AnimationPlayerActors release");
let stillNodeActor = yield gWalker.querySelector(gWalker.rootNode,
".still");
yield animationsFront.getAnimationPlayersForNode(stillNodeActor);
is(animationsActor.actors.length, 0,
"AnimationActor does not have any AnimationPlayerActors anymore");
- info ("Testing multi animated node actor");
+ info("Testing multi animated node actor");
let multiNodeActor = yield gWalker.querySelector(gWalker.rootNode,
".multi");
yield animationsFront.getAnimationPlayersForNode(multiNodeActor);
is(animationsActor.actors.length, 2,
"AnimationActor has now 2 AnimationPlayerActors");
- info ("Testing single animated node actor");
+ info("Testing single animated node actor");
yield animationsFront.getAnimationPlayersForNode(animatedNodeActor);
is(animationsActor.actors.length, 1,
"AnimationActor has only one AnimationPlayerActors");
- info ("Testing AnimationPlayerActors release again");
+ info("Testing AnimationPlayerActors release again");
yield animationsFront.getAnimationPlayersForNode(stillNodeActor);
is(animationsActor.actors.length, 0,
"AnimationActor does not have any AnimationPlayerActors anymore");
runNextTest();
});
-
runNextTest();
};
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1247243">Mozilla Bug 1247243</a>
<a id="animationContent" target="_blank" href="animation-data.html">Test Document</a>
</body>
--- a/devtools/server/tests/mochitest/test_connectToChild.html
+++ b/devtools/server/tests/mochitest/test_connectToChild.html
@@ -1,70 +1,74 @@
-<SDOCTYPv HTM.>
+<!DOCTYPE HTML>
<html>
<!--
Bug 966991 - Test DebuggerServer.connectToChild
-->
<head>
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script type="application/javascript">
+"use strict";
let Cu = Components.utils;
-let Cc = Components.classes;
let Ci = Components.interfaces;
let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
let { DebuggerClient } = require("devtools/shared/client/main");
let { DebuggerServer } = require("devtools/server/main");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [
// Always log packets when running tests.
["devtools.debugger.log", true],
["dom.mozBrowserFramesEnabled", true]
]
}, runTests);
-}
+};
function runTests() {
// Create a minimal iframe with a message manager
let iframe = document.createElement("iframe");
iframe.mozbrowser = true;
document.body.appendChild(iframe);
let mm = iframe.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
// Register a test actor in the child process so that we can know if and when
// this fake actor is destroyed.
mm.loadFrameScript("data:text/javascript,new " + function FrameScriptScope() {
+ /* eslint-disable no-shadow */
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const { DebuggerServer } = require("devtools/server/main");
+ /* eslint-enable no-shadow */
if (!DebuggerServer.initialized) {
DebuggerServer.init();
}
- function TestActor() {dump("instanciate test actor\n");}
+ function TestActor() {
+ dump("instanciate test actor\n");
+ }
TestActor.prototype = {
actorPrefix: "test",
destroy: function () {
sendAsyncMessage("test-actor-destroyed", null);
},
hello: function () {
- return {msg:"world"};
+ return {msg: "world"};
}
};
TestActor.prototype.requestTypes = {
"hello": TestActor.prototype.hello
};
DebuggerServer.addTabActor(TestActor, "testActor");
}, false);
@@ -85,17 +89,16 @@ function runTests() {
ok(actor.testActor, "Got the test actor");
// Ensure sending at least one request to our actor,
// otherwise it won't be instanciated, nor be destroyed...
client.request({
to: actor.testActor,
type: "hello",
}, function (response) {
-
// Then close the client. That should end up cleaning our test actor
client.close();
// Ensure that our test actor got cleaned up;
// its destroy method should be called
mm.addMessageListener("test-actor-destroyed", function listener() {
mm.removeMessageListener("test-actor-destroyed", listener);
ok(true, "Actor is cleaned up");
@@ -108,27 +111,27 @@ function runTests() {
function secondClient(firstActor) {
// Then fake a second one, that should spawn a new set of tab actors
let transport = DebuggerServer.connectPipe();
let conn = transport._serverConnection;
let client = new DebuggerClient(transport);
DebuggerServer.connectToChild(conn, iframe).then(actor => {
ok(actor.testActor, "Got a test actor for the second connection");
- isnot(actor.testActor, firstActor, "We get different actor instances between two connections");
+ isnot(actor.testActor, firstActor,
+ "We get different actor instances between two connections");
client.close(cleanup);
});
}
function cleanup() {
DebuggerServer.destroy();
iframe.remove();
- SimpleTest.finish()
+ SimpleTest.finish();
}
firstClient();
}
-
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_connection-manager.html
+++ b/devtools/server/tests/mochitest/test_connection-manager.html
@@ -7,113 +7,130 @@ Bug 898485 - [app manager] Implement an
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var Cu = Components.utils;
+ const Cu = Components.utils;
- var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var {DebuggerServer} = require("devtools/server/main");
- var Services = require("Services");
+ const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ const {DebuggerServer} = require("devtools/server/main");
+ const Services = require("Services");
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
}
- var {ConnectionManager, Connection} = require("devtools/shared/client/connection-manager");
+ const {
+ ConnectionManager,
+ Connection
+ } = require("devtools/shared/client/connection-manager");
- var orgCount = ConnectionManager.connections.length;
+ let orgCount = ConnectionManager.connections.length;
ConnectionManager.once("new", (event, c) => {
- is(ConnectionManager.connections[orgCount], c, "new event fired, with correct connection");
+ is(ConnectionManager.connections[orgCount], c,
+ "new event fired, with correct connection");
});
- var c1 = ConnectionManager.createConnection();
- var c2 = ConnectionManager.createConnection();
+ let c1 = ConnectionManager.createConnection();
+ let c2 = ConnectionManager.createConnection();
is(ConnectionManager.connections[orgCount], c1, "Connection 1 registered");
is(ConnectionManager.connections[orgCount + 1], c2, "Connection 2 registered");
- c1.once(Connection.Events.DESTROYED, function() {
+ c1.once(Connection.Events.DESTROYED, function () {
is(ConnectionManager.connections.length, orgCount + 1, "Connection 1 destroyed");
- var c = c2;
+ let c = c2;
- var eventsRef = "connecting connected disconnecting disconnected host-changed disconnected timeout destroyed";
- var events = [];
+ let eventsRef = "connecting connected disconnecting disconnected host-changed"
+ + " disconnected timeout destroyed";
+ let events = [];
- var s = Connection.Status;
+ let s = Connection.Status;
is(c.status, s.DISCONNECTED, "disconnected");
- c.once(Connection.Events.CONNECTING, function(e) { events.push(e); is(c.status, s.CONNECTING, "connecting"); });
- c.once(Connection.Events.CONNECTED, function(e) { events.push(e); is(c.status, s.CONNECTED, "connected"); c.disconnect()});
- c.once(Connection.Events.DISCONNECTING, function(e) { events.push(e); is(c.status, s.DISCONNECTING, "disconnecting"); });
- c.once(Connection.Events.DISCONNECTED, function(e) { events.push(e); is(c.status, s.DISCONNECTED, "disconnected"); testError()});
- c.once(Connection.Events.DESTROYED, function(e) { events.push(e); is(c.status, s.DESTROYED, "destroyed"); finish()});
+ c.once(Connection.Events.CONNECTING, function (e) {
+ events.push(e);
+ is(c.status, s.CONNECTING, "connecting");
+ });
+
+ c.once(Connection.Events.CONNECTED, function (e) {
+ events.push(e);
+ is(c.status, s.CONNECTED, "connected");
+ c.disconnect();
+ });
+
+ c.once(Connection.Events.DISCONNECTING, function (e) {
+ events.push(e);
+ is(c.status, s.DISCONNECTING, "disconnecting");
+ });
+
+ c.once(Connection.Events.DISCONNECTED, function (e) {
+ events.push(e);
+ is(c.status, s.DISCONNECTED, "disconnected");
+ testError();
+ });
+
+ c.once(Connection.Events.DESTROYED, function (e) {
+ events.push(e);
+ is(c.status, s.DESTROYED, "destroyed");
+ finish();
+ });
c.connect();
- function testStore() {
- c.store.on("set", function(e,path) {
- if (path.join(".") == "device.width") {
- is(c.store.object.device.width, window.screen.width, "Store is fed with valid data");
- c.disconnect();
- }
- });
- }
-
function testError() {
- c.once(Connection.Events.DISCONNECTED, function(e) {
+ c.once(Connection.Events.DISCONNECTED, function (e) {
events.push(e);
testKeepConnecting();
});
- c.once(Connection.Events.HOST_CHANGED, function(e) {
+ c.once(Connection.Events.HOST_CHANGED, function (e) {
events.push(e);
c.connect();
});
c.port = 1;
c.host = "localhost";
}
function testKeepConnecting() {
// ensure that keepConnecting keep trying connecting
// until the connection attempts timeout
- var originalTimeout = Services.prefs.getIntPref("devtools.debugger.remote-timeout");
+ let prefRemoteTimeout = "devtools.debugger.remote-timeout";
+ let originalTimeout = Services.prefs.getIntPref(prefRemoteTimeout);
Services.prefs.setIntPref("devtools.debugger.remote-timeout", 1000);
c.once("timeout", function (e) {
events.push(e);
- Services.prefs.setIntPref("devtools.debugger.remote-timeout", originalTimeout);
+ Services.prefs.setIntPref(prefRemoteTimeout, originalTimeout);
ConnectionManager.destroyConnection(c);
});
c.keepConnecting = true;
- var port = ConnectionManager.getFreeTCPPort();
- ok(parseInt(port), "Free TCP port looks like a port number");
+ let port = ConnectionManager.getFreeTCPPort();
+ ok(parseInt(port, 10), "Free TCP port looks like a port number");
c.port = port;
c.host = "locahost";
c.connect();
}
function finish() {
is(events.join(" "), eventsRef, "Events received in the right order");
DebuggerServer.destroy();
SimpleTest.finish();
}
-
});
ConnectionManager.destroyConnection(c1);
-
-
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_css-logic-media-queries.html
+++ b/devtools/server/tests/mochitest/test_css-logic-media-queries.html
@@ -20,24 +20,25 @@ Test that css-logic handles media-querie
width: 200px;
}
}
</style>
</head>
<body>
<div></div>
<script type="application/javascript">
+ "use strict";
- window.onload = function() {
- var { classes: Cc, utils: Cu, interfaces: Ci } = Components;
+ window.onload = function () {
+ const { classes: Cc, utils: Cu, interfaces: Ci } = Components;
const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils);
- var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var Services = require("Services");
+ const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ const Services = require("Services");
const {CssLogic} = require("devtools/server/css-logic");
SimpleTest.waitForExplicitFinish();
let div = document.querySelector("div");
let cssLogic = new CssLogic(DOMUtils.isInheritedProperty);
cssLogic.highlight(div);
cssLogic.processMatchedSelectors();
@@ -50,13 +51,12 @@ Test that css-logic handles media-querie
let source1 = inline + ":12";
let source2 = inline + ":19 @media screen and (min-width: 1px)";
is(cssLogic._matchedRules[0][0].source, source1,
"rule.source gives correct output for rule 1");
is(cssLogic._matchedRules[1][0].source, source2,
"rule.source gives correct output for rule 2");
SimpleTest.finish();
- }
-
+ };
</script>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_css-logic-specificity.html
+++ b/devtools/server/tests/mochitest/test_css-logic-specificity.html
@@ -5,19 +5,20 @@ Test that css-logic calculates CSS speci
-->
<head>
<meta charset="utf-8">
<title>Test css-logic specificity</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body style="background:blue;">
<script type="application/javascript">
+ "use strict";
- window.onload = function() {
- var {utils: Cu, classes: Cc, interfaces: Ci} = Components;
+ window.onload = function () {
+ const {utils: Cu, classes: Cc, interfaces: Ci} = Components;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const {CssLogic, CssSelector} = require("devtools/server/css-logic");
const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils);
const TEST_DATA = [
{text: "*", expected: 0},
@@ -53,32 +54,31 @@ Test that css-logic calculates CSS speci
createDocument();
let cssLogic = new CssLogic(DOMUtils.isInheritedProperty);
cssLogic.highlight(document.body);
let cssSheet = cssLogic.sheets[0];
let cssRule = cssSheet.domSheet.cssRules[0];
let selectors = CssLogic.getSelectors(cssRule);
- info("Iterating over the test selectors")
+ info("Iterating over the test selectors");
for (let i = 0; i < selectors.length; i++) {
let selectorText = selectors[i];
info("Testing selector " + selectorText);
let selector = new CssSelector(cssRule, selectorText, i);
let expected = getExpectedSpecificity(selectorText);
let specificity = DOMUtils.getSpecificity(selector.cssRule,
- selector.selectorIndex)
+ selector.selectorIndex);
is(specificity, expected,
'Selector "' + selectorText + '" has a specificity of ' + expected);
}
info("Testing specificity of element.style");
let colorProp = cssLogic.getPropertyInfo("background");
is(colorProp.matchedSelectors[0].specificity, 0x01000000,
"Element styles have specificity of 0x01000000 (16777216).");
SimpleTest.finish();
- }
-
+ };
</script>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_css-logic.html
+++ b/devtools/server/tests/mochitest/test_css-logic.html
@@ -6,59 +6,61 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
+"use strict";
+
const {CssLogic} = require("devtools/server/css-logic");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
addTest(function getComputedStyle() {
let node = document.querySelector("#computed-style");
- is (CssLogic.getComputedStyle(node).getPropertyValue("width"),
+ is(CssLogic.getComputedStyle(node).getPropertyValue("width"),
"50px", "Computed style on a normal node works (width)");
- is (CssLogic.getComputedStyle(node).getPropertyValue("height"),
+ is(CssLogic.getComputedStyle(node).getPropertyValue("height"),
"10px", "Computed style on a normal node works (height)");
let firstChild = new _documentWalker(node, window).firstChild();
- is (CssLogic.getComputedStyle(firstChild).getPropertyValue("content"),
- "\"before\"", "Computed style on a ::before node works (content)");
+ is(CssLogic.getComputedStyle(firstChild).getPropertyValue("content"),
+ "\"before\"", "Computed style on a ::before node works (content)");
let lastChild = new _documentWalker(node, window).lastChild();
- is (CssLogic.getComputedStyle(lastChild).getPropertyValue("content"),
- "\"after\"", "Computed style on a ::after node works (content)");
+ is(CssLogic.getComputedStyle(lastChild).getPropertyValue("content"),
+ "\"after\"", "Computed style on a ::after node works (content)");
runNextTest();
});
addTest(function getBindingElementAndPseudo() {
let node = document.querySelector("#computed-style");
- var {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node);
+ let {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node);
- is (bindingElement, node,
- "Binding element is the node itself for a normal node");
- ok (!pseudo, "Pseudo is null for a normal node");
+ is(bindingElement, node,
+ "Binding element is the node itself for a normal node");
+ ok(!pseudo, "Pseudo is null for a normal node");
let firstChild = new _documentWalker(node, window).firstChild();
- var {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(firstChild);
- is (bindingElement, node,
- "Binding element is the parent for a pseudo node");
- is (pseudo, ":before", "Pseudo is correct for a ::before node");
+ ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(firstChild));
+ is(bindingElement, node,
+ "Binding element is the parent for a pseudo node");
+ is(pseudo, ":before", "Pseudo is correct for a ::before node");
let lastChild = new _documentWalker(node, window).lastChild();
- var {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(lastChild);
- is (bindingElement, node,
- "Binding element is the parent for a pseudo node");
- is (pseudo, ":after", "Pseudo is correct for a ::after node");
+ ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(lastChild));
+ is(bindingElement, node,
+ "Binding element is the parent for a pseudo node");
+ is(pseudo, ":after", "Pseudo is correct for a ::after node");
runNextTest();
});
</script>
</head>
<body>
<style type="text/css">
--- a/devtools/server/tests/mochitest/test_css-properties.html
+++ b/devtools/server/tests/mochitest/test_css-properties.html
@@ -5,29 +5,31 @@ Bug 1265798 - Replace inIDOMUtils.cssPro
-->
<head>
<meta charset="utf-8">
<title>Test CSS Properties Actor</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
const { initCssProperties, getCssProperties } =
require("devtools/shared/fronts/css-properties");
- function promiseAttachUrl (url) {
+ function promiseAttachUrl(url) {
return new Promise((resolve, reject) => {
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
if (err) {
return reject(err);
}
- resolve({client, tab, doc});
+ return resolve({client, tab, doc});
});
- })
+ });
}
function toSortedString(array) {
return JSON.stringify(array.sort());
}
const runCssPropertiesTests = Task.async(function* (url, useActor) {
info(`Opening two tabs ${useActor ? "with" : "without"} CssPropertiesActor support.`);
@@ -58,17 +60,17 @@ window.onload = function() {
const cssProperties = getCssProperties(toolboxMockA);
const cssPropertiesA = getCssProperties(toolboxMockA);
const cssPropertiesB = getCssProperties(toolboxMockB);
is(cssProperties, cssPropertiesA,
"Multiple calls with the same toolbox returns the same object.");
isnot(cssProperties, cssPropertiesB,
- "Multiple calls with the different toolboxes return different "+
+ "Multiple calls with the different toolboxes return different " +
" objects.");
ok(cssProperties.isKnown("border"),
"The `border` shorthand property is known.");
ok(cssProperties.isKnown("display"),
"The `display` property is known.");
ok(!cssProperties.isKnown("foobar"),
"A fake property is not known.");
@@ -76,23 +78,23 @@ window.onload = function() {
"A CSS variable properly evaluates.");
ok(cssProperties.isKnown("--foob\\{ar"),
"A CSS variable with escaped character properly evaluates.");
ok(cssProperties.isKnown("--fübar"),
"A CSS variable unicode properly evaluates.");
ok(!cssProperties.isKnown("--foo bar"),
"A CSS variable with spaces fails");
- is(toSortedString(cssProperties.getValues('margin')),
- toSortedString(["auto","calc","inherit","initial","unset"]),
+ is(toSortedString(cssProperties.getValues("margin")),
+ toSortedString(["auto", "calc", "inherit", "initial", "unset"]),
"Can get values for the CSS margin.");
- is(cssProperties.getValues('foobar').length, 0,
+ is(cssProperties.getValues("foobar").length, 0,
"Unknown values return an empty array.");
- const bgColorValues = cssProperties.getValues('background-color');
+ const bgColorValues = cssProperties.getValues("background-color");
ok(bgColorValues.includes("blanchedalmond"),
"A property with color values includes blanchedalmond.");
ok(bgColorValues.includes("papayawhip"),
"A property with color values includes papayawhip.");
ok(bgColorValues.includes("rgb"),
"A property with color values includes non-colors.");
ok(cssProperties.isValidOnClient("margin", "0px", window.document),
@@ -106,16 +108,16 @@ window.onload = function() {
yield runCssPropertiesTests(url, true);
yield runCssPropertiesTests(url, false);
runNextTest();
});
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1265798">Mozilla Bug 1265798</a>
<a id="cssProperties" target="_blank" href="inspector_css-properties.html">Test Document</a>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_device.html
+++ b/devtools/server/tests/mochitest/test_device.html
@@ -7,85 +7,86 @@ Bug 895360 - [app manager] Device meta d
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
- var Cu = Components.utils;
- var Cc = Components.classes;
- var Ci = Components.interfaces;
+window.onload = function () {
+ const Cu = Components.utils;
+ const Cc = Components.classes;
+ const Ci = Components.interfaces;
- var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var {DebuggerClient} = require("devtools/shared/client/main");
- var {DebuggerServer} = require("devtools/server/main");
- var Services = require("Services");
+ const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ const {DebuggerClient} = require("devtools/shared/client/main");
+ const {DebuggerServer} = require("devtools/server/main");
+ const Services = require("Services");
SimpleTest.waitForExplicitFinish();
- var {getDeviceFront} = require("devtools/shared/fronts/device");
+ const {getDeviceFront} = require("devtools/shared/fronts/device");
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
}
- var client = new DebuggerClient(DebuggerServer.connectPipe());
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() {
- client.listTabs(function onListTabs(aResponse) {
- var d = getDeviceFront(client, aResponse);
+ client.listTabs(function onListTabs(response) {
+ let d = getDeviceFront(client, response);
- var desc;
- var appInfo = Services.appinfo;
- var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+ let desc;
+ let appInfo = Services.appinfo;
+ let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
-
- var localDesc = {
+ let localDesc = {
appid: appInfo.ID,
vendor: appInfo.vendor,
name: appInfo.name,
version: appInfo.version,
appbuildid: appInfo.appBuildID,
platformbuildid: appInfo.platformBuildID,
platformversion: appInfo.platformVersion,
geckobuildid: appInfo.platformBuildID,
geckoversion: appInfo.platformVersion,
useragent: window.navigator.userAgent,
- locale: Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"),
+ locale: Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"),
os: appInfo.OS,
processor: appInfo.XPCOMABI.split("-")[0],
compiler: appInfo.XPCOMABI.split("-")[1],
dpi: utils.displayDPI,
width: window.screen.width,
height: window.screen.height
- }
+ };
function checkValues() {
- for (var key in localDesc) {
+ for (let key in localDesc) {
is(desc[key], localDesc[key], "valid field (" + key + ")");
}
- var currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile);
- var profileDir = currProfD.path;
- ok(profileDir.indexOf(desc.profile.length > 0 && desc.profile) != -1, "valid profile name");
+ let currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile);
+ let profileDir = currProfD.path;
+ ok(profileDir.indexOf(desc.profile.length > 0 && desc.profile) != -1,
+ "valid profile name");
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
}
-
- d.getDescription().then((v) => desc = v)
- .then(checkValues);
-
+ d.getDescription().then(function (v) {
+ desc = v;
+ }).then(checkValues);
});
});
-
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_director.html
+++ b/devtools/server/tests/mochitest/test_director.html
@@ -9,53 +9,55 @@ https://bugzilla.mozilla.org/show_bug.cg
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script type="application/javascript" src="./director-helpers.js"></script>
<script type="application/javascript">
-const WAIT_EVENT_TIMEOUT = 3000;
+"use strict";
-window.onload = function() {
+window.onload = function () {
Task.spawn(function* () {
SimpleTest.waitForExplicitFinish();
- var tests = [
+ let tests = [
runDirectorRegistryActorTest
].map((testCase) => {
return function* () {
setup();
yield testCase().then(null, (e) => {
console.error("Exception during testCase run", e);
- ok(false, "Exception during testCase run: " + [e, e.fileName, e.lineNumber].join("\n\t"));
+ ok(false, "Exception during testCase run: "
+ + [e, e.fileName, e.lineNumber].join("\n\t"));
});
teardown();
};
});
- for (var test of tests) {
+ for (let test of tests) {
yield test();
}
}).then(
function success() {
- SimpleTest.finish()
+ SimpleTest.finish();
},
function error(e) {
console.error("Exception during testCase run", e);
- ok(false, "Exception during testCase run: " + [e, e.fileName, e.lineNumber].join("\n\t"));
+ ok(false, "Exception during testCase run: "
+ + [e, e.fileName, e.lineNumber].join("\n\t"));
SimpleTest.finish();
}
);
};
-var targetWin = null;
+let targetWin = null;
function setup() {
if (!DebuggerServer.initialized) {
DebuggerServer.init(() => true);
DebuggerServer.addBrowserActors();
SimpleTest.registerCleanupFunction(teardown);
}
@@ -65,50 +67,44 @@ function teardown() {
purgeInstalledDirectorScripts();
DebuggerServer.destroy();
if (targetWin) {
targetWin.close();
}
}
-/***********************************
- * test cases
- **********************************/
-
-
function runDirectorRegistryActorTest() {
let testDirectorScriptOptions = {
- scriptCode: "(" + (function() {
- module.exports = function({port}) {
- port.onmessage = function(evt) {
+ scriptCode: "(" + (function () {
+ module.exports = function ({port}) {
+ port.onmessage = function (evt) {
// echo messages
evt.target.postMessage(evt.data);
};
};
}).toString() + ")();",
scriptOptions: {}
- }
+ };
return Task.spawn(function* () {
let { client, root } = yield newConnectedDebuggerClient();
- var directorRegistryClient = new DirectorRegistryFront(client, root);
+ let directorRegistryClient = new DirectorRegistryFront(client, root);
- let installed = yield directorRegistryClient.install("testDirectorScript", testDirectorScriptOptions);
+ let installed = yield directorRegistryClient.install("testDirectorScript",
+ testDirectorScriptOptions);
is(installed, true, "DirectorManager.install returns true");
let list = yield directorRegistryClient.list();
is(JSON.stringify(list), JSON.stringify(["testDirectorScript"]),
"DirectorManager.list contains the installed director script");
let uninstalled = yield directorRegistryClient.uninstall("testDirectorScript");
is(uninstalled, true, "DirectorManager.uninstall return true");
yield client.close();
});
}
-
-
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_director_connectToChild.html
+++ b/devtools/server/tests/mochitest/test_director_connectToChild.html
@@ -9,90 +9,89 @@ https://bugzilla.mozilla.org/show_bug.cg
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script type="application/javascript" src="./director-helpers.js"></script>
<script type="application/javascript">
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
Task.spawn(function* () {
SimpleTest.waitForExplicitFinish();
- var tests = [
+ let tests = [
runPropagateDirectorScriptsToChildTest,
].map((testCase) => {
return function* () {
setup();
yield testCase().then(null, (e) => {
- ok(false, "Exception during testCase run: " + [e, e.fileName, e.lineNumber].join("\n\t"));
+ ok(false, "Exception during testCase run: "
+ + [e, e.fileName, e.lineNumber].join("\n\t"));
});
teardown();
};
});
- for (var test of tests) {
+ for (let test of tests) {
yield test();
}
SimpleTest.finish();
});
};
function setup() {
if (!DebuggerServer.initialized) {
DebuggerServer.init(() => true);
DebuggerServer.addBrowserActors();
- SimpleTest.registerCleanupFunction(function() {
+ SimpleTest.registerCleanupFunction(function () {
DebuggerServer.destroy();
});
}
}
function teardown() {
purgeInstalledDirectorScripts();
DebuggerServer.destroy();
}
-/***********************************
- * test cases
- **********************************/
-
function runPropagateDirectorScriptsToChildTest() {
let iframe = document.createElement("iframe");
iframe.mozbrowser = true;
document.body.appendChild(iframe);
return Task.spawn(function* () {
- var { client, root, transport } = yield newConnectedDebuggerClient();
+ let { client, root, transport } = yield newConnectedDebuggerClient();
- var directorRegistryClient = new DirectorRegistryFront(client, root);
+ let directorRegistryClient = new DirectorRegistryFront(client, root);
// install a director script
yield directorRegistryClient.install("testPropagatedDirectorScript", {
scriptCode: "console.log('director script test');",
scriptOptions: {}
});
- var conn = transport._serverConnection;
- var childActor = yield DebuggerServer.connectToChild(conn, iframe);
+ let conn = transport._serverConnection;
+ let childActor = yield DebuggerServer.connectToChild(conn, iframe);
ok(typeof childActor.directorManagerActor !== "undefined",
"childActor.directorActor should be defined");
- var childDirectorManagerClient = new DirectorManagerFront(client, childActor);
+ let childDirectorManagerClient = new DirectorManagerFront(client, childActor);
- var directorScriptList = yield childDirectorManagerClient.list();
+ let directorScriptList = yield childDirectorManagerClient.list();
ok(directorScriptList.installed.length === 1 &&
directorScriptList.installed[0] === "testPropagatedDirectorScript",
- "director scripts propagated correctly")
+ "director scripts propagated correctly");
yield client.close();
});
}
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_executeInGlobal-outerized_this.html
+++ b/devtools/server/tests/mochitest/test_executeInGlobal-outerized_this.html
@@ -11,59 +11,63 @@ object.
<meta charset="utf-8">
<title>Mozilla Bug 837060</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var iframe = document.createElement("iframe");
+ let iframe = document.createElement("iframe");
iframe.src = "data:text/html,<script>var me = 'page 1';<\/script>";
iframe.onload = firstOnLoadHandler;
document.body.appendChild(iframe);
function firstOnLoadHandler() {
- var dbg = new Debugger;
- var page1DO = dbg.addDebuggee(iframe.contentWindow);
+ let dbg = new Debugger();
+ let page1DO = dbg.addDebuggee(iframe.contentWindow);
iframe.src = "data:text/html,<script>var me = 'page 2';<\/script>";
iframe.onload = function () {
- var page2DO = dbg.addDebuggee(iframe.contentWindow);
+ let page2DO = dbg.addDebuggee(iframe.contentWindow);
ok(page1DO !== page2DO, "the two pages' globals get distinct D.O's");
ok(page1DO.unsafeDereference() === page2DO.unsafeDereference(),
"unwrapping page1DO and page2DO outerizes both, yielding the same outer window");
- is(page1DO.executeInGlobal('me').return, 'page 1', "page1DO continues to refer to original page");
- is(page2DO.executeInGlobal('me').return, 'page 2', "page2DO refers to current page");
+ is(page1DO.executeInGlobal("me").return,
+ "page 1", "page1DO continues to refer to original page");
+ is(page2DO.executeInGlobal("me").return, "page 2",
+ "page2DO refers to current page");
- is(page1DO.executeInGlobal('this === window').return, true,
+ is(page1DO.executeInGlobal("this === window").return, true,
"page 1: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
- is(page1DO.executeInGlobalWithBindings('this === window', {x:2}).return, true,
+ is(page1DO.executeInGlobalWithBindings("this === window", {x: 2}).return, true,
"page 1: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
- is(page2DO.executeInGlobal('this === window').return, true,
+ is(page2DO.executeInGlobal("this === window").return, true,
"page 2: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
- is(page2DO.executeInGlobalWithBindings('this === window', {x:2}).return, true,
+ is(page2DO.executeInGlobalWithBindings("this === window", {x: 2}).return, true,
"page 2: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
// Debugger doesn't let one use outer windows as globals. You have to innerize.
- var outerDO = page1DO.makeDebuggeeValue(page1DO.unsafeDereference());
- ok(outerDO !== page1DO, "outer window gets its own D.O, distinct from page 1's global");
- ok(outerDO !== page2DO, "outer window gets its own D.O, distinct from page 2's global");
- SimpleTest.doesThrow(function () { outerDO.executeInGlobal('me'); },
+ let outerDO = page1DO.makeDebuggeeValue(page1DO.unsafeDereference());
+ ok(outerDO !== page1DO,
+ "outer window gets its own D.O, distinct from page 1's global");
+ ok(outerDO !== page2DO,
+ "outer window gets its own D.O, distinct from page 2's global");
+ SimpleTest.doesThrow(() => outerDO.executeInGlobal("me"),
"outer window D.Os can't be used as globals");
SimpleTest.finish();
- }
+ };
}
-}
-
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_framerate_01.html
+++ b/devtools/server/tests/mochitest/test_framerate_01.html
@@ -7,135 +7,132 @@ Bug 1007200 - Create a framerate actor
<meta charset="utf-8">
<title>Framerate actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
- var Cu = Components.utils;
- var Cc = Components.classes;
- var Ci = Components.interfaces;
+window.onload = function () {
+ const Cu = Components.utils;
- var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var Services = require("Services");
- var { DebuggerClient } = require("devtools/shared/client/main");
- var { DebuggerServer } = require("devtools/server/main");
+ const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ const Services = require("Services");
+ const { DebuggerClient } = require("devtools/shared/client/main");
+ const { DebuggerServer } = require("devtools/server/main");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
- SimpleTest.registerCleanupFunction(function() {
+ SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log");
});
SimpleTest.waitForExplicitFinish();
- var {FramerateFront} = require("devtools/shared/fronts/framerate");
+ const { FramerateFront } = require("devtools/shared/fronts/framerate");
function plotFPS(ticks, interval = 100, clamp = 60) {
- var timeline = [];
- var totalTicks = ticks.length;
+ let timeline = [];
+ let totalTicks = ticks.length;
// If the refresh driver didn't get a chance to tick before the
// recording was stopped, assume framerate was 0.
if (totalTicks == 0) {
timeline.push({ delta: 0, value: 0 });
timeline.push({ delta: interval, value: 0 });
return timeline;
}
- var frameCount = 0;
- var prevTime = ticks[0];
+ let frameCount = 0;
+ let prevTime = ticks[0];
- for (var i = 1; i < totalTicks; i++) {
- var currTime = ticks[i];
+ for (let i = 1; i < totalTicks; i++) {
+ let currTime = ticks[i];
frameCount++;
- var elapsedTime = currTime - prevTime;
+ let elapsedTime = currTime - prevTime;
if (elapsedTime < interval) {
continue;
}
- var framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
+ let framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
timeline.push({ delta: prevTime, value: framerate });
timeline.push({ delta: currTime, value: framerate });
frameCount = 0;
prevTime = currTime;
}
return timeline;
- };
+ }
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
}
- var client = new DebuggerClient(DebuggerServer.connectPipe());
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() {
- client.listTabs(function onListTabs(aResponse) {
- var form = aResponse.tabs[aResponse.selected];
- var front = FramerateFront(client, form);
+ client.listTabs(function onListTabs(response) {
+ let form = response.tabs[response.selected];
+ let front = FramerateFront(client, form);
window.setTimeout(() => {
+ /* eslint-disable max-nested-callbacks */
front.startRecording().then(() => {
window.setTimeout(() => {
front.stopRecording().then(rawData => {
onRecordingStopped(front, rawData);
});
}, 1000);
});
+ /* eslint-enable max-nested-callbacks */
}, 1000);
});
});
function onRecordingStopped(front, rawData) {
ok(rawData, "There should be a recording available.");
- var timeline = plotFPS(rawData);
+ let timeline = plotFPS(rawData);
ok(timeline.length >= 2,
"There should be at least one measurement available, with two entries.");
- var prevTimeStart = timeline[0].delta;
+ let prevTimeStart = timeline[0].delta;
- for (var i = 0; i < timeline.length; i += 2) {
- var currTimeStart = timeline[i].delta;
- var currTimeEnd = timeline[i + 1].delta;
+ for (let i = 0; i < timeline.length; i += 2) {
+ let currTimeStart = timeline[i].delta;
+ let currTimeEnd = timeline[i + 1].delta;
info("Testing delta: " + currTimeStart + " vs. " + currTimeEnd);
ok(currTimeStart < currTimeEnd,
"The start and end time deltas should be consecutive.");
is(currTimeStart, prevTimeStart,
"There should be two time deltas for each framerate value.");
prevTimeStart = currTimeEnd;
}
- var prevFramerateValue = -1;
-
- for (var i = 0; i < timeline.length; i += 2) {
- var currFramerateStart = timeline[i].value;
- var currFramerateEnd = timeline[i + 1].value;
+ for (let i = 0; i < timeline.length; i += 2) {
+ let currFramerateStart = timeline[i].value;
+ let currFramerateEnd = timeline[i + 1].value;
info("Testing framerate: " + currFramerateStart);
is(currFramerateStart, currFramerateEnd,
"The start and end framerate values should be equal.");
is(typeof currFramerateStart, "number", "All values should be numbers.");
- ok(currFramerateStart <= 60, "All values were correctly clamped.")
-
- prevFramerateValue = currFramerateStart;
+ ok(currFramerateStart <= 60, "All values were correctly clamped.");
}
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
}
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_framerate_02.html
+++ b/devtools/server/tests/mochitest/test_framerate_02.html
@@ -7,107 +7,107 @@ Bug 1007200 - Create a framerate actor
<meta charset="utf-8">
<title>Framerate actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
- var Cu = Components.utils;
- var Cc = Components.classes;
- var Ci = Components.interfaces;
+window.onload = function () {
+ const Cu = Components.utils;
- var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var {DebuggerClient} = require("devtools/shared/client/main");
- var {DebuggerServer} = require("devtools/server/main");
- var Services = require("Services");
+ const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ const {DebuggerClient} = require("devtools/shared/client/main");
+ const {DebuggerServer} = require("devtools/server/main");
+ const Services = require("Services");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
- SimpleTest.registerCleanupFunction(function() {
+ SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log");
});
SimpleTest.waitForExplicitFinish();
- var {FramerateFront} = require("devtools/shared/fronts/framerate");
+ const {FramerateFront} = require("devtools/shared/fronts/framerate");
function plotFPS(ticks, interval = 100, clamp = 60) {
- var timeline = [];
- var totalTicks = ticks.length;
+ let timeline = [];
+ let totalTicks = ticks.length;
// If the refresh driver didn't get a chance to tick before the
// recording was stopped, assume framerate was 0.
if (totalTicks == 0) {
timeline.push({ delta: 0, value: 0 });
timeline.push({ delta: interval, value: 0 });
return timeline;
}
- var frameCount = 0;
- var prevTime = ticks[0];
+ let frameCount = 0;
+ let prevTime = ticks[0];
- for (var i = 1; i < totalTicks; i++) {
- var currTime = ticks[i];
+ for (let i = 1; i < totalTicks; i++) {
+ let currTime = ticks[i];
frameCount++;
- var elapsedTime = currTime - prevTime;
+ let elapsedTime = currTime - prevTime;
if (elapsedTime < interval) {
continue;
}
- var framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
+ let framerate = Math.min(1000 / (elapsedTime / frameCount), clamp);
timeline.push({ delta: prevTime, value: framerate });
timeline.push({ delta: currTime, value: framerate });
frameCount = 0;
prevTime = currTime;
}
return timeline;
- };
+ }
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
}
- var client = new DebuggerClient(DebuggerServer.connectPipe());
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() {
- client.listTabs(function onListTabs(aResponse) {
- var form = aResponse.tabs[aResponse.selected];
- var front = FramerateFront(client, form);
+ client.listTabs(function onListTabs(response) {
+ let form = response.tabs[response.selected];
+ let front = FramerateFront(client, form);
front.stopRecording().then(rawData => {
ok(rawData, "There should be a recording available.");
is(rawData.length, 0, "...but it should be empty.");
- var timeline = plotFPS(rawData);
+ let timeline = plotFPS(rawData);
is(timeline.length, 2,
"There should be one measurement plotted, with two entries.");
info("The framerate should be assumed to be 0 if the recording is empty.");
is(timeline[0].delta, 0,
"The first time delta should be 0.");
is(timeline[0].value, 0,
"The first framerate value should be 0.");
is(timeline[1].delta, 100,
"The last time delta should be 100 (the default interval value).");
is(timeline[1].value, 0,
"The last framerate value should be 0.");
+ // eslint-disable-next-line max-nested-callbacks
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
});
});
});
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_framerate_03.html
+++ b/devtools/server/tests/mochitest/test_framerate_03.html
@@ -7,76 +7,77 @@ Bug 1023018 - Tests whether or not the f
<meta charset="utf-8">
<title>Framerate actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
- var Cu = Components.utils;
- var Cc = Components.classes;
- var Ci = Components.interfaces;
+window.onload = function () {
+ const Cu = Components.utils;
- var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var {DebuggerClient} = require("devtools/shared/client/main");
- var {DebuggerServer} = require("devtools/server/main");
- var Services = require("Services");
+ const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ const {DebuggerClient} = require("devtools/shared/client/main");
+ const {DebuggerServer} = require("devtools/server/main");
+ const Services = require("Services");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
- SimpleTest.registerCleanupFunction(function() {
+ SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log");
});
SimpleTest.waitForExplicitFinish();
- var {FramerateFront} = require("devtools/shared/fronts/framerate");
- var START_TICK = 2000;
- var STOP_TICK = 3000;
- var TOTAL_TIME = 5000;
+ const {FramerateFront} = require("devtools/shared/fronts/framerate");
+ const START_TICK = 2000;
+ const STOP_TICK = 3000;
+ const TOTAL_TIME = 5000;
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
}
- var client = new DebuggerClient(DebuggerServer.connectPipe());
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() {
- client.listTabs(function onListTabs(aResponse) {
- var form = aResponse.tabs[aResponse.selected];
- var front = FramerateFront(client, form);
+ client.listTabs(function onListTabs(response) {
+ let form = response.tabs[response.selected];
+ let front = FramerateFront(client, form);
front.startRecording().then(() => {
+ /* eslint-disable max-nested-callbacks */
window.setTimeout(() => {
front.stopRecording(START_TICK, STOP_TICK).then(rawData => {
onRecordingStopped(front, rawData);
});
}, TOTAL_TIME);
+ /* eslint-enable max-nested-callbacks */
});
});
});
function onRecordingStopped(front, rawData) {
ok(rawData, "There should be a recording available.");
ok(!rawData.find(e => e < START_TICK),
"There should be no tick before 2000ms.");
ok(!rawData.find(e => e > STOP_TICK),
"There should be no tick after 3000ms.");
- for (var tick of rawData) {
+ for (let tick of rawData) {
info("Testing tick: " + tick);
is(typeof tick, "number", "All values should be numbers.");
}
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
}
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_framerate_04.html
+++ b/devtools/server/tests/mochitest/test_framerate_04.html
@@ -8,65 +8,68 @@ Bug 1023018 - Tests if the framerate act
<title>Framerate actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="inspector-helpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var {FramerateFront} = require("devtools/shared/fronts/framerate");
- var {TargetFactory} = require("devtools/client/framework/target");
+ const {FramerateFront} = require("devtools/shared/fronts/framerate");
+ const {TargetFactory} = require("devtools/client/framework/target");
- var url = document.getElementById("testContent").href;
+ let url = document.getElementById("testContent").href;
attachURL(url, onTab);
function onTab(_, client, form, contentDoc) {
- var contentWin = contentDoc.defaultView;
- var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
- var selectedTab = chromeWin.gBrowser.selectedTab;
+ let contentWin = contentDoc.defaultView;
+ let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
+ let selectedTab = chromeWin.gBrowser.selectedTab;
- var target = TargetFactory.forTab(selectedTab);
- var front = FramerateFront(client, form);
+ let target = TargetFactory.forTab(selectedTab);
+ let front = FramerateFront(client, form);
front.startRecording().then(() => {
window.setTimeout(() => {
front.getPendingTicks().then(firstBatch => {
+ /* eslint-disable max-nested-callbacks */
target.once("will-navigate", () => {
window.setTimeout(() => {
front.stopRecording().then(secondBatch => {
onRecordingStopped(client, firstBatch, secondBatch);
});
}, 1000);
});
+ /* eslint-enable max-nested-callbacks */
contentWin.location.reload();
});
}, 1000);
});
}
function onRecordingStopped(client, firstBatch, secondBatch) {
ok(firstBatch, "There should be a first batch recording available.");
ok(secondBatch, "There should be a second batch recording available.");
- var diff = secondBatch.length - firstBatch.length;
+ let diff = secondBatch.length - firstBatch.length;
info("Difference in ticks: " + diff);
ok(diff > 0, "More ticks should be recorded in the second batch.");
ok(firstBatch.every((e) => secondBatch.indexOf(e) != -1),
"All the ticks in the first batch should be in the second batch as well.");
ok(secondBatch.every((e, i, array) => i < array.length - 1 ? e < array[i + 1] : true),
"All the ticks in the final batch should be ascending in value.");
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
}
-}
+};
</script>
</pre>
<a id="testContent" target="_blank" href="inspector_getImageData.html">Test Document</a>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_framerate_05.html
+++ b/devtools/server/tests/mochitest/test_framerate_05.html
@@ -7,47 +7,47 @@ Bug 1034648 - Tests whether a framerate
<meta charset="utf-8">
<title>Framerate actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
- var Cu = Components.utils;
- var Cc = Components.classes;
- var Ci = Components.interfaces;
+window.onload = function () {
+ let Cu = Components.utils;
- var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var {DebuggerClient} = require("devtools/shared/client/main");
- var {DebuggerServer} = require("devtools/server/main");
- var Services = require("Services");
+ const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ const {DebuggerClient} = require("devtools/shared/client/main");
+ const {DebuggerServer} = require("devtools/server/main");
+ const Services = require("Services");
// Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true);
- SimpleTest.registerCleanupFunction(function() {
+ SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log");
});
SimpleTest.waitForExplicitFinish();
- var {FramerateFront} = require("devtools/shared/fronts/framerate");
+ const {FramerateFront} = require("devtools/shared/fronts/framerate");
DebuggerServer.init();
DebuggerServer.addBrowserActors();
- var client = new DebuggerClient(DebuggerServer.connectPipe());
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() {
- client.listTabs(function onListTabs(aResponse) {
- var form = aResponse.tabs[aResponse.selected];
- var front = FramerateFront(client, form);
+ client.listTabs(function onListTabs(response) {
+ let form = response.tabs[response.selected];
+ let front = FramerateFront(client, form);
front.startRecording().then(() => {
+ /* eslint-disable max-nested-callbacks */
window.setTimeout(() => {
front.cancelRecording().then(() => {
window.setTimeout(() => {
front.getPendingTicks().then(rawTicks => {
ok(rawTicks,
"The returned pending ticks should be empty (1).");
is(rawTicks.length, 0,
"The returned pending ticks should be empty (2).");
@@ -55,23 +55,24 @@ window.onload = function() {
front.stopRecording().then(rawData => {
ok(rawData,
"The returned raw data should be an empty array (1).");
is(rawData.length, 0,
"The returned raw data should be an empty array (2).");
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
});
});
}, 1000);
});
}, 1000);
+ /* eslint-enable max-nested-callbacks */
});
});
});
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_framerate_06.html
+++ b/devtools/server/tests/mochitest/test_framerate_06.html
@@ -8,75 +8,76 @@ Bug 1171489 - Tests if the framerate act
<title>Framerate actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="inspector-helpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var {FramerateFront} = require("devtools/shared/fronts/framerate");
- var {TargetFactory} = require("devtools/client/framework/target");
+ const {FramerateFront} = require("devtools/shared/fronts/framerate");
- var url = document.getElementById("testContent").href;
+ let url = document.getElementById("testContent").href;
attachURL(url, onTab);
function onTab(_, client, form, contentDoc) {
- var contentWin = contentDoc.defaultView;
- var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
- var selectedTab = chromeWin.gBrowser.selectedTab;
+ let contentWin = contentDoc.defaultView;
- var target = TargetFactory.forTab(selectedTab);
- var front = FramerateFront(client, form);
+ let front = FramerateFront(client, form);
front.startRecording().then(() => {
window.setTimeout(() => {
// Wait for the iframe to be loaded again
- window.addEventListener("message", function loaded (event) {
+ window.addEventListener("message", function loaded(event) {
if (event.data === "ready") {
window.removeEventListener("message", loaded);
+ /* eslint-disable max-nested-callbacks */
window.setTimeout(() => {
front.stopRecording().then(ticks => {
onRecordingStopped(client, ticks);
});
}, 1000);
+ /* eslint-enable max-nested-callbacks */
}
});
contentWin.location.reload();
}, 1000);
});
}
function onRecordingStopped(client, ticks) {
- var diffs = [];
+ let diffs = [];
info(`Got ${ticks.length} ticks.`);
- for (var i = 1; i < ticks.length; i++) {
- var prev = ticks[i - 1];
- var curr = ticks[i];
+ for (let i = 1; i < ticks.length; i++) {
+ let prev = ticks[i - 1];
+ let curr = ticks[i];
diffs.push(curr - prev);
info(curr + " - " + (curr - prev));
}
// 1000 / 60 => 16.666... so we shouldn't get more than diffs of 16.66.. but
// when we get ticks from other frames they're usually at diffs of < 1. Sometimes
// ticks can still be less than 16ms even on one frame (usually following a very slow
// frame), so use a low number (2) to be our threshold
- var THRESHOLD = 2;
- ok(ticks.length >= 20, "we should have atleast 20 ticks over the course of two seconds.");
- var belowThreshold = diffs.filter(v => v <= THRESHOLD);
- ok(belowThreshold.length <= 10, "we should have very few frames less than the threshold");
+ let THRESHOLD = 2;
+ ok(ticks.length >= 20,
+ "we should have atleast 20 ticks over the course of two seconds.");
+ let belowThreshold = diffs.filter(v => v <= THRESHOLD);
+ ok(belowThreshold.length <= 10,
+ "we should have very few frames less than the threshold");
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
}
-}
+};
</script>
</pre>
<a id="testContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_getProcess.html
+++ b/devtools/server/tests/mochitest/test_getProcess.html
@@ -7,40 +7,39 @@ Bug 1060093 - Test DebuggerServer.getPro
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script type="application/javascript">
+"use strict";
let Cu = Components.utils;
-let Cc = Components.classes;
-let Ci = Components.interfaces;
let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
let {DebuggerClient} = require("devtools/shared/client/main");
let {DebuggerServer} = require("devtools/server/main");
let Services = require("Services");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [
// Always log packets when running tests.
["devtools.debugger.log", true],
// Enabled mozbrowser frame to support remote=true
["dom.mozBrowserFramesEnabled", true],
// Allows creating a branch new process when creation the iframe
["dom.ipc.processCount", 10],
]
}, runTests);
-}
+};
function runTests() {
// Instantiate a minimal server
if (!DebuggerServer.initialized) {
DebuggerServer.init();
}
DebuggerServer.allowChromeProcess = true;
if (!DebuggerServer.createRootActor) {
@@ -76,33 +75,33 @@ function runTests() {
iframe.setAttribute("remote", "true");
iframe.setAttribute("src", "data:text/html,foo");
document.body.appendChild(iframe);
}
function getProcess() {
client.mainRoot.listProcesses(response => {
ok(response.processes.length >= 2, "Got at least the parent process and one child");
- is(response.processes.length, processCount+1 , "Got one additional process on the second call to listProcesses");
+ is(response.processes.length, processCount + 1,
+ "Got one additional process on the second call to listProcesses");
// Connect to the first content processe available
let content = response.processes.filter(p => (!p.parent))[0];
- client.getProcess(content.id).then(response => {
- let actor = response.form;
+ client.getProcess(content.id).then(({form: actor}) => {
ok(actor.consoleActor, "Got the console actor");
ok(actor.chromeDebugger, "Got the thread actor");
// Ensure sending at least one request to an actor...
client.request({
to: actor.consoleActor,
type: "evaluateJS",
text: "var a = 42; a"
- }, function (response) {
- ok(response.result, 42, "console.eval worked");
+ }, function ({result}) {
+ ok(result, 42, "console.eval worked");
getProcessAgain(actor, content.id);
});
});
});
}
// Assert that calling client.getProcess against the same process id is
@@ -113,46 +112,46 @@ function runTests() {
is(actor, firstActor,
"Second call to getProcess with the same id returns the same form");
closeClient();
});
}
function processScript() {
let listener = function () {
- Services.obs.removeObserver(listener, "sdk:loader:destroy", false);
+ Services.obs.removeObserver(listener, "sdk:loader:destroy");
sendAsyncMessage("test:getProcess-destroy", null);
};
Services.obs.addObserver(listener, "sdk:loader:destroy", false);
}
function closeClient() {
let onLoaderDestroyed = new Promise(done => {
let processListener = function () {
- Services.ppmm.removeMessageListener("test:getProcess-destroy", processListener)
+ Services.ppmm.removeMessageListener("test:getProcess-destroy", processListener);
done();
};
- Services.ppmm.addMessageListener("test:getProcess-destroy", processListener)
+ Services.ppmm.addMessageListener("test:getProcess-destroy", processListener);
});
let script = "data:,(" + processScript + ")()";
Services.ppmm.loadProcessScript(script, true);
client.close();
onLoaderDestroyed.then(function () {
Services.ppmm.removeDelayedProcessScript(script);
info("Loader destroyed in the content process");
cleanup();
});
}
function cleanup() {
DebuggerServer.destroy();
iframe.remove();
- SimpleTest.finish()
+ SimpleTest.finish();
}
connect();
}
</script>
</pre>
</body>
--- a/devtools/server/tests/mochitest/test_inspector-anonymous.html
+++ b/devtools/server/tests/mochitest/test_inspector-anonymous.html
@@ -6,185 +6,187 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 777674</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
const {InspectorFront} =
require("devtools/shared/fronts/inspector");
const {_documentWalker} =
require("devtools/server/actors/inspector");
const nodeFilterConstants =
require("devtools/shared/dom-node-filter-constants");
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
SpecialPowers.pushPrefEnv({"set": [
["dom.webcomponents.enabled", true]
]});
SimpleTest.waitForExplicitFinish();
let gWalker = null;
- let gClient = null;
+ let gInspectee = null;
addTest(function setup() {
- info ("Setting up inspector and walker actors.");
+ info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addAsyncTest(function* testXBLAnonymousInHTMLDocument() {
- info ("Testing XBL anonymous in an HTML document.");
+ info("Testing XBL anonymous in an HTML document.");
let rawToolbarbutton = gInspectee.createElementNS(XUL_NS, "toolbarbutton");
gInspectee.documentElement.appendChild(rawToolbarbutton);
let toolbarbutton = yield gWalker.querySelector(gWalker.rootNode, "toolbarbutton");
let children = yield gWalker.children(toolbarbutton);
- is (toolbarbutton.numChildren, 0, "XBL content is not visible in HTML doc");
- is (children.nodes.length, 0, "XBL content is not returned in HTML doc");
+ is(toolbarbutton.numChildren, 0, "XBL content is not visible in HTML doc");
+ is(children.nodes.length, 0, "XBL content is not returned in HTML doc");
runNextTest();
});
addAsyncTest(function* testNativeAnonymous() {
- info ("Testing native anonymous content with walker.");
+ info("Testing native anonymous content with walker.");
let select = yield gWalker.querySelector(gWalker.rootNode, "select");
let children = yield gWalker.children(select);
- is (select.numChildren, 2, "No native anon content for form control");
- is (children.nodes.length, 2, "No native anon content for form control");
+ is(select.numChildren, 2, "No native anon content for form control");
+ is(children.nodes.length, 2, "No native anon content for form control");
runNextTest();
});
addAsyncTest(function* testNativeAnonymousStartingNode() {
- info ("Tests attaching an element that a walker can't see.");
+ info("Tests attaching an element that a walker can't see.");
let serverWalker = DebuggerServer._searchAllConnectionsForActor(gWalker.actorID);
let docwalker = new _documentWalker(
gInspectee.querySelector("select"),
gInspectee.defaultView,
nodeFilterConstants.SHOW_ALL,
() => {
- return nodeFilterConstants.FILTER_ACCEPT
+ return nodeFilterConstants.FILTER_ACCEPT;
}
);
let scrollbar = docwalker.lastChild();
- is (scrollbar.tagName, "scrollbar", "An anonymous child has been fetched");
+ is(scrollbar.tagName, "scrollbar", "An anonymous child has been fetched");
let node = yield serverWalker.attachElement(scrollbar);
- ok (node, "A response has arrived");
- ok (node.node, "A node is in the response");
- is (node.node.rawNode.tagName, "SELECT",
+ ok(node, "A response has arrived");
+ ok(node.node, "A node is in the response");
+ is(node.node.rawNode.tagName, "SELECT",
"The node has changed to a parent that the walker recognizes");
runNextTest();
});
addAsyncTest(function* testPseudoElements() {
- info ("Testing pseudo elements with walker.");
+ info("Testing pseudo elements with walker.");
// Markup looks like: <div><::before /><span /><::after /></div>
let pseudo = yield gWalker.querySelector(gWalker.rootNode, "#pseudo");
let children = yield gWalker.children(pseudo);
- is (pseudo.numChildren, 1, "::before/::after are not counted if there is a child");
- is (children.nodes.length, 3, "Correct number of children");
+ is(pseudo.numChildren, 1, "::before/::after are not counted if there is a child");
+ is(children.nodes.length, 3, "Correct number of children");
let before = children.nodes[0];
- ok (before.isAnonymous, "Child is anonymous");
- ok (!before._form.isXBLAnonymous, "Child is not XBL anonymous");
- ok (!before._form.isShadowAnonymous, "Child is not shadow anonymous");
- ok (before._form.isNativeAnonymous, "Child is native anonymous");
+ ok(before.isAnonymous, "Child is anonymous");
+ ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
+ ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
+ ok(before._form.isNativeAnonymous, "Child is native anonymous");
let span = children.nodes[1];
- ok (!span.isAnonymous, "Child is not anonymous");
+ ok(!span.isAnonymous, "Child is not anonymous");
let after = children.nodes[2];
- ok (after.isAnonymous, "Child is anonymous");
- ok (!after._form.isXBLAnonymous, "Child is not XBL anonymous");
- ok (!after._form.isShadowAnonymous, "Child is not shadow anonymous");
- ok (after._form.isNativeAnonymous, "Child is native anonymous");
+ ok(after.isAnonymous, "Child is anonymous");
+ ok(!after._form.isXBLAnonymous, "Child is not XBL anonymous");
+ ok(!after._form.isShadowAnonymous, "Child is not shadow anonymous");
+ ok(after._form.isNativeAnonymous, "Child is native anonymous");
runNextTest();
});
addAsyncTest(function* testEmptyWithPseudo() {
- info ("Testing elements with no childrent, except for pseudos.");
+ info("Testing elements with no childrent, except for pseudos.");
- info ("Checking an element whose only child is a pseudo element");
+ info("Checking an element whose only child is a pseudo element");
let pseudo = yield gWalker.querySelector(gWalker.rootNode, "#pseudo-empty");
let children = yield gWalker.children(pseudo);
- is (pseudo.numChildren, 1, "::before/::after are is counted if there are no other children");
- is (children.nodes.length, 1, "Correct number of children");
+ is(pseudo.numChildren, 1,
+ "::before/::after are is counted if there are no other children");
+ is(children.nodes.length, 1, "Correct number of children");
let before = children.nodes[0];
- ok (before.isAnonymous, "Child is anonymous");
- ok (!before._form.isXBLAnonymous, "Child is not XBL anonymous");
- ok (!before._form.isShadowAnonymous, "Child is not shadow anonymous");
- ok (before._form.isNativeAnonymous, "Child is native anonymous");
+ ok(before.isAnonymous, "Child is anonymous");
+ ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
+ ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
+ ok(before._form.isNativeAnonymous, "Child is native anonymous");
runNextTest();
});
addAsyncTest(function* testShadowAnonymous() {
- info ("Testing shadow DOM content.");
+ info("Testing shadow DOM content.");
let shadow = yield gWalker.querySelector(gWalker.rootNode, "#shadow");
let children = yield gWalker.children(shadow);
- is (shadow.numChildren, 3, "Children of the shadow root are counted");
- is (children.nodes.length, 3, "Children returned from walker");
+ is(shadow.numChildren, 3, "Children of the shadow root are counted");
+ is(children.nodes.length, 3, "Children returned from walker");
let before = children.nodes[0];
- ok (before.isAnonymous, "Child is anonymous");
- ok (!before._form.isXBLAnonymous, "Child is not XBL anonymous");
- ok (!before._form.isShadowAnonymous, "Child is not shadow anonymous");
- ok (before._form.isNativeAnonymous, "Child is native anonymous");
+ ok(before.isAnonymous, "Child is anonymous");
+ ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
+ ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
+ ok(before._form.isNativeAnonymous, "Child is native anonymous");
// <h3>Shadow <em>DOM</em></h3>
let shadowChild1 = children.nodes[1];
- ok (shadowChild1.isAnonymous, "Child is anonymous");
- ok (!shadowChild1._form.isXBLAnonymous, "Child is not XBL anonymous");
- ok (shadowChild1._form.isShadowAnonymous, "Child is shadow anonymous");
- ok (!shadowChild1._form.isNativeAnonymous, "Child is not native anonymous");
+ ok(shadowChild1.isAnonymous, "Child is anonymous");
+ ok(!shadowChild1._form.isXBLAnonymous, "Child is not XBL anonymous");
+ ok(shadowChild1._form.isShadowAnonymous, "Child is shadow anonymous");
+ ok(!shadowChild1._form.isNativeAnonymous, "Child is not native anonymous");
let shadowSubChildren = yield gWalker.children(children.nodes[1]);
- is (shadowChild1.numChildren, 2, "Subchildren of the shadow root are counted");
- is (shadowSubChildren.nodes.length, 2, "Subchildren are returned from walker");
+ is(shadowChild1.numChildren, 2, "Subchildren of the shadow root are counted");
+ is(shadowSubChildren.nodes.length, 2, "Subchildren are returned from walker");
// <em>DOM</em>
let shadowSubChild = children.nodes[1];
- ok (shadowSubChild.isAnonymous, "Child is anonymous");
- ok (!shadowSubChild._form.isXBLAnonymous, "Child is not XBL anonymous");
- ok (shadowSubChild._form.isShadowAnonymous, "Child is shadow anonymous");
- ok (!shadowSubChild._form.isNativeAnonymous, "Child is not native anonymous");
+ ok(shadowSubChild.isAnonymous, "Child is anonymous");
+ ok(!shadowSubChild._form.isXBLAnonymous, "Child is not XBL anonymous");
+ ok(shadowSubChild._form.isShadowAnonymous, "Child is shadow anonymous");
+ ok(!shadowSubChild._form.isNativeAnonymous, "Child is not native anonymous");
// <select multiple></select>
let shadowChild2 = children.nodes[2];
- ok (shadowChild2.isAnonymous, "Child is anonymous");
- ok (!shadowChild2._form.isXBLAnonymous, "Child is not XBL anonymous");
- ok (shadowChild2._form.isShadowAnonymous, "Child is shadow anonymous");
- ok (!shadowChild2._form.isNativeAnonymous, "Child is not native anonymous");
+ ok(shadowChild2.isAnonymous, "Child is anonymous");
+ ok(!shadowChild2._form.isXBLAnonymous, "Child is not XBL anonymous");
+ ok(shadowChild2._form.isShadowAnonymous, "Child is shadow anonymous");
+ ok(!shadowChild2._form.isNativeAnonymous, "Child is not native anonymous");
runNextTest();
});
runNextTest();
};
</script>
</head>
--- a/devtools/server/tests/mochitest/test_inspector-changeattrs.html
+++ b/devtools/server/tests/mochitest/test_inspector-changeattrs.html
@@ -6,41 +6,34 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gClient = null;
-var gWalker = null;
-var checkActorIDs = [];
-
-function assertOwnership() {
- assertOwnershipTrees(gWalker);
-}
+let gInspectee = null;
+let gWalker = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(function testChangeAttrs() {
let attrNode = gInspectee.querySelector("#a");
let attrFront;
@@ -51,44 +44,46 @@ addTest(function testChangeAttrs() {
let list = attrFront.startModifyingAttributes();
list.setAttribute("data-newattr", "newvalue");
list.setAttribute("data-newattr2", "newvalue");
return list.apply();
}).then(() => {
// We're only going to test that the change hit the document.
// There are other tests that make sure changes are propagated
// to the client.
- is(attrNode.getAttribute("data-newattr"), "newvalue", "Node should have the first new attribute");
- is(attrNode.getAttribute("data-newattr2"), "newvalue", "Node should have the second new attribute.");
+ is(attrNode.getAttribute("data-newattr"), "newvalue",
+ "Node should have the first new attribute");
+ is(attrNode.getAttribute("data-newattr2"), "newvalue",
+ "Node should have the second new attribute.");
}).then(() => {
// Change an attribute.
let list = attrFront.startModifyingAttributes();
list.setAttribute("data-newattr", "changedvalue");
return list.apply();
}).then(() => {
- is(attrNode.getAttribute("data-newattr"), "changedvalue", "Node should have the changed first value.");
- is(attrNode.getAttribute("data-newattr2"), "newvalue", "Second value should remain unchanged.");
+ is(attrNode.getAttribute("data-newattr"), "changedvalue",
+ "Node should have the changed first value.");
+ is(attrNode.getAttribute("data-newattr2"), "newvalue",
+ "Second value should remain unchanged.");
}).then(() => {
let list = attrFront.startModifyingAttributes();
list.removeAttribute("data-newattr2");
return list.apply();
}).then(() => {
- is(attrNode.getAttribute("data-newattr"), "changedvalue", "Node should have the changed first value.");
+ is(attrNode.getAttribute("data-newattr"), "changedvalue",
+ "Node should have the changed first value.");
ok(!attrNode.hasAttribute("data-newattr2"), "Second value should be removed.");
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gInspectee;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-changevalue.html
+++ b/devtools/server/tests/mochitest/test_inspector-changevalue.html
@@ -6,41 +6,36 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
+"use strict";
+
const Ci = Components.interfaces;
-const inspector = require("devtools/shared/fronts/inspector");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gClient = null;
-var gWalker = null;
-
-function assertOwnership() {
- assertOwnershipTrees(gWalker);
-}
+let gInspectee = null;
+let gWalker = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(function testChangeValue() {
let contentNode = gInspectee.querySelector("#a").firstChild;
let nodeFront;
@@ -55,23 +50,20 @@ addTest(function testChangeValue() {
// We're only going to test that the change hit the document.
// There are other tests that make sure changes are propagated
// to the client.
is(contentNode.nodeValue, "newvalue", "Node should have a new value.");
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gInspectee;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
+++ b/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
@@ -6,230 +6,231 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 1121528</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker, gDoc;
+let gWalker = null;
+let gDoc = null;
-addAsyncTest(function*() {
+addAsyncTest(function* () {
let url = document.getElementById("inspectorContent").href;
let def = promise.defer();
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
def.resolve({client, tab, doc});
});
let {client, tab, doc} = yield def.promise;
gDoc = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
gWalker = yield inspector.getWalker();
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.parents(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.parents(nodeFront);
yield newRoot;
ok(true, "The call to walker.parents() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.children(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "body");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.children(nodeFront);
yield newRoot;
ok(true, "The call to walker.children() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.siblings(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.siblings(nodeFront);
yield newRoot;
ok(true, "The call to walker.siblings() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.nextSibling(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.nextSibling(nodeFront);
yield newRoot;
ok(true, "The call to walker.nextSibling() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.previousSibling(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.previousSibling(nodeFront);
yield newRoot;
ok(true, "The call to walker.previousSibling() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.addPseudoClassLock(nodeFront) before the load completes " +
"shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.addPseudoClassLock(nodeFront, ":hover");
yield newRoot;
ok(true, "The call to walker.addPseudoClassLock() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.removePseudoClassLock(nodeFront) before the load completes " +
"shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.removePseudoClassLock(nodeFront, ":hover");
yield newRoot;
ok(true, "The call to walker.removePseudoClassLock() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.clearPseudoClassLocks(nodeFront) before the load completes " +
"shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.clearPseudoClassLocks(nodeFront);
yield newRoot;
ok(true, "The call to walker.clearPseudoClassLocks() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.innerHTML(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.innerHTML(nodeFront);
yield newRoot;
ok(true, "The call to walker.innerHTML() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.setInnerHTML(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.setInnerHTML(nodeFront, "<span>innerHTML changed</span>");
yield newRoot;
ok(true, "The call to walker.setInnerHTML() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.outerHTML(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.outerHTML(nodeFront);
yield newRoot;
ok(true, "The call to walker.outerHTML() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.setOuterHTML(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.setOuterHTML(nodeFront, "<h1><span>innerHTML changed</span></h1>");
yield newRoot;
ok(true, "The call to walker.setOuterHTML() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.insertAdjacentHTML(nodeFront) before the load completes shouldn't " +
"fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.insertAdjacentHTML(nodeFront, "afterEnd",
"<span>new adjacent HTML</span>");
yield newRoot;
ok(true, "The call to walker.insertAdjacentHTML() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.removeNode(nodeFront) before the load completes should throw");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
let hasThrown = false;
try {
@@ -238,17 +239,17 @@ addAsyncTest(function*() {
hasThrown = true;
}
yield newRoot;
ok(hasThrown, "The call to walker.removeNode() threw");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.removeNodes([nodeFront]) before the load completes should throw");
let nodeFront1 = yield gWalker.querySelector(gWalker.rootNode, "h1");
let nodeFront2 = yield gWalker.querySelector(gWalker.rootNode, "#longstring");
let nodeFront3 = yield gWalker.querySelector(gWalker.rootNode, "#shortstring");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
@@ -259,121 +260,122 @@ addAsyncTest(function*() {
hasThrown = true;
}
yield newRoot;
ok(hasThrown, "The call to walker.removeNodes() threw");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.insertBefore(nodeFront, parent, null) before the load completes " +
"shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newParentFront = yield gWalker.querySelector(gWalker.rootNode, "#longlist");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.insertBefore(nodeFront, newParentFront);
yield newRoot;
ok(true, "The call to walker.insertBefore() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.insertBefore(nodeFront, parent, sibling) before the load completes " +
"shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newParentFront = yield gWalker.querySelector(gWalker.rootNode, "#longlist");
let siblingFront = yield gWalker.querySelector(gWalker.rootNode, "#b");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.insertBefore(nodeFront, newParentFront, siblingFront);
yield newRoot;
ok(true, "The call to walker.insertBefore() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.editTagName(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.editTagName(nodeFront, "h2");
yield newRoot;
ok(true, "The call to walker.editTagName() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.hideNode(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.hideNode(nodeFront);
yield newRoot;
ok(true, "The call to walker.hideNode() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.unhideNode(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.unhideNode(nodeFront);
yield newRoot;
ok(true, "The call to walker.unhideNode() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.releaseNode(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.releaseNode(nodeFront);
yield newRoot;
ok(true, "The call to walker.releaseNode() didn't fail");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " +
"walker.querySelector(nodeFront) before the load completes shouldn't fail");
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, "body");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
yield gWalker.querySelector(nodeFront, "h1");
yield newRoot;
ok(true, "The call to walker.querySelector() didn't fail");
runNextTest();
});
addTest(function cleanup() {
- gWalker = gDoc = null;
+ gWalker = null;
+ gDoc = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=932937">Mozilla Bug 1121528</a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
--- a/devtools/server/tests/mochitest/test_inspector-duplicate-node.html
+++ b/devtools/server/tests/mochitest/test_inspector-duplicate-node.html
@@ -6,40 +6,32 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 1208864</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gClient = null;
-var gWalker = null;
-
-function assertOwnership() {
- assertOwnershipTrees(gWalker);
-}
+let gWalker = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
- gInspectee = doc;
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(Task.async(function* testDuplicateNode() {
let className = ".node-to-duplicate";
let matches = yield gWalker.querySelectorAll(gWalker.rootNode, className);
@@ -50,19 +42,17 @@ addTest(Task.async(function* testDuplica
matches = yield gWalker.querySelectorAll(gWalker.rootNode, className);
is(matches.length, 2, "The node should now be duplicated.");
runNextTest();
}));
addTest(function cleanup() {
- delete gWalker;
- delete gInspectee;
- delete gClient;
+ gWalker = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1208864">Mozilla Bug 1208864</a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
--- a/devtools/server/tests/mochitest/test_inspector-hide.html
+++ b/devtools/server/tests/mochitest/test_inspector-hide.html
@@ -6,35 +6,34 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gClient = null;
+let gWalker = null;
+let gInspectee = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(function testRearrange() {
let listFront = null;
let listNode = gInspectee.querySelector("#longlist");
@@ -51,18 +50,18 @@ addTest(function testRearrange() {
return gWalker.unhideNode(listFront);
}).then(() => {
let computed = gInspectee.defaultView.getComputedStyle(listNode);
ok(computed.visibility, "visible", "Node should be visible again.");
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_inspector-insert.html
+++ b/devtools/server/tests/mochitest/test_inspector-insert.html
@@ -6,55 +6,54 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
+"use strict";
+
const inspector = require("devtools/server/actors/inspector");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gClient = null;
-
-function assertOwnership() {
- return assertOwnershipTrees(gWalker);
-}
+let gWalker = null;
+let gInspectee = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
- let inspector = InspectorFront(client, tab);
- promiseDone(inspector.getWalker().then(walker => {
+ let inspectorFront = InspectorFront(client, tab);
+ promiseDone(inspectorFront.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addAsyncTest(function* testRearrange() {
let longlist = yield gWalker.querySelector(gWalker.rootNode, "#longlist");
let children = yield gWalker.children(longlist);
let nodeA = children.nodes[0];
is(nodeA.id, "a", "Got the expected node.");
// Move nodeA to the end of the list.
yield gWalker.insertBefore(nodeA, longlist, null);
- ok(!gInspectee.querySelector("#a").nextSibling, "a should now be at the end of the list.");
+ ok(!gInspectee.querySelector("#a").nextSibling,
+ "a should now be at the end of the list.");
children = yield gWalker.children(longlist);
- is(nodeA, children.nodes[children.nodes.length - 1], "a should now be the last returned child.");
+ is(nodeA, children.nodes[children.nodes.length - 1],
+ "a should now be the last returned child.");
// Now move it to the middle of the list.
let nextNode = children.nodes[13];
yield gWalker.insertBefore(nodeA, longlist, nextNode);
let sibling =
new inspector._documentWalker(gInspectee.querySelector("#a"), window).nextSibling();
is(sibling, nextNode.rawNode(), "Node should match the expected next node.");
children = yield gWalker.children(longlist);
@@ -94,18 +93,18 @@ addAsyncTest(function* testInsertInvalid
yield gWalker.insertBefore(nodeA, longlist);
ok(!hasMutated, "hasn't mutated after inserting with null sibling again");
observer.disconnect();
runNextTest();
});
addTest(function cleanup() {
- delete gWalker;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_inspector-mutations-attr.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-attr.html
@@ -6,38 +6,36 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gWalker = null;
-var gClient = null;
-var attrNode;
-var attrFront;
+let gInspectee = null;
+let gWalker = null;
+let attrNode;
+let attrFront;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(setupAttrTest);
addTest(testAddAttribute);
addTest(testChangeAttribute);
@@ -45,24 +43,24 @@ addTest(testRemoveAttribute);
addTest(testQueuedMutations);
addTest(setupFrameAttrTest);
addTest(testAddAttribute);
addTest(testChangeAttribute);
addTest(testRemoveAttribute);
addTest(testQueuedMutations);
function setupAttrTest() {
- attrNode = gInspectee.querySelector("#a")
+ attrNode = gInspectee.querySelector("#a");
promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(node => {
attrFront = node;
}).then(runNextTest));
}
function setupFrameAttrTest() {
- let frame = gInspectee.querySelector('#childFrame');
+ let frame = gInspectee.querySelector("#childFrame");
attrNode = frame.contentDocument.querySelector("#a");
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
return gWalker.children(childFrame);
}).then(children => {
let nodes = children.nodes;
ok(nodes.length, 1, "There should be only one child of the iframe");
is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node");
@@ -72,91 +70,98 @@ function setupFrameAttrTest() {
}).then(runNextTest));
}
function testAddAttribute() {
attrNode.setAttribute("data-newattr", "newvalue");
attrNode.setAttribute("data-newattr2", "newvalue");
gWalker.once("mutations", () => {
is(attrFront.attributes.length, 3, "Should have id and two new attributes.");
- is(attrFront.getAttribute("data-newattr"), "newvalue", "Node front should have the first new attribute");
- is(attrFront.getAttribute("data-newattr2"), "newvalue", "Node front should have the second new attribute.");
+ is(attrFront.getAttribute("data-newattr"), "newvalue",
+ "Node front should have the first new attribute");
+ is(attrFront.getAttribute("data-newattr2"), "newvalue",
+ "Node front should have the second new attribute.");
runNextTest();
});
}
function testChangeAttribute() {
attrNode.setAttribute("data-newattr", "changedvalue1");
attrNode.setAttribute("data-newattr", "changedvalue2");
attrNode.setAttribute("data-newattr", "changedvalue3");
gWalker.once("mutations", mutations => {
- is(mutations.length, 1, "Only one mutation is sent for multiple queued attribute changes");
+ is(mutations.length, 1,
+ "Only one mutation is sent for multiple queued attribute changes");
is(attrFront.attributes.length, 3, "Should have id and two new attributes.");
- is(attrFront.getAttribute("data-newattr"), "changedvalue3", "Node front should have the changed first value");
- is(attrFront.getAttribute("data-newattr2"), "newvalue", "Second value should remain unchanged.");
+ is(attrFront.getAttribute("data-newattr"), "changedvalue3",
+ "Node front should have the changed first value");
+ is(attrFront.getAttribute("data-newattr2"), "newvalue",
+ "Second value should remain unchanged.");
runNextTest();
});
}
function testRemoveAttribute() {
attrNode.removeAttribute("data-newattr2");
gWalker.once("mutations", () => {
is(attrFront.attributes.length, 2, "Should have id and one remaining attribute.");
- is(attrFront.getAttribute("data-newattr"), "changedvalue3", "Node front should still have the first value");
+ is(attrFront.getAttribute("data-newattr"), "changedvalue3",
+ "Node front should still have the first value");
ok(!attrFront.hasAttribute("data-newattr2"), "Second value should be removed.");
runNextTest();
- })
+ });
}
function testQueuedMutations() {
// All modifications to each attribute should be queued in one mutation event.
attrNode.removeAttribute("data-newattr");
attrNode.setAttribute("data-newattr", "1");
attrNode.removeAttribute("data-newattr");
attrNode.setAttribute("data-newattr", "2");
attrNode.removeAttribute("data-newattr");
- for (var i = 0; i <= 1000; i++) {
+ for (let i = 0; i <= 1000; i++) {
attrNode.setAttribute("data-newattr2", i);
}
attrNode.removeAttribute("data-newattr3");
attrNode.setAttribute("data-newattr3", "1");
attrNode.removeAttribute("data-newattr3");
attrNode.setAttribute("data-newattr3", "2");
attrNode.removeAttribute("data-newattr3");
attrNode.setAttribute("data-newattr3", "3");
// This shouldn't be added in the attribute set, since it's a new
// attribute that's been added and removed.
attrNode.setAttribute("data-newattr4", "4");
attrNode.removeAttribute("data-newattr4");
gWalker.once("mutations", mutations => {
- is(mutations.length, 4, "Only one mutation each is sent for multiple queued attribute changes");
- is(attrFront.attributes.length, 3, "Should have id, data-newattr2, and data-newattr3.");
+ is(mutations.length, 4,
+ "Only one mutation each is sent for multiple queued attribute changes");
+ is(attrFront.attributes.length, 3,
+ "Should have id, data-newattr2, and data-newattr3.");
- is(attrFront.getAttribute("data-newattr2"), "1000", "Node front should still have the correct value");
- is(attrFront.getAttribute("data-newattr3"), "3", "Node front should still have the correct value");
+ is(attrFront.getAttribute("data-newattr2"), "1000",
+ "Node front should still have the correct value");
+ is(attrFront.getAttribute("data-newattr3"), "3",
+ "Node front should still have the correct value");
ok(!attrFront.hasAttribute("data-newattr"), "Attribute value should be removed.");
ok(!attrFront.hasAttribute("data-newattr4"), "Attribute value should be removed.");
runNextTest();
- })
+ });
}
addTest(function cleanup() {
- delete gInspectee;
- delete gWalker;
- delete gClient;
+ gInspectee = null;
+ gWalker = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-mutations-childlist.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-childlist.html
@@ -6,53 +6,50 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gWalker = null;
-var gClient = null;
-var gCleanupConnection = null;
+let gInspectee = null;
+let gWalker = null;
+let gCleanupConnection = null;
function setup(callback) {
let url = document.getElementById("inspectorContent").href;
- gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
+ gCleanupConnection = attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
- gClient = client;
gWalker = walker;
}).then(callback));
});
}
function teardown() {
gWalker = null;
- gClient = null;
gInspectee = null;
if (gCleanupConnection) {
gCleanupConnection();
gCleanupConnection = null;
}
}
function assertOwnership() {
- let num = assertOwnershipTrees(gWalker);
+ return assertOwnershipTrees(gWalker);
}
function setParent(nodeSelector, newParentSelector) {
let node = gInspectee.querySelector(nodeSelector);
if (newParentSelector) {
let newParent = gInspectee.querySelector(newParentSelector);
newParent.appendChild(node);
} else {
@@ -78,111 +75,113 @@ function doMoves(moves) {
/**
* Test a set of tree rearrangements and make sure they cause the expected changes.
*/
var gDummySerial = 0;
function mutationTest(testSpec) {
- return function() {
+ return function () {
setup(() => {
promiseDone(loadSelectors(testSpec.load || ["html"]).then(() => {
gWalker.autoCleanup = !!testSpec.autoCleanup;
if (testSpec.preCheck) {
testSpec.preCheck();
}
doMoves(testSpec.moves || []);
// Some of these moves will trigger no mutation events,
// so do a dummy change to the root node to trigger
// a mutation event anyway.
gInspectee.documentElement.setAttribute("data-dummy", gDummySerial++);
gWalker.once("mutations", (mutations) => {
// Filter out our dummy mutation.
+ // eslint-disable-next-line max-nested-callbacks
mutations = mutations.filter(change => {
if (change.type == "attributes" &&
change.attributeName == "data-dummy") {
return false;
}
return true;
});
assertOwnership();
if (testSpec.postCheck) {
testSpec.postCheck(mutations);
}
teardown();
runNextTest();
});
}));
- })
- }
+ });
+ };
}
// Verify that our dummy mutation works.
addTest(mutationTest({
autoCleanup: false,
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 0, "Dummy mutation is filtered out.");
}
}));
// Test a simple move to a different location in the sibling list for the same
// parent.
addTest(mutationTest({
autoCleanup: false,
load: ["#longlist div"],
moves: [
["#a", "#longlist"]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
let remove = mutations[0];
- is(remove.type, "childList", "First mutation should be a childList.")
- ok(remove.removed.length > 0, "First mutation should be a removal.")
+ is(remove.type, "childList", "First mutation should be a childList.");
+ ok(remove.removed.length > 0, "First mutation should be a removal.");
let add = mutations[1];
- is(add.type, "childList", "Second mutation should be a childList removal.")
- ok(add.added.length > 0, "Second mutation should be an addition.")
+ is(add.type, "childList", "Second mutation should be a childList removal.");
+ ok(add.added.length > 0, "Second mutation should be an addition.");
let a = add.added[0];
is(a.id, "a", "Added node should be #a");
is(a.parentNode(), remove.target, "Should still be a child of longlist.");
- is(remove.target, add.target, "First and second mutations should be against the same node.");
+ is(remove.target, add.target,
+ "First and second mutations should be against the same node.");
}
}));
// Test a move to another location that is within our ownership tree.
addTest(mutationTest({
autoCleanup: false,
load: ["#longlist div", "#longlist-sibling"],
moves: [
["#a", "#longlist-sibling"]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
let remove = mutations[0];
- is(remove.type, "childList", "First mutation should be a childList.")
- ok(remove.removed.length > 0, "First mutation should be a removal.")
+ is(remove.type, "childList", "First mutation should be a childList.");
+ ok(remove.removed.length > 0, "First mutation should be a removal.");
let add = mutations[1];
- is(add.type, "childList", "Second mutation should be a childList removal.")
- ok(add.added.length > 0, "Second mutation should be an addition.")
+ is(add.type, "childList", "Second mutation should be a childList removal.");
+ ok(add.added.length > 0, "Second mutation should be an addition.");
let a = add.added[0];
is(a.id, "a", "Added node should be #a");
is(a.parentNode(), add.target, "Should still be a child of longlist.");
is(add.target.id, "longlist-sibling", "long-sibling should be the target.");
}
}));
// Move an unseen node with a seen parent into our ownership tree - should generate a
// childList pair with no adds or removes.
addTest(mutationTest({
autoCleanup: false,
load: ["#longlist"],
moves: [
["#longlist-sibling", "#longlist"]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 2, "Should generate two mutations");
is(mutations[0].type, "childList", "Should be childList mutations.");
is(mutations[0].added.length, 0, "Should have no adds.");
is(mutations[0].removed.length, 0, "Should have no removes.");
is(mutations[1].type, "childList", "Should be childList mutations.");
is(mutations[1].added.length, 0, "Should have no adds.");
is(mutations[1].removed.length, 0, "Should have no removes.");
}
@@ -191,115 +190,114 @@ addTest(mutationTest({
// Move an unseen node with an unseen parent into our ownership tree. Should only
// generate one childList mutation with no adds or removes.
addTest(mutationTest({
autoCleanup: false,
load: ["#longlist div"],
moves: [
["#longlist-sibling-firstchild", "#longlist"]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 1, "Should generate two mutations");
is(mutations[0].type, "childList", "Should be childList mutations.");
is(mutations[0].added.length, 0, "Should have no adds.");
is(mutations[0].removed.length, 0, "Should have no removes.");
}
}));
// Move a node between unseen nodes, should generate no mutations.
addTest(mutationTest({
autoCleanup: false,
load: ["html"],
moves: [
["#longlist-sibling", "#longlist"]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 0, "Should generate no mutations.");
}
}));
// Orphan a node and don't clean it up
addTest(mutationTest({
autoCleanup: false,
load: ["#longlist div"],
moves: [
["#longlist", null]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0];
is(change.type, "childList", "Should be a childList.");
is(change.removed.length, 1, "Should have removed a child.");
let ownership = clientOwnershipTree(gWalker);
is(ownership.orphaned.length, 1, "Should have one orphaned subtree.");
- is(ownershipTreeSize(ownership.orphaned[0]), 1 + 26 + 26, "Should have orphaned longlist, and 26 children, and 26 singleTextChilds");
+ is(ownershipTreeSize(ownership.orphaned[0]), 1 + 26 + 26,
+ "Should have orphaned longlist, and 26 children, and 26 singleTextChilds");
}
}));
// Orphan a node, and do clean it up.
addTest(mutationTest({
autoCleanup: true,
load: ["#longlist div"],
moves: [
["#longlist", null]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0];
is(change.type, "childList", "Should be a childList.");
is(change.removed.length, 1, "Should have removed a child.");
let ownership = clientOwnershipTree(gWalker);
is(ownership.orphaned.length, 0, "Should have no orphaned subtrees.");
}
}));
// Orphan a node by moving it into the tree but out of our visible subtree.
addTest(mutationTest({
autoCleanup: false,
load: ["#longlist div"],
moves: [
["#longlist", "#longlist-sibling"]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0];
is(change.type, "childList", "Should be a childList.");
is(change.removed.length, 1, "Should have removed a child.");
let ownership = clientOwnershipTree(gWalker);
is(ownership.orphaned.length, 1, "Should have one orphaned subtree.");
- is(ownershipTreeSize(ownership.orphaned[0]), 1 + 26 + 26, "Should have orphaned longlist, 26 children, and 26 singleTextChilds.");
+ is(ownershipTreeSize(ownership.orphaned[0]), 1 + 26 + 26,
+ "Should have orphaned longlist, 26 children, and 26 singleTextChilds.");
}
}));
-// Orphan a node by moving it into the tree but out of our visible subtree, and clean it up.
+// Orphan a node by moving it into the tree but out of our visible subtree,
+// and clean it up.
addTest(mutationTest({
autoCleanup: true,
load: ["#longlist div"],
moves: [
["#longlist", "#longlist-sibling"]
],
- postCheck: function(mutations) {
+ postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0];
is(change.type, "childList", "Should be a childList.");
is(change.removed.length, 1, "Should have removed a child.");
let ownership = clientOwnershipTree(gWalker);
is(ownership.orphaned.length, 0, "Should have no orphaned subtrees.");
}
}));
-
addTest(function cleanup() {
- delete gInspectee;
- delete gWalker;
- delete gClient;
+ gInspectee = null;
+ gWalker = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-mutations-events.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-events.html
@@ -5,19 +5,19 @@ https://bugzilla.mozilla.org/show_bug.cg
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1157469</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
+"use strict";
-window.onload = function() {
-
+window.onload = function () {
const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const {InspectorFront} = require("devtools/shared/fronts/inspector");
SimpleTest.waitForExplicitFinish();
let inspectee = null;
let inspector = null;
@@ -25,36 +25,36 @@ window.onload = function() {
let eventListener1 = function () {};
let eventListener2 = function () {};
let eventNode1;
let eventNode2;
let eventFront1;
let eventFront2;
addAsyncTest(function* setup() {
- info ("Setting up inspector and walker actors.");
+ info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href;
yield new Promise(resolve => {
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
inspectee = doc;
inspector = InspectorFront(client, tab);
resolve();
});
});
walker = yield inspector.getWalker();
ok(walker, "getWalker() should return an actor.");
runNextTest();
});
addAsyncTest(function* setupEventTest() {
- eventNode1 = inspectee.querySelector("#a")
- eventNode2 = inspectee.querySelector("#b")
+ eventNode1 = inspectee.querySelector("#a");
+ eventNode2 = inspectee.querySelector("#b");
eventFront1 = yield walker.querySelector(walker.rootNode, "#a");
eventFront2 = yield walker.querySelector(walker.rootNode, "#b");
runNextTest();
});
addAsyncTest(function* testChangeEventListenerOnSingleNode() {
@@ -62,40 +62,44 @@ window.onload = function() {
info("add event listener on a single node");
eventNode1.addEventListener("click", eventListener1);
let mutations = yield waitForMutations();
is(mutations.length, 1, "one mutation expected");
is(mutations[0].target, eventFront1, "mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events");
- is(mutations[0].hasEventListeners, true, "mutation target should have event listeners");
+ is(mutations[0].hasEventListeners, true,
+ "mutation target should have event listeners");
is(eventFront1.hasEventListeners, true, "eventFront1 should have event listeners");
info("remove event listener on a single node");
eventNode1.removeEventListener("click", eventListener1);
mutations = yield waitForMutations();
is(mutations.length, 1, "one mutation expected");
is(mutations[0].target, eventFront1, "mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events");
- is(mutations[0].hasEventListeners, false, "mutation target should have no event listeners");
- is(eventFront1.hasEventListeners, false, "eventFront1 should have no event listeners");
+ is(mutations[0].hasEventListeners, false,
+ "mutation target should have no event listeners");
+ is(eventFront1.hasEventListeners, false,
+ "eventFront1 should have no event listeners");
- info("perform several event listener changes on a single node")
+ info("perform several event listener changes on a single node");
eventNode1.addEventListener("click", eventListener1);
eventNode1.addEventListener("click", eventListener2);
eventNode1.removeEventListener("click", eventListener1);
eventNode1.removeEventListener("click", eventListener2);
mutations = yield waitForMutations();
is(mutations.length, 1, "one mutation expected");
is(mutations[0].target, eventFront1, "mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events");
- is(mutations[0].hasEventListeners, false, "no event listener expected on mutation target");
+ is(mutations[0].hasEventListeners, false,
+ "no event listener expected on mutation target");
is(eventFront1.hasEventListeners, false, "no event listener expected on node");
runNextTest();
});
addAsyncTest(function* testChangeEventsOnSeveralNodes() {
checkNodesHaveNoEventListener();
@@ -103,76 +107,83 @@ window.onload = function() {
eventNode1.addEventListener("click", eventListener1);
eventNode2.addEventListener("click", eventListener2);
let mutations = yield waitForMutations();
is(mutations.length, 2, "two mutations expected, one for each modified node");
// first mutation
is(mutations[0].target, eventFront1, "first mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events");
- is(mutations[0].hasEventListeners, true, "mutation target should have event listeners");
+ is(mutations[0].hasEventListeners, true,
+ "mutation target should have event listeners");
is(eventFront1.hasEventListeners, true, "eventFront1 should have event listeners");
// second mutation
is(mutations[1].target, eventFront2, "second mutation targets eventFront2");
is(mutations[1].type, "events", "mutation type is events");
- is(mutations[1].hasEventListeners, true, "mutation target should have event listeners");
+ is(mutations[1].hasEventListeners, true,
+ "mutation target should have event listeners");
is(eventFront2.hasEventListeners, true, "eventFront1 should have event listeners");
info("remove event listeners on both nodes");
eventNode1.removeEventListener("click", eventListener1);
eventNode2.removeEventListener("click", eventListener2);
mutations = yield waitForMutations();
is(mutations.length, 2, "one mutation registered for event listener change");
// first mutation
is(mutations[0].target, eventFront1, "first mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events");
- is(mutations[0].hasEventListeners, false, "mutation target should have no event listeners");
- is(eventFront1.hasEventListeners, false, "eventFront2 should have no event listeners");
+ is(mutations[0].hasEventListeners, false,
+ "mutation target should have no event listeners");
+ is(eventFront1.hasEventListeners, false,
+ "eventFront2 should have no event listeners");
// second mutation
is(mutations[1].target, eventFront2, "second mutation targets eventFront2");
is(mutations[1].type, "events", "mutation type is events");
- is(mutations[1].hasEventListeners, false, "mutation target should have no event listeners");
- is(eventFront2.hasEventListeners, false, "eventFront2 should have no event listeners");
+ is(mutations[1].hasEventListeners, false,
+ "mutation target should have no event listeners");
+ is(eventFront2.hasEventListeners, false,
+ "eventFront2 should have no event listeners");
runNextTest();
});
addAsyncTest(function* testRemoveMissingEvent() {
checkNodesHaveNoEventListener();
info("try to remove an event listener not previously added");
eventNode1.removeEventListener("click", eventListener1);
- info("set any attribute on the node to trigger a mutation")
+ info("set any attribute on the node to trigger a mutation");
eventNode1.setAttribute("data-attr", "somevalue");
let mutations = yield waitForMutations();
is(mutations.length, 1, "expect only one mutation");
isnot(mutations.type, "events", "mutation type should not be events");
runNextTest();
});
function checkNodesHaveNoEventListener() {
- is(eventFront1.hasEventListeners, false, "eventFront1 hasEventListeners should be false");
- is(eventFront2.hasEventListeners, false, "eventFront2 hasEventListeners should be false");
- };
+ is(eventFront1.hasEventListeners, false,
+ "eventFront1 hasEventListeners should be false");
+ is(eventFront2.hasEventListeners, false,
+ "eventFront2 hasEventListeners should be false");
+ }
function waitForMutations() {
return new Promise(resolve => {
walker.once("mutations", mutations => {
resolve(mutations);
});
});
}
runNextTest();
-}
-
+};
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1157469">Mozilla Bug 1157469</a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
@@ -6,62 +6,59 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gWalker = null;
-var gClient = null;
-var gChildFrame = null;
-var gChildDocument = null;
-var gCleanupConnection = null;
+let gInspectee = null;
+let gWalker = null;
+let gClient = null;
+let gCleanupConnection = null;
function setup(callback) {
let url = document.getElementById("inspectorContent").href;
- gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
+ gCleanupConnection = attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
gClient = client;
gWalker = walker;
}).then(callback));
});
}
function teardown() {
gWalker = null;
gClient = null;
gInspectee = null;
- gChildFrame = null;
if (gCleanupConnection) {
gCleanupConnection();
gCleanupConnection = null;
}
}
function assertOwnership() {
return assertOwnershipTrees(gWalker);
}
function loadChildSelector(selector) {
return gWalker.querySelector(gWalker.rootNode, "#childFrame").then(frame => {
- ok(frame.numChildren > 0, "Child frame should consider its loaded document as a child.");
- gChildFrame = frame;
+ ok(frame.numChildren > 0,
+ "Child frame should consider its loaded document as a child.");
return gWalker.children(frame);
}).then(children => {
return gWalker.querySelectorAll(children.nodes[0], selector);
}).then(nodeList => {
return nodeList.items();
});
}
@@ -71,17 +68,16 @@ function getUnloadedDoc(mutations) {
return change.target;
}
}
return null;
}
addTest(function loadNewChild() {
setup(() => {
- let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame");
childFrame.src = "data:text/html,<html>new child</html>";
return waitForMutation(gWalker, isChildList);
}).then(mutations => {
let unloaded = getUnloadedDoc(mutations);
mutations = assertSrcChange(mutations);
@@ -97,17 +93,16 @@ addTest(function loadNewChild() {
}).then(() => {
teardown();
}).then(runNextTest));
});
});
addTest(function loadNewChildTwice() {
setup(() => {
- let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame");
childFrame.src = "data:text/html,<html>new child</html>";
return waitForMutation(gWalker, isChildList);
}).then(mutations => {
// The first load went through as expected (as tested in loadNewChild)
// Now change the source again, but this time we *don't* expect
@@ -125,20 +120,18 @@ addTest(function loadNewChildTwice() {
assertOwnership();
}).then(() => {
teardown();
}).then(runNextTest));
});
});
-
addTest(function loadNewChildTwiceAndCareAboutIt() {
setup(() => {
- let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame");
childFrame.src = "data:text/html,<html>new child</html>";
return waitForMutation(gWalker, isChildList);
}).then(mutations => {
// Read the new child
return loadChildSelector("#longlist div");
@@ -163,27 +156,27 @@ addTest(function loadNewChildTwiceAndCar
}).then(() => {
teardown();
}).then(runNextTest));
});
});
addTest(function testBack() {
setup(() => {
- let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame");
childFrame.src = "data:text/html,<html>new child</html>";
return waitForMutation(gWalker, isChildList);
}).then(mutations => {
// Read the new child
return loadChildSelector("#longlist div");
}).then(() => {
- // Now use history.back to change the source, and expect the same results as loadNewChild.
+ // Now use history.back to change the source,
+ // and expect the same results as loadNewChild.
let childFrame = gInspectee.querySelector("#childFrame");
childFrame.contentWindow.history.back();
return waitForMutation(gWalker, isChildList);
}).then(mutations => {
let unloaded = getUnloadedDoc(mutations);
mutations = assertSrcChange(mutations);
mutations = assertUnload(mutations);
mutations = assertFrameLoad(mutations);
--- a/devtools/server/tests/mochitest/test_inspector-mutations-value.html
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-value.html
@@ -6,49 +6,48 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
+"use strict";
+
const inspector = require("devtools/server/actors/inspector");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
const testSummaryLength = 10;
inspector.setValueSummaryLength(testSummaryLength);
-SimpleTest.registerCleanupFunction(function() {
+SimpleTest.registerCleanupFunction(function () {
inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH);
});
-var gInspectee = null;
-var gWalker = null;
-var gClient = null;
-var valueNode;
+let gInspectee = null;
+let gWalker = null;
+let valueNode;
var valueFront;
var longStringFront;
var longString = "stringstringstringstringstringstringstringstringstringstringstring";
-var truncatedLongString = longString.substring(0, testSummaryLength);
var shortString = "str";
var shortString2 = "str2";
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
- let inspector = InspectorFront(client, tab);
- promiseDone(inspector.getWalker().then(walker => {
+ let inspectorFront = InspectorFront(client, tab);
+ promiseDone(inspectorFront.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(setupValueTest);
addTest(testKeepLongValue);
addTest(testSetShortValue);
@@ -66,17 +65,17 @@ function setupValueTest() {
longStringFront = node;
return gWalker.children(node);
}).then(children => {
valueFront = children.nodes[0];
}).then(runNextTest));
}
function setupFrameValueTest() {
- let frame = gInspectee.querySelector('#childFrame');
+ let frame = gInspectee.querySelector("#childFrame");
valueNode = frame.contentDocument.querySelector("#longstring").firstChild;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
return gWalker.children(childFrame);
}).then(children => {
let nodes = children.nodes;
is(nodes.length, 1, "There should be only one child of the iframe");
is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node");
@@ -89,17 +88,17 @@ function setupFrameValueTest() {
}).then(runNextTest));
}
function checkNodeFrontValue(front, expectedValue) {
return front.getNodeValue().then(longstring => {
return longstring.string();
}).then(str => {
is(str, expectedValue, "Node value is as expected");
- })
+ });
}
function testKeepLongValue() {
// After first setup we should have a long string in the node
ok(!longStringFront.inlineTextChild, "Text node is too long to be inlined.");
valueNode.nodeValue = longString;
gWalker.once("mutations", (changes) => {
@@ -142,19 +141,18 @@ function testSetLongValue() {
ok(!longStringFront.inlineTextChild, "Text node is too long to be inlined.");
ok(changes.some(change => change.type === "inlineTextChild"),
"An inlineTextChild mutation was fired.");
checkNodeFrontValue(valueFront, longString).then(runNextTest);
});
}
addTest(function cleanup() {
- delete gInspectee;
- delete gWalker;
- delete gClient;
+ gInspectee = null;
+ gWalker = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_inspector-pick-color.html
+++ b/devtools/server/tests/mochitest/test_inspector-pick-color.html
@@ -1,101 +1,99 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that the inspector actor has the pickColorFromPage and cancelPickColorFromPage
-methods and that when a color is picked the color-picked event is emitted and that when
-the eyedropper is dimissed, the color-pick-canceled event is emitted.
-https://bugzilla.mozilla.org/show_bug.cgi?id=1262439
--->
-<head>
- <meta charset="utf-8">
- <title>Test for Bug 1262439</title>
- <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
- <script type="application/javascript" src="inspector-helpers.js"></script>
- <script type="application/javascript">
-window.onload = function() {
- const Cu = Components.utils;
- Cu.import("resource://devtools/shared/Loader.jsm");
- const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
- const {InspectorFront} = devtools.require("devtools/shared/fronts/inspector");
- const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
-
- SimpleTest.waitForExplicitFinish();
-
- let win = null;
- let inspector = null;
-
- addAsyncTest(function*() {
- info("Setting up inspector actor");
-
- let url = document.getElementById("inspectorContent").href;
-
- yield new Promise(resolve => {
- attachURL(url, function(err, client, tab, doc) {
- win = doc.defaultView;
- inspector = InspectorFront(client, tab);
- resolve();
- });
- });
-
- runNextTest();
- });
-
- addAsyncTest(function*() {
- info("Start picking a color from the page");
- yield inspector.pickColorFromPage();
-
- info("Click in the page and make sure a color-picked event is received");
- let onColorPicked = waitForEvent("color-picked");
- win.document.body.click();
- let color = yield onColorPicked;
-
- is(color, "#000000", "The color-picked event was received with the right color");
-
- runNextTest();
- });
-
- addAsyncTest(function*() {
- info("Start picking a color from the page");
- yield inspector.pickColorFromPage();
-
- info("Use the escape key to dismiss the eyedropper");
- let onPickCanceled = waitForEvent("color-pick-canceled");
-
- let keyboardEvent = win.document.createEvent("KeyboardEvent");
- keyboardEvent.initKeyEvent("keydown", true, true, win, false, false,
- false, false, 27, 0);
- win.document.dispatchEvent(keyboardEvent);
-
- yield onPickCanceled;
- ok(true, "The color-pick-canceled event was received");
-
- runNextTest();
- });
-
- addAsyncTest(function*() {
- info("Start picking a color from the page");
- yield inspector.pickColorFromPage();
-
- info("And cancel the color picking");
- yield inspector.cancelPickColorFromPage();
-
- runNextTest();
- });
-
- function waitForEvent(name) {
- return new Promise(resolve => inspector.once(name, resolve));
- }
-
- runNextTest();
-};
- </script>
-</head>
-<body>
-<a id="inspectorContent" target="_blank" href="inspector-eyedropper.html">Test Document</a>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-</pre>
-</body>
-</html>
+<!DOCTYPE HTML>
+<html>
+<!--
+Test that the inspector actor has the pickColorFromPage and cancelPickColorFromPage
+methods and that when a color is picked the color-picked event is emitted and that when
+the eyedropper is dimissed, the color-pick-canceled event is emitted.
+https://bugzilla.mozilla.org/show_bug.cgi?id=1262439
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1262439</title>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+ <script type="application/javascript" src="inspector-helpers.js"></script>
+ <script type="application/javascript">
+"use strict";
+
+window.onload = function () {
+ const {InspectorFront} = require("devtools/shared/fronts/inspector");
+
+ SimpleTest.waitForExplicitFinish();
+
+ let win = null;
+ let inspector = null;
+
+ addAsyncTest(function* () {
+ info("Setting up inspector actor");
+
+ let url = document.getElementById("inspectorContent").href;
+
+ yield new Promise(resolve => {
+ attachURL(url, function (err, client, tab, doc) {
+ win = doc.defaultView;
+ inspector = InspectorFront(client, tab);
+ resolve();
+ });
+ });
+
+ runNextTest();
+ });
+
+ addAsyncTest(function* () {
+ info("Start picking a color from the page");
+ yield inspector.pickColorFromPage();
+
+ info("Click in the page and make sure a color-picked event is received");
+ let onColorPicked = waitForEvent("color-picked");
+ win.document.body.click();
+ let color = yield onColorPicked;
+
+ is(color, "#000000", "The color-picked event was received with the right color");
+
+ runNextTest();
+ });
+
+ addAsyncTest(function* () {
+ info("Start picking a color from the page");
+ yield inspector.pickColorFromPage();
+
+ info("Use the escape key to dismiss the eyedropper");
+ let onPickCanceled = waitForEvent("color-pick-canceled");
+
+ let keyboardEvent = win.document.createEvent("KeyboardEvent");
+ keyboardEvent.initKeyEvent("keydown", true, true, win, false, false,
+ false, false, 27, 0);
+ win.document.dispatchEvent(keyboardEvent);
+
+ yield onPickCanceled;
+ ok(true, "The color-pick-canceled event was received");
+
+ runNextTest();
+ });
+
+ addAsyncTest(function* () {
+ info("Start picking a color from the page");
+ yield inspector.pickColorFromPage();
+
+ info("And cancel the color picking");
+ yield inspector.cancelPickColorFromPage();
+
+ runNextTest();
+ });
+
+ function waitForEvent(name) {
+ return new Promise(resolve => inspector.once(name, resolve));
+ }
+
+ runNextTest();
+};
+ </script>
+</head>
+<body>
+<a id="inspectorContent" target="_blank" href="inspector-eyedropper.html">Test Document</a>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/devtools/server/tests/mochitest/test_inspector-pseudoclass-lock.html
+++ b/devtools/server/tests/mochitest/test_inspector-pseudoclass-lock.html
@@ -6,62 +6,63 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
-const DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"].
- getService(Components.interfaces.inIDOMUtils);
+"use strict";
-const KNOWN_PSEUDOCLASSES = [':hover', ':active', ':focus']
+const DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
+ .getService(Components.interfaces.inIDOMUtils);
-window.onload = function() {
+const KNOWN_PSEUDOCLASSES = [":hover", ":active", ":focus"];
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gWalker = null;
-var gClient = null;
-var gCleanupConnection = null;
+let gInspectee = null;
+let gWalker = null;
+let gCleanupConnection = null;
function setup(callback) {
let url = document.getElementById("inspectorContent").href;
- gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
+ gCleanupConnection = attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
- gClient = client;
gWalker = walker;
}).then(callback));
});
}
function teardown() {
gWalker = null;
- gClient = null;
gInspectee = null;
if (gCleanupConnection) {
gCleanupConnection();
gCleanupConnection = null;
}
}
function checkChange(change, expectation) {
is(change.type, "pseudoClassLock", "Expect a pseudoclass lock change.");
let target = change.target;
- if (expectation.id)
+ if (expectation.id) {
is(target.id, expectation.id, "Expect a change on node id " + expectation.id);
- if (expectation.nodeName)
- is(target.nodeName, expectation.nodeName, "Expect a change on node name " + expectation.nodeName);
+ }
+ if (expectation.nodeName) {
+ is(target.nodeName, expectation.nodeName,
+ "Expect a change on node name " + expectation.nodeName);
+ }
is(target.pseudoClassLocks.length, expectation.pseudos.length,
"Expect " + expectation.pseudos.length + " pseudoclass locks.");
for (let i = 0; i < expectation.pseudos.length; i++) {
let pseudo = expectation.pseudos[i];
let enabled = expectation.enabled === undefined ? true : expectation.enabled[i];
ok(target.hasPseudoClassLock(pseudo), "Expect lock: " + pseudo);
let rawNode = target.rawNode();
@@ -69,93 +70,94 @@ function checkChange(change, expectation
is(rawNode.matches(pseudo), enabled,
`Target should match pseudoclass, '${pseudo}', if enabled (with .matches())`);
}
for (let pseudo of KNOWN_PSEUDOCLASSES) {
if (!expectation.pseudos.some(expected => pseudo === expected)) {
ok(!target.hasPseudoClassLock(pseudo), "Don't expect lock: " + pseudo);
- ok(!DOMUtils.hasPseudoClassLock(target.rawNode(), pseudo), "Don't expect lock in dom: " + pseudo);
+ ok(!DOMUtils.hasPseudoClassLock(target.rawNode(), pseudo),
+ "Don't expect lock in dom: " + pseudo);
}
}
}
function checkMutations(mutations, expectations) {
is(mutations.length, expectations.length, "Should get the right number of mutations.");
for (let i = 0; i < mutations.length; i++) {
- checkChange(mutations[i] , expectations[i]);
+ checkChange(mutations[i], expectations[i]);
}
}
addTest(function testPseudoClassLock() {
let contentNode;
let nodeFront;
setup(() => {
contentNode = gInspectee.querySelector("#b");
return promiseDone(gWalker.querySelector(gWalker.rootNode, "#b").then(front => {
nodeFront = front;
// Lock the pseudoclass alone, no parents.
- gWalker.addPseudoClassLock(nodeFront, ':active');
+ gWalker.addPseudoClassLock(nodeFront, ":active");
// Expect a single pseudoClassLock mutation.
return promiseOnce(gWalker, "mutations");
}).then(mutations => {
is(mutations.length, 1, "Should get one mutation");
is(mutations[0].target, nodeFront, "Should be the node we tried to apply to");
checkChange(mutations[0], {
id: "b",
nodeName: "DIV",
pseudos: [":active"]
});
}).then(() => {
// Now add :hover, this time with parents.
- gWalker.addPseudoClassLock(nodeFront, ':hover', {parents: true});
+ gWalker.addPseudoClassLock(nodeFront, ":hover", {parents: true});
return promiseOnce(gWalker, "mutations");
}).then(mutations => {
let expectedMutations = [{
- id: 'b',
- nodeName: 'DIV',
- pseudos: [':hover', ':active'],
+ id: "b",
+ nodeName: "DIV",
+ pseudos: [":hover", ":active"],
},
{
- id: 'longlist',
- nodeName: 'DIV',
- pseudos: [':hover']
+ id: "longlist",
+ nodeName: "DIV",
+ pseudos: [":hover"]
},
{
- nodeName: 'BODY',
- pseudos: [':hover']
+ nodeName: "BODY",
+ pseudos: [":hover"]
},
{
- nodeName: 'HTML',
- pseudos: [':hover']
+ nodeName: "HTML",
+ pseudos: [":hover"]
}];
checkMutations(mutations, expectedMutations);
}).then(() => {
// Now remove the :hover on all parents
- gWalker.removePseudoClassLock(nodeFront, ':hover', {parents: true});
+ gWalker.removePseudoClassLock(nodeFront, ":hover", {parents: true});
return promiseOnce(gWalker, "mutations");
}).then(mutations => {
let expectedMutations = [{
- id: 'b',
- nodeName: 'DIV',
+ id: "b",
+ nodeName: "DIV",
// Should still have :active on the original node.
- pseudos: [':active']
+ pseudos: [":active"]
},
{
- id: 'longlist',
- nodeName: 'DIV',
+ id: "longlist",
+ nodeName: "DIV",
pseudos: []
},
{
- nodeName: 'BODY',
+ nodeName: "BODY",
pseudos: []
},
{
- nodeName: 'HTML',
+ nodeName: "HTML",
pseudos: []
}];
checkMutations(mutations, expectedMutations);
}).then(() => {
gWalker.addPseudoClassLock(nodeFront, ":hover", {enabled: false});
return promiseOnce(gWalker, "mutations");
}).then(mutations => {
is(mutations.length, 1, "Should get one mutation");
@@ -165,17 +167,18 @@ addTest(function testPseudoClassLock() {
nodeName: "DIV",
pseudos: [":hover", ":active"],
enabled: [false, true]
});
}).then(() => {
// Now shut down the walker and make sure that clears up the remaining lock.
return gWalker.release();
}).then(() => {
- ok(!DOMUtils.hasPseudoClassLock(contentNode, ':active'), "Pseudoclass should have been removed during destruction.");
+ ok(!DOMUtils.hasPseudoClassLock(contentNode, ":active"),
+ "Pseudoclass should have been removed during destruction.");
teardown();
}).then(runNextTest));
});
});
</script>
</head>
<body>
--- a/devtools/server/tests/mochitest/test_inspector-release.html
+++ b/devtools/server/tests/mochitest/test_inspector-release.html
@@ -6,33 +6,33 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gClient = null;
+let gWalker = null;
+let gClient = null;
function assertOwnership() {
return assertOwnershipTrees(gWalker);
}
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker;
}).then(runNextTest));
});
@@ -40,17 +40,18 @@ addTest(function setup() {
addTest(function testReleaseSubtree() {
let originalOwnershipSize = 0;
let longlist = null;
let firstChild = null;
promiseDone(gWalker.querySelectorAll(gWalker.rootNode, "#longlist div").then(list => {
// Make sure we have the 26 children of longlist in our ownership tree.
is(list.length, 26, "Expect 26 div children.");
- // Make sure we've read in all those children and incorporated them in our ownership tree.
+ // Make sure we've read in all those children and incorporated them
+ // in our ownership tree.
return list.items();
}).then((items)=> {
originalOwnershipSize = assertOwnership();
// Here is how the ownership tree is summed up:
// #document 1
// <html> 1
// <body> 1
@@ -64,34 +65,33 @@ addTest(function testReleaseSubtree() {
firstChild = items[0].actorID;
}).then(() => {
// Now get the longlist and release it from the ownership tree.
return gWalker.querySelector(gWalker.rootNode, "#longlist");
}).then(node => {
longlist = node.actorID;
return gWalker.releaseNode(node);
}).then(() => {
- // Our ownership size should now be 53 fewer (we forgot about #longlist + 26 children + 26 singleTextChild nodes)
+ // Our ownership size should now be 53 fewer
+ // (we forgot about #longlist + 26 children + 26 singleTextChild nodes)
let newOwnershipSize = assertOwnership();
is(newOwnershipSize, originalOwnershipSize - 53,
"Ownership tree should be lower");
// Now verify that some nodes have gone away
return checkMissing(gClient, longlist);
}).then(() => {
return checkMissing(gClient, firstChild);
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gClient;
+ gWalker = null;
+ gClient = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-reload.html
+++ b/devtools/server/tests/mochitest/test_inspector-reload.html
@@ -6,70 +6,64 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gClient = null;
-var gWalker = null;
+let gInspectee = null;
+let gWalker = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
return inspector.getWalker();
}).then(walker => {
dump(walker.actorID + "\n");
ok(walker === gWalker, "getWalker() twice should return the same walker.");
}).then(runNextTest));
});
});
addTest(function testReload() {
- let nodeFront;
let oldRootID = gWalker.rootNode.actorID;
// Load a node to populate the tree a bit.
promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(front => {
gInspectee.defaultView.location.reload();
return waitForMutation(gWalker, isNewRoot);
}).then(() => {
ok(gWalker.rootNode.actorID != oldRootID, "Root node should have changed.");
}).then(() => {
// Make sure we can still access the document
return gWalker.querySelector(gWalker.rootNode, "#a");
}).then(front => {
ok(front.actorID, "Got a new actor ID");
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gInspectee;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-remove.html
+++ b/devtools/server/tests/mochitest/test_inspector-remove.html
@@ -6,39 +6,40 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gClient = null;
+let gWalker = null;
+let gClient = null;
+let gInspectee = null;
function assertOwnership() {
return assertOwnershipTrees(gWalker);
}
function ignoreNode(node) {
// Duplicate the walker logic to skip blank nodes...
return node.nodeType === Components.interfaces.nsIDOMNode.TEXT_NODE &&
!/[^\s]/.test(node.nodeValue);
}
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker;
}).then(runNextTest));
@@ -75,38 +76,39 @@ addTest(function testRemoveSubtree() {
// <div id=a>a</div> 26*2 (each child plus it's singleTextChild)
// ...
// <div id=z>z</div>
// -----
// 56
is(originalOwnershipSize, 56, "Correct number of items in ownership tree");
return gWalker.removeNode(longlist);
}).then(siblings => {
- is(siblings.previousSibling.rawNode(), previousSibling, "Should have returned the previous sibling.");
- is(siblings.nextSibling.rawNode(), nextSibling, "Should have returned the next sibling.");
+ is(siblings.previousSibling.rawNode(), previousSibling,
+ "Should have returned the previous sibling.");
+ is(siblings.nextSibling.rawNode(), nextSibling,
+ "Should have returned the next sibling.");
return waitForMutation(gWalker, isChildList);
}).then(() => {
// Our ownership size should now be 51 fewer (we forgot about #longlist + 26
// children + 26 singleTextChild nodes, but learned about #longlist's
// prev/next sibling)
let newOwnershipSize = assertOwnership();
is(newOwnershipSize, originalOwnershipSize - 51,
"Ownership tree should be lower");
// Now verify that some nodes have gone away
return checkMissing(gClient, longlistID);
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gClient;
+ gWalker = null;
+ gClient = null;
+ gInspectee = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector-resize.html
+++ b/devtools/server/tests/mochitest/test_inspector-resize.html
@@ -6,52 +6,55 @@ https://bugzilla.mozilla.org/show_bug.cg
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1222409</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const promise = require("promise");
const {InspectorFront} = require("devtools/shared/fronts/inspector");
- const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
SimpleTest.waitForExplicitFinish();
let win = null;
let inspector = null;
addAsyncTest(function* setup() {
- info ("Setting up inspector and walker actors.");
+ info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href;
+ // eslint-disable-next-line new-cap
yield new promise(resolve => {
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
win = doc.defaultView;
inspector = InspectorFront(client, tab);
resolve();
});
});
runNextTest();
});
- addAsyncTest(function*() {
+ addAsyncTest(function* () {
let walker = yield inspector.getWalker();
// We can't receive events from the walker if we haven't first executed a
// method on the actor to initialize it.
yield walker.querySelector(walker.rootNode, "img");
let {outerWidth, outerHeight} = win;
+ // eslint-disable-next-line new-cap
let onResize = new promise(resolve => {
walker.once("resize", () => {
resolve();
});
});
win.resizeTo(800, 600);
yield onResize;
--- a/devtools/server/tests/mochitest/test_inspector-resolve-url.html
+++ b/devtools/server/tests/mochitest/test_inspector-resolve-url.html
@@ -6,76 +6,77 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 921102</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspector;
-var gDoc;
+let gInspector;
+let gDoc;
-addTest(function() {
+addTest(function () {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gDoc = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
gInspector = InspectorFront(client, tab);
runNextTest();
});
});
-addTest(function() {
+addTest(function () {
info("Resolve a relative URL without providing a context node");
gInspector.resolveRelativeURL("test.png?id=4#wow").then(url => {
is(url, "chrome://mochitests/content/chrome/devtools/server/tests/" +
"mochitest/test.png?id=4#wow");
runNextTest();
});
});
-addTest(function() {
+addTest(function () {
info("Resolve an absolute URL without providing a context node");
gInspector.resolveRelativeURL("chrome://mochitests/content/chrome/" +
- "devtools/server/").then(url => {
- is(url, "chrome://mochitests/content/chrome/devtools/server/");
- runNextTest();
- });
+ "devtools/server/").then(url => {
+ is(url, "chrome://mochitests/content/chrome/devtools/server/");
+ runNextTest();
+ });
});
-addTest(function() {
+addTest(function () {
info("Resolve a relative URL providing a context node");
let node = gDoc.querySelector(".big-horizontal");
gInspector.resolveRelativeURL("test.png?id=4#wow", node).then(url => {
is(url, "chrome://mochitests/content/chrome/devtools/server/tests/" +
"mochitest/test.png?id=4#wow");
runNextTest();
});
});
-addTest(function() {
+addTest(function () {
info("Resolve an absolute URL providing a context node");
let node = gDoc.querySelector(".big-horizontal");
gInspector.resolveRelativeURL("chrome://mochitests/content/chrome/" +
- "devtools/server/", node).then(url => {
- is(url, "chrome://mochitests/content/chrome/devtools/server/");
- runNextTest();
- });
+ "devtools/server/", node).then(url => {
+ is(url, "chrome://mochitests/content/chrome/devtools/server/");
+ runNextTest();
+ });
});
-addTest(function() {
- gInspector = gDoc = null;
+addTest(function () {
+ gInspector = null;
+ gDoc = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=921102">Mozilla Bug 921102</a>
<a id="inspectorContent" target="_blank" href="inspector_getImageData.html">Test Document</a>
<p id="display"></p>
--- a/devtools/server/tests/mochitest/test_inspector-retain.html
+++ b/devtools/server/tests/mochitest/test_inspector-retain.html
@@ -6,109 +6,103 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gClient = null;
-var gInspectee = null;
+let gWalker = null;
+let gInspectee = null;
function assertOwnership() {
return assertOwnershipTrees(gWalker);
}
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
// Retain a node, and a second-order child (in another document, for kicks)
// Release the parent of the top item, which should cause one retained orphan.
// Then unretain the top node, which should retain the orphan.
// Then change the source of the iframe, which should kill that orphan.
addTest(function testRetain() {
let originalOwnershipSize = 0;
let bodyFront = null;
- let frameFront = null;
let childListFront = null;
// Get the toplevel body element and retain it.
promiseDone(gWalker.querySelector(gWalker.rootNode, "body").then(front => {
bodyFront = front;
return gWalker.retainNode(bodyFront);
}).then(() => {
// Get an element in the child frame and retain it.
return gWalker.querySelector(gWalker.rootNode, "#childFrame");
}).then(frame => {
- frameFront = frame;
return gWalker.children(frame, { maxNodes: 1 }).then(children => {
return children.nodes[0];
});
}).then(childDoc => {
return gWalker.querySelector(childDoc, "#longlist");
}).then(list => {
childListFront = list;
originalOwnershipSize = assertOwnership();
// and rtain it.
return gWalker.retainNode(childListFront);
}).then(() => {
// OK, try releasing the parent of the first retained.
return gWalker.releaseNode(bodyFront.parentNode());
}).then(() => {
- let size = assertOwnership();
let clientTree = clientOwnershipTree(gWalker);
// That request should have freed the parent of the first retained
// but moved the rest into the retained orphaned tree.
is(ownershipTreeSize(clientTree.root) + ownershipTreeSize(clientTree.retained[0]) + 1,
originalOwnershipSize,
"Should have only lost one item overall.");
is(gWalker._retainedOrphans.size, 1, "Should have retained one orphan");
- ok(gWalker._retainedOrphans.has(bodyFront), "Should have retained the expected node.");
+ ok(gWalker._retainedOrphans.has(bodyFront),
+ "Should have retained the expected node.");
}).then(() => {
// Unretain the body, which should promote the childListFront to a retained orphan.
return gWalker.unretainNode(bodyFront);
}).then(() => {
assertOwnership();
- let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 1, "Should still only have one retained orphan.");
- ok(!gWalker._retainedOrphans.has(bodyFront), "Should have dropped the body node.")
- ok(gWalker._retainedOrphans.has(childListFront), "Should have retained the child node.")
+ ok(!gWalker._retainedOrphans.has(bodyFront), "Should have dropped the body node.");
+ ok(gWalker._retainedOrphans.has(childListFront),
+ "Should have retained the child node.");
}).then(() => {
// Change the source of the iframe, which should kill the retained orphan.
gInspectee.querySelector("#childFrame").src = "data:text/html,<html>new child</html>";
return waitForMutation(gWalker, isUnretained);
}).then(mutations => {
assertOwnership();
- let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans.");
-
}).then(runNextTest));
});
// Get a hold of a node, remove it from the doc and retain it at the same time.
// We should always win that race (even though the mutation happens before the
// retain request), because we haven't issued `getMutations` yet.
addTest(function testWinRace() {
let front = null;
@@ -118,24 +112,22 @@ addTest(function testWinRace() {
contentNode.remove();
// Now wait for that mutation and retain response to come in.
return promise.all([
gWalker.retainNode(front),
waitForMutation(gWalker, isChildList)
]);
}).then(() => {
assertOwnership();
- let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 1, "Should have a retained orphan.");
ok(gWalker._retainedOrphans.has(front), "Should have retained our expected node.");
return gWalker.unretainNode(front);
}).then(() => {
// Make sure we're clear for the next test.
assertOwnership();
- let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans.");
}).then(runNextTest));
});
// Same as above, but issue the request right after the 'new-mutations' event, so that
// we *lose* the race.
addTest(function testLoseRace() {
let front = null;
@@ -144,29 +136,28 @@ addTest(function testLoseRace() {
gInspectee.querySelector("#z").parentNode = null;
let contentNode = gInspectee.querySelector("#a");
contentNode.remove();
return promiseOnce(gWalker, "new-mutations");
}).then(() => {
// Verify that we have an outstanding request (no good way to tell that it's a
// getMutations request, but there's nothing else it would be).
is(gWalker._requests.length, 1, "Should have an outstanding request.");
- return gWalker.retainNode(front)
- }).then(() => { ok(false, "Request should not have succeeded!"); },
+ return gWalker.retainNode(front);
+ }).then(() => ok(false, "Request should not have succeeded!"),
(err) => {
- ok(err, "noSuchActor", "Should have lost the race.");
- let clientTree = clientOwnershipTree(gWalker);
- is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans.");
- // Don't re-throw the error.
- }).then(runNextTest));
+ ok(err, "noSuchActor", "Should have lost the race.");
+ is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans.");
+ // Don't re-throw the error.
+ }).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_inspector-scroll-into-view.html
+++ b/devtools/server/tests/mochitest/test_inspector-scroll-into-view.html
@@ -6,40 +6,34 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 901250</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gClient = null;
-var gWalker = null;
-
-function assertOwnership() {
- assertOwnershipTrees(gWalker);
-}
+let gInspectee = null;
+let gWalker = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(Task.async(function* testScrollIntoView() {
let id = "#scroll-into-view";
let rect = gInspectee.querySelector(id).getBoundingClientRect();
@@ -62,19 +56,18 @@ addTest(Task.async(function* testScrollI
ok(inViewport, "Element is in viewport.");
runNextTest();
});
}));
addTest(function cleanup() {
- delete gWalker;
- delete gInspectee;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=901250">Mozilla Bug 901250</a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
--- a/devtools/server/tests/mochitest/test_inspector-search-front.html
+++ b/devtools/server/tests/mochitest/test_inspector-search-front.html
@@ -5,55 +5,55 @@ https://bugzilla.mozilla.org/show_bug.cg
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 835896</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const promise = require("promise");
const {InspectorFront} = require("devtools/shared/fronts/inspector");
- const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
SimpleTest.waitForExplicitFinish();
let walkerFront = null;
- let inspectee = null;
let inspector = null;
// WalkerFront specific tests. These aren't to excercise search
// edge cases so much as to test the state the Front maintains between
// searches.
// See also test_inspector-search.html
addAsyncTest(function* setup() {
- info ("Setting up inspector and walker actors.");
+ info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href;
+ // eslint-disable-next-line new-cap
yield new promise(resolve => {
- attachURL(url, function(err, client, tab, doc) {
- inspectee = doc;
+ attachURL(url, function (err, client, tab, doc) {
inspector = InspectorFront(client, tab);
resolve();
});
});
walkerFront = yield inspector.getWalker();
ok(walkerFront, "getWalker() should return an actor.");
runNextTest();
});
addAsyncTest(function* testWalkerFrontDefaults() {
- info ("Testing search API using WalkerFront.");
+ info("Testing search API using WalkerFront.");
let nodes = yield walkerFront.querySelectorAll(walkerFront.rootNode, "h2");
let fronts = yield nodes.items();
let frontResult = yield walkerFront.search("");
ok(!frontResult, "Null result on front when searching for ''");
let results = yield walkerFront.search("h2");
isDeeply(results, {
@@ -72,17 +72,17 @@ window.onload = function() {
}, "Search works with empty options");
// Clear search data to remove result state on the front
yield walkerFront.search("");
runNextTest();
});
addAsyncTest(function* testMultipleSearches() {
- info ("Testing search API using WalkerFront (reverse=false)");
+ info("Testing search API using WalkerFront (reverse=false)");
let nodes = yield walkerFront.querySelectorAll(walkerFront.rootNode, "h2");
let fronts = yield nodes.items();
let results = yield walkerFront.search("h2");
isDeeply(results, {
node: fronts[0],
type: "search",
resultsIndex: 0,
@@ -114,17 +114,17 @@ window.onload = function() {
}, "Search works with multiple results (reverse=false)");
// Clear search data to remove result state on the front
yield walkerFront.search("");
runNextTest();
});
addAsyncTest(function* testMultipleSearchesReverse() {
- info ("Testing search API using WalkerFront (reverse=true)");
+ info("Testing search API using WalkerFront (reverse=true)");
let nodes = yield walkerFront.querySelectorAll(walkerFront.rootNode, "h2");
let fronts = yield nodes.items();
let results = yield walkerFront.search("h2", {reverse: true});
isDeeply(results, {
node: fronts[2],
type: "search",
resultsIndex: 2,
@@ -163,19 +163,18 @@ window.onload = function() {
resultsLength: 3
}, "Search works with multiple results (reverse=false)");
// Clear search data to remove result state on the front
yield walkerFront.search("");
runNextTest();
});
-
addAsyncTest(function* testBackwardsCompat() {
- info ("Simulating a server that doesn't have the new search functionality.");
+ info("Simulating a server that doesn't have the new search functionality.");
walkerFront.traits.textSearch = false;
let front = yield walkerFront.querySelector(walkerFront.rootNode, "h1");
let results = yield walkerFront.search("h1");
isDeeply(results, {
node: front,
type: "selector",
resultsIndex: 0,
--- a/devtools/server/tests/mochitest/test_inspector-search.html
+++ b/devtools/server/tests/mochitest/test_inspector-search.html
@@ -5,43 +5,45 @@ https://bugzilla.mozilla.org/show_bug.cg
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 835896</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const promise = require("promise");
const {InspectorFront} = require("devtools/shared/fronts/inspector");
const {WalkerSearch, WalkerIndex} =
require("devtools/server/actors/utils/walker-search");
- const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
SimpleTest.waitForExplicitFinish();
let walkerActor = null;
let walkerSearch = null;
let inspectee = null;
let inspector = null;
// WalkerSearch specific tests. This is to make sure search results are
// coming back as expected.
// See also test_inspector-search-front.html.
addAsyncTest(function* setup() {
- info ("Setting up inspector and walker actors.");
+ info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href;
+ // eslint-disable-next-line new-cap
yield new promise(resolve => {
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
inspectee = doc;
inspector = InspectorFront(client, tab);
resolve();
});
});
let walkerFront = yield inspector.getWalker();
ok(walkerFront, "getWalker() should return an actor.");
@@ -51,31 +53,31 @@ window.onload = function() {
"Got a reference to the walker actor (" + walkerFront.actorID + ")");
walkerSearch = walkerActor.walkerSearch;
runNextTest();
});
addAsyncTest(function* testIndexExists() {
- info ("Testing basic index APIs exist.");
+ info("Testing basic index APIs exist.");
let index = new WalkerIndex(walkerActor);
ok(index.data.size > 0, "public index is filled after getting");
index.clearIndex();
ok(!index._data, "private index is empty after clearing");
ok(index.data.size > 0, "public index is filled after getting");
index.destroy();
runNextTest();
});
addAsyncTest(function* testSearchExists() {
- info ("Testing basic search APIs exist.");
+ info("Testing basic search APIs exist.");
ok(walkerSearch, "walker search exists on the WalkerActor");
ok(walkerSearch.search, "walker search has `search` method");
ok(walkerSearch.index, "walker search has `index` property");
is(walkerSearch.walker, walkerActor, "referencing the correct WalkerActor");
let search = new WalkerSearch(walkerActor);
ok(search, "a new search instance can be created");
@@ -83,18 +85,18 @@ window.onload = function() {
ok(search.index, "new search instance has `index` property");
isnot(search, walkerSearch, "new search instance differs from the WalkerActor's");
search.destroy();
runNextTest();
});
addAsyncTest(function* testEmptySearch() {
- info ("Testing search with an empty query.");
- results = walkerSearch.search("");
+ info("Testing search with an empty query.");
+ let results = walkerSearch.search("");
is(results.length, 0, "No results when searching for ''");
results = walkerSearch.search(null);
is(results.length, 0, "No results when searching for null");
results = walkerSearch.search(undefined);
is(results.length, 0, "No results when searching for undefined");
@@ -160,30 +162,30 @@ window.onload = function() {
desc: "Search that has tag and text results",
search: "h1",
expected: [
{node: inspectee.querySelector("h1"), type: "tag"},
{node: inspectee.querySelector("h1 + p").childNodes[0], type: "text"},
{node: inspectee.querySelector("h1 + p > strong").childNodes[0], type: "text"},
]
},
- ]
+ ];
for (let {desc, search, expected} of testData) {
info("Running test: " + desc);
let results = walkerSearch.search(search);
isDeeply(results, expected,
"Search returns correct results with '" + search + "'");
}
runNextTest();
});
addAsyncTest(function* testPseudoElements() {
- info ("Testing ::before and ::after element matching");
+ info("Testing ::before and ::after element matching");
let beforeElt = new _documentWalker(inspectee.querySelector("#pseudo"),
inspectee.defaultView).firstChild();
let afterElt = new _documentWalker(inspectee.querySelector("#pseudo"),
inspectee.defaultView).lastChild();
let styleText = inspectee.querySelector("style").childNodes[0];
// ::before
@@ -213,17 +215,17 @@ window.onload = function() {
{node: styleText, type: "text"},
{node: afterElt, type: "text"}
], "Text search works for pseudo element");
runNextTest();
});
addAsyncTest(function* testSearchMutationChangeResults() {
- info ("Testing search before and after a mutation.");
+ info("Testing search before and after a mutation.");
let expected = [
{node: inspectee.querySelectorAll("h3")[0], type: "tag"},
{node: inspectee.querySelectorAll("h3")[1], type: "tag"},
{node: inspectee.querySelectorAll("h3")[2], type: "tag"},
];
let results = walkerSearch.search("h3");
isDeeply(results, expected, "Search works with tag results");
@@ -233,32 +235,34 @@ window.onload = function() {
});
results = walkerSearch.search("h3");
isDeeply(results, [
expected[1],
expected[2]
], "Results are updated after removal");
+ // eslint-disable-next-line new-cap
yield new promise(resolve => {
info("Waiting for a mutation to happen");
let observer = new inspectee.defaultView.MutationObserver(() => {
resolve();
});
observer.observe(inspectee, {attributes: true, subtree: true});
inspectee.body.setAttribute("h3", "true");
});
results = walkerSearch.search("h3");
isDeeply(results, [
{node: inspectee.body, type: "attributeName"},
expected[1],
expected[2]
], "Results are updated after addition");
+ // eslint-disable-next-line new-cap
yield new promise(resolve => {
info("Waiting for a mutation to happen");
let observer = new inspectee.defaultView.MutationObserver(() => {
resolve();
});
observer.observe(inspectee, {attributes: true, childList: true, subtree: true});
inspectee.body.removeAttribute("h3");
expected[1].node.remove();
@@ -269,16 +273,17 @@ window.onload = function() {
is(results.length, 0, "Results are updated after removal");
runNextTest();
});
runNextTest();
function mutateDocumentAndWaitForMutation(mutationFn) {
+ // eslint-disable-next-line new-cap
return new promise(resolve => {
info("Listening to markup mutation on the inspectee");
let observer = new inspectee.defaultView.MutationObserver(resolve);
observer.observe(inspectee, {childList: true, subtree: true});
mutationFn();
});
}
};
--- a/devtools/server/tests/mochitest/test_inspector-traversal.html
+++ b/devtools/server/tests/mochitest/test_inspector-traversal.html
@@ -6,50 +6,51 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/server/actors/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspectee = null;
-var gClient = null;
-var gWalker = null;
-var checkActorIDs = [];
+let gInspectee = null;
+let gClient = null;
+let gWalker = null;
+let checkActorIDs = [];
function assertOwnership() {
assertOwnershipTrees(gWalker);
}
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker;
}).then(runNextTest));
});
});
addTest(function testWalkerRoot() {
// Make sure that refetching the root document of the walker returns the same
// actor as the getWalker returned.
promiseDone(gWalker.document().then(root => {
- ok(root === gWalker.rootNode, "Re-fetching the document node should match the root document node.");
+ ok(root === gWalker.rootNode,
+ "Re-fetching the document node should match the root document node.");
checkActorIDs.push(root.actorID);
assertOwnership();
}).then(runNextTest));
});
addTest(function testInnerHTML() {
promiseDone(gWalker.documentElement().then(docElement => {
return gWalker.innerHTML(docElement);
@@ -116,117 +117,122 @@ addTest(function testQuerySelectors() {
is(node.id, "a", "First child should be a");
assertOwnership();
return nodeList.items();
}).then(nodes => {
is(nodes.length, 26, "Expect 26 nodes");
is(nodes[0], firstNode, "First node should be reused.");
ok(nodes[0]._parent, "Parent node should be set.");
ok(nodes[0]._next || nodes[0]._prev, "Siblings should be set.");
- ok(nodes[25]._next || nodes[25]._prev, "Siblings of " + nodes[25] + " should be set.");
+ ok(nodes[25]._next || nodes[25]._prev,
+ "Siblings of " + nodes[25] + " should be set.");
assertOwnership();
return nodeList.items(-1);
}).then(nodes => {
- is(nodes.length, 1, "Expect 1 node")
+ is(nodes.length, 1, "Expect 1 node");
is(nodes[0].id, "z", "Expect it to be the last node.");
checkActorIDs.push(nodes[0].actorID);
// Save the node list ID so we can ensure it was destroyed.
nodeListID = nodeList.actorID;
assertOwnership();
return nodeList.release();
}).then(() => {
ok(!nodeList.actorID, "Actor should have been destroyed.");
assertOwnership();
return checkMissing(gClient, nodeListID);
}).then(runNextTest));
});
// Helper to check the response of requests that return hasFirst/hasLast/nodes
// node lists (like `children` and `siblings`)
function nodeArrayChecker(first, last, ids) {
- return function(response) {
- is(response.hasFirst, first, "Should " + (first ? "" : "not ") + " have the first node.");
+ return function (response) {
+ is(response.hasFirst, first,
+ "Should " + (first ? "" : "not ") + " have the first node.");
is(response.hasLast, last, "Should " + (last ? "" : "not ") + " have the last node.");
- is(response.nodes.length, ids.length, "Should have " + ids.length + " children listed.");
- let responseIds = '';
- for (node of response.nodes) {
+ is(response.nodes.length, ids.length,
+ "Should have " + ids.length + " children listed.");
+ let responseIds = "";
+ for (let node of response.nodes) {
responseIds += node.id;
}
is(responseIds, ids, "Correct nodes were returned.");
assertOwnership();
- }
+ };
}
addTest(function testNoChildren() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#empty").then(empty => {
assertOwnership();
return gWalker.children(empty).then(nodeArrayChecker(true, true, ""));
}).then(runNextTest));
});
addTest(function testLongListTraversal() {
- var longList;
- var allChildren;
+ let longList;
+ let allChildren;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(node => {
longList = node;
// First call with no options, expect all children.
assertOwnership();
return gWalker.children(longList).then(response => {
nodeArrayChecker(true, true, "abcdefghijklmnopqrstuvwxyz")(response);
allChildren = response.nodes;
assertOwnership();
});
}).then(() => {
// maxNodes should limit us to the first 5 nodes.
assertOwnership();
- return gWalker.children(longList, { maxNodes: 5 }).then(nodeArrayChecker(true, false, 'abcde'));
+ return gWalker.children(longList, { maxNodes: 5 })
+ .then(nodeArrayChecker(true, false, "abcde"));
}).then(() => {
assertOwnership();
// maxNodes with the second item centered should still give us the first 5 nodes.
return gWalker.children(longList, { maxNodes: 5, center: allChildren[1] }).then(
- nodeArrayChecker(true, false, 'abcde')
+ nodeArrayChecker(true, false, "abcde")
);
}).then(() => {
// maxNodes with a center in the middle of the list should put that item in the middle
let center = allChildren[13];
- is(center.id, 'n', "Make sure I know how to count letters.");
+ is(center.id, "n", "Make sure I know how to count letters.");
return gWalker.children(longList, { maxNodes: 5, center: center }).then(
- nodeArrayChecker(false, false, 'lmnop')
+ nodeArrayChecker(false, false, "lmnop")
);
}).then(() => {
// maxNodes with the second-to-last item centered should give us the last 5 nodes.
return gWalker.children(longList, { maxNodes: 5, center: allChildren[24] }).then(
- nodeArrayChecker(false, true, 'vwxyz')
+ nodeArrayChecker(false, true, "vwxyz")
);
}).then(() => {
// maxNodes with a start in the middle should start at that node and fetch 5
let start = allChildren[13];
- is(start.id, 'n', "Make sure I know how to count letters.")
+ is(start.id, "n", "Make sure I know how to count letters.");
return gWalker.children(longList, { maxNodes: 5, start: start }).then(
- nodeArrayChecker(false, false, 'nopqr')
+ nodeArrayChecker(false, false, "nopqr")
);
}).then(() => {
// maxNodes near the end should only return what's left
return gWalker.children(longList, { maxNodes: 5, start: allChildren[24] }).then(
- nodeArrayChecker(false, true, 'yz')
+ nodeArrayChecker(false, true, "yz")
);
}).then(runNextTest));
});
addTest(function testObjectNodeChildren() {
promiseDone(
gWalker.querySelector(gWalker.rootNode, "object")
.then(object => gWalker.children(object))
.then(nodeArrayChecker(true, true, "1"))
.then(runNextTest));
});
addTest(function testSiblings() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(a => {
- return gWalker.siblings(a, { maxNodes: 5, center: a }).then(nodeArrayChecker(true, false, "abcde"));
+ return gWalker.siblings(a, { maxNodes: 5, center: a })
+ .then(nodeArrayChecker(true, false, "abcde"));
}).then(() => {
return gWalker.siblings(gWalker.rootNode).then(response => {
ok(response.hasFirst && response.hasLast, "Has first and last.");
is(response.nodes.length, 1, "Has only the document element.");
ok(response.nodes[0] === gWalker.rootNode, "Document element is its own sibling.");
});
}).then(runNextTest));
});
@@ -250,41 +256,43 @@ addTest(function testPreviousSibling() {
}).then(a => {
is(a.id, "a", "nextSibling got the next node.");
return gWalker.previousSibling(a);
}).then(nothing => {
is(nothing, null, "previousSibling on the first node returned null.");
}).then(runNextTest));
});
-
addTest(function testFrameTraversal() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
return gWalker.children(childFrame);
}).then(children => {
let nodes = children.nodes;
is(nodes.length, 1, "There should be only one child of the iframe");
is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node");
return gWalker.querySelector(nodes[0], "#z");
}).then(childDocumentZ => {
return gWalker.parents(childDocumentZ);
}).then(parents => {
// Expected set of parent tag names for this item:
- let expectedParents = ['DIV', 'BODY', 'HTML', '#document', 'IFRAME', 'BODY', 'HTML', '#document'];
+ let expectedParents = ["DIV", "BODY", "HTML", "#document", "IFRAME", "BODY", "HTML",
+ "#document"];
for (let parent of parents) {
let expected = expectedParents.shift();
is(parent.nodeName, expected, "Got expected parent");
}
}).then(runNextTest));
});
addTest(function testLongValue() {
const testSummaryLength = 10;
+ const inspector = require("devtools/server/actors/inspector");
+
inspector.setValueSummaryLength(testSummaryLength);
- SimpleTest.registerCleanupFunction(function() {
+ SimpleTest.registerCleanupFunction(function () {
inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH);
});
let longstringText = gInspectee.getElementById("longstring").firstChild.nodeValue;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#longstring").then(node => {
ok(!node.inlineTextChild, "Text is too long to be inlined");
// Now we need to get the text node child...
@@ -293,17 +301,18 @@ addTest(function testLongValue() {
let textNode = children.nodes[0];
is(textNode.nodeType, Node.TEXT_NODE, "Value should be a text node");
return textNode;
}).then(textNode => {
return textNode.getNodeValue();
}).then(value => {
return value.string();
}).then(valueStr => {
- is(valueStr, longstringText, "Full node value should match the string from the document.");
+ is(valueStr, longstringText,
+ "Full node value should match the string from the document.");
}).then(runNextTest));
});
addTest(function testShortValue() {
let shortstringText = gInspectee.getElementById("shortstring").firstChild.nodeValue;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#shortstring").then(node => {
ok(!!node.inlineTextChild, "Text is short enough to be inlined");
@@ -313,37 +322,36 @@ addTest(function testShortValue() {
let textNode = children.nodes[0];
is(textNode.nodeType, Node.TEXT_NODE, "Value should be a text node");
return textNode;
}).then(textNode => {
return textNode.getNodeValue();
}).then(value => {
return value.string();
}).then(valueStr => {
- is(valueStr, shortstringText, "Full node value should match the string from the document.");
+ is(valueStr, shortstringText,
+ "Full node value should match the string from the document.");
}).then(runNextTest));
});
addTest(function testReleaseWalker() {
checkActorIDs.push(gWalker.actorID);
promiseDone(gWalker.release().then(() => {
let promises = Array.from(checkActorIDs, (id) => checkMissing(gClient, id));
- return promise.all(promises)
+ return promise.all(promises);
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gWalker;
- delete gInspectee;
- delete gClient;
+ gWalker = null;
+ gInspectee = null;
+ gClient = null;
runNextTest();
});
-
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
--- a/devtools/server/tests/mochitest/test_inspector_getImageData-wait-for-load.html
+++ b/devtools/server/tests/mochitest/test_inspector_getImageData-wait-for-load.html
@@ -12,44 +12,48 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 1192536</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
+"use strict";
const flags = require("devtools/shared/flags");
const wasTesting = flags.testing;
-SimpleTest.registerCleanupFunction(() => flags.testing = wasTesting);
+SimpleTest.registerCleanupFunction(function () {
+ flags.testing = wasTesting;
+});
const PATH = "http://mochi.test:8888/chrome/devtools/server/tests/mochitest/";
const BASE_IMAGE = PATH + "inspector-delay-image-response.sjs";
const DELAYED_IMAGE = BASE_IMAGE + "?delay=300";
const TIMEOUT_IMAGE = BASE_IMAGE + "?delay=50000";
const NONEXISTENT_IMAGE = PATH + "this-does-not-exist.png";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gImg = null;
-var gNodeFront = null;
-var gWalker = null;
+let gImg = null;
+let gNodeFront = null;
+let gWalker = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
gWalker = walker;
+ // eslint-disable-next-line max-nested-callbacks
return walker.querySelector(gWalker.rootNode, "img.custom").then(img => {
gNodeFront = img;
gImg = doc.querySelector("img.custom");
ok(gNodeFront, "Got the image NodeFront.");
ok(gImg, "Got the image Node.");
});
}).then(runNextTest));
@@ -88,19 +92,19 @@ addTest(function testDelayedImage() {
gImg.src = DELAYED_IMAGE;
info("Calling getImageData().");
checkImageData(gNodeFront.getImageData()).then(runNextTest);
});
addTest(function cleanup() {
- delete gImg;
- delete gNodeFront
- delete gWalker;
+ gImg = null;
+ gNodeFront = null;
+ gWalker = null;
runNextTest();
});
/**
* Asserts that the given promise rejects.
*/
function ensureRejects(promise, desc) {
return promise.then(() => {
--- a/devtools/server/tests/mochitest/test_inspector_getImageData.html
+++ b/devtools/server/tests/mochitest/test_inspector_getImageData.html
@@ -6,28 +6,28 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 932937</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
+let gWalker = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
gWalker = walker;
}).then(runNextTest));
});
});
@@ -40,16 +40,17 @@ addTest(function testLargeImage() {
img.getImageData(100).then(imageData => {
ok(imageData.data, "Image data actor was sent back");
ok(imageData.size, "Image size info was sent back too");
is(imageData.size.naturalWidth, 5333, "Natural width of the image correct");
is(imageData.size.naturalHeight, 3000, "Natural width of the image correct");
ok(imageData.size.resized, "Image was resized");
+ // eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => {
ok(str, "We have an image data string!");
testResizing(imageData, str);
});
});
});
});
@@ -61,16 +62,17 @@ addTest(function testLargeCanvas() {
canvas.getImageData(350).then(imageData => {
ok(imageData.data, "Image data actor was sent back");
ok(imageData.size, "Image size info was sent back too");
is(imageData.size.naturalWidth, 1000, "Natural width of the image correct");
is(imageData.size.naturalHeight, 2000, "Natural width of the image correct");
ok(imageData.size.resized, "Image was resized");
+ // eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => {
ok(str, "We have an image data string!");
testResizing(imageData, str);
});
});
});
});
@@ -82,16 +84,17 @@ addTest(function testSmallImage() {
img.getImageData().then(imageData => {
ok(imageData.data, "Image data actor was sent back");
ok(imageData.size, "Image size info was sent back too");
is(imageData.size.naturalWidth, 245, "Natural width of the image correct");
is(imageData.size.naturalHeight, 240, "Natural width of the image correct");
ok(!imageData.size.resized, "Image was NOT resized");
+ // eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => {
ok(str, "We have an image data string!");
testResizing(imageData, str);
});
});
});
});
@@ -103,32 +106,33 @@ addTest(function testDataImage() {
img.getImageData(14).then(imageData => {
ok(imageData.data, "Image data actor was sent back");
ok(imageData.size, "Image size info was sent back too");
is(imageData.size.naturalWidth, 28, "Natural width of the image correct");
is(imageData.size.naturalHeight, 28, "Natural width of the image correct");
ok(imageData.size.resized, "Image was resized");
+ // eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => {
ok(str, "We have an image data string!");
testResizing(imageData, str);
});
});
});
});
addTest(function testNonImgOrCanvasElements() {
gWalker.querySelector(gWalker.rootNode, "body").then(body => {
ensureRejects(body.getImageData(), "Invalid element").then(runNextTest);
});
});
addTest(function cleanup() {
- delete gWalker;
+ gWalker = null;
runNextTest();
});
/**
* Checks if the server told the truth about resizing the image
*/
function testResizing(imageData, str) {
let img = document.createElement("img");
--- a/devtools/server/tests/mochitest/test_inspector_getImageDataFromURL.html
+++ b/devtools/server/tests/mochitest/test_inspector_getImageDataFromURL.html
@@ -11,37 +11,40 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 1192536</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
+"use strict";
const flags = require("devtools/shared/flags");
const wasTesting = flags.testing;
-SimpleTest.registerCleanupFunction(() => flags.testing = wasTesting);
+SimpleTest.registerCleanupFunction(function () {
+ flags.testing = wasTesting;
+});
const PATH = "http://mochi.test:8888/chrome/devtools/server/tests/mochitest/";
const BASE_IMAGE = PATH + "inspector-delay-image-response.sjs";
const DELAYED_IMAGE = BASE_IMAGE + "?delay=300";
const TIMEOUT_IMAGE = BASE_IMAGE + "?delay=50000";
const NONEXISTENT_IMAGE = PATH + "this-does-not-exist.png";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gInspector = null;
+let gInspector = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
gInspector = InspectorFront(client, tab);
runNextTest();
});
});
addTest(function testTimeout() {
info("Testing that the method aborts if the image takes too long to load.");
@@ -68,17 +71,17 @@ addTest(function testNormalImage() {
// This test shouldn't hit the timeout.
flags.testing = true;
checkImageData(gInspector.getImageDataFromURL(DELAYED_IMAGE)).then(runNextTest);
});
addTest(function cleanup() {
- delete gInspector;
+ gInspector = null;
runNextTest();
});
/**
* Asserts that the given promise rejects.
*/
function ensureRejects(promise, desc) {
return promise.then(() => {
--- a/devtools/server/tests/mochitest/test_inspector_getNodeFromActor.html
+++ b/devtools/server/tests/mochitest/test_inspector_getNodeFromActor.html
@@ -6,75 +6,75 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug 1155653</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/shared/fronts/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker;
+let gWalker;
-addTest(function() {
+addTest(function () {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
gWalker = walker;
}).then(runNextTest));
});
});
-addTest(function() {
+addTest(function () {
info("Try to get a NodeFront from an invalid actorID");
gWalker.getNodeFromActor("invalid", ["node"]).then(node => {
ok(!node, "The node returned is null");
runNextTest();
});
});
-addTest(function() {
+addTest(function () {
info("Try to get a NodeFront from a valid actorID but invalid path");
gWalker.getNodeFromActor(gWalker.actorID, ["invalid", "path"]).then(node => {
ok(!node, "The node returned is null");
runNextTest();
});
});
-addTest(function() {
+addTest(function () {
info("Try to get a NodeFront from a valid actorID and valid path");
gWalker.getNodeFromActor(gWalker.actorID, ["rootDoc"]).then(rootDocNode => {
ok(rootDocNode, "A node was returned");
is(rootDocNode, gWalker.rootNode, "The right node was returned");
runNextTest();
});
});
-addTest(function() {
+addTest(function () {
info("Try to get a NodeFront from a valid actorID and valid complex path");
gWalker.getNodeFromActor(gWalker.actorID,
["tabActor", "window", "document", "body"]).then(bodyNode => {
- ok(bodyNode, "A node was returned");
- gWalker.querySelector(gWalker.rootNode, "body").then(node => {
- is(bodyNode, node, "The body node was returned");
- runNextTest();
+ ok(bodyNode, "A node was returned");
+ gWalker.querySelector(gWalker.rootNode, "body").then(node => {
+ is(bodyNode, node, "The body node was returned");
+ runNextTest();
+ });
});
- });
});
-addTest(function() {
+addTest(function () {
gWalker = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1155653">Mozilla Bug 1155653</a>
<a id="inspectorContent" target="_blank" href="inspector_getImageData.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_makeGlobalObjectReference.html
+++ b/devtools/server/tests/mochitest/test_makeGlobalObjectReference.html
@@ -10,77 +10,86 @@ Debugger.prototype.makeGlobalObjectRefer
<meta charset="utf-8">
<title>Mozilla Bug 914405</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var iframe = document.createElement("iframe");
- iframe.src = "data:text/html,<html>The word 'smorgasbord', spoken by an adorably plump child, symbolizing prosperity</html>";
+ let iframe = document.createElement("iframe");
+ iframe.src = "data:text/html,<html>The word 'smorgasbord'," +
+ " spoken by an adorably plump child, symbolizing prosperity</html>";
iframe.onload = iframeOnLoad;
document.body.appendChild(iframe);
function iframeOnLoad() {
- var dbg = new Debugger;
+ let dbg = new Debugger();
- var g1o = iframe.contentWindow; // 'o' for 'outer window'
+ // 'o' for 'outer window'
+ let g1o = iframe.contentWindow;
ok(!dbg.hasDebuggee(g1o), "iframe is not initially a debuggee");
// Like addDebuggee, makeGlobalObjectReference innerizes.
// 'i' stands for 'inner window'.
// 'DO' stands for 'Debugger.Object'.
- var g1iDO = dbg.makeGlobalObjectReference(g1o);
- ok(!dbg.hasDebuggee(g1o), "makeGlobalObjectReference does not add g1 as debuggee, designated via outer");
- ok(!dbg.hasDebuggee(g1iDO), "makeGlobalObjectReference does not add g1 as debuggee, designated via D.O ");
+ let g1iDO = dbg.makeGlobalObjectReference(g1o);
+ ok(!dbg.hasDebuggee(g1o),
+ "makeGlobalObjectReference does not add g1 as debuggee, designated via outer");
+ ok(!dbg.hasDebuggee(g1iDO),
+ "makeGlobalObjectReference does not add g1 as debuggee, designated via D.O ");
// Wrapping an object automatically outerizes it, so dereferencing an
// inner object D.O gets you an outer object.
// ('===' does distinguish inner and outer objects.)
// (That's a capital '=', if you must know.)
ok(g1iDO.unsafeDereference() === g1o, "g1iDO has the right referent");
// However, Debugger.Objects do distinguish inner and outer windows.
- var g1oDO = g1iDO.makeDebuggeeValue(g1o);
+ let g1oDO = g1iDO.makeDebuggeeValue(g1o);
ok(g1iDO !== g1oDO, "makeDebuggeeValue doesn't innerize");
ok(g1iDO.unsafeDereference() === g1oDO.unsafeDereference(),
- "unsafeDereference() outerizes, so inner and outer window D.Os both dereference to outer");
+ "unsafeDereference() outerizes," +
+ " so inner and outer window D.Os both dereference to outer");
ok(dbg.addDebuggee(g1o) === g1iDO, "addDebuggee returns the inner window's D.O");
ok(dbg.hasDebuggee(g1o), "addDebuggee adds the correct global");
- ok(dbg.hasDebuggee(g1iDO), "hasDebuggee can take a D.O referring to the inner window");
- ok(dbg.hasDebuggee(g1oDO), "hasDebuggee can take a D.O referring to the outer window");
+ ok(dbg.hasDebuggee(g1iDO),
+ "hasDebuggee can take a D.O referring to the inner window");
+ ok(dbg.hasDebuggee(g1oDO),
+ "hasDebuggee can take a D.O referring to the outer window");
- var iframe2 = document.createElement("iframe");
- iframe2.src = "data:text/html,<html>Her retrospection, in hindsight, was prescient.</html>";
+ let iframe2 = document.createElement("iframe");
+ iframe2.src = "data:text/html,<html>Her retrospection," +
+ " in hindsight, was prescient.</html>";
iframe2.onload = iframe2OnLoad;
document.body.appendChild(iframe2);
function iframe2OnLoad() {
// makeGlobalObjectReference dereferences CCWs.
- var g2o = iframe2.contentWindow;
+ let g2o = iframe2.contentWindow;
g2o.g1o = g1o;
- var g2iDO = dbg.addDebuggee(g2o);
- var g2g1oDO = g2iDO.getOwnPropertyDescriptor('g1o').value;
+ let g2iDO = dbg.addDebuggee(g2o);
+ let g2g1oDO = g2iDO.getOwnPropertyDescriptor("g1o").value;
ok(g2g1oDO !== g1oDO, "g2's cross-compartment wrapper for g1o gets its own D.O");
ok(g2g1oDO.unwrap() === g1oDO,
"unwrapping g2's cross-compartment wrapper for g1o gets the right D.O");
ok(dbg.makeGlobalObjectReference(g2g1oDO) === g1iDO,
"makeGlobalObjectReference unwraps cross-compartment wrappers, and innerizes");
SimpleTest.finish();
}
}
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_memory.html
+++ b/devtools/server/tests/mochitest/test_memory.html
@@ -8,22 +8,24 @@ Bug 923275 - Add a memory monitor widget
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
- var measurement = yield memory.measure();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let measurement = yield memory.measure();
ok(measurement.total > 0, "total memory is valid");
ok(measurement.domSize > 0, "domSize is valid");
ok(measurement.styleSize > 0, "styleSize is valid");
ok(measurement.jsObjectsSize > 0, "jsObjectsSize is valid");
ok(measurement.jsStringsSize > 0, "jsStringsSize is valid");
ok(measurement.jsOtherSize > 0, "jsOtherSize is valid");
ok(measurement.otherSize > 0, "otherSize is valid");
ok(measurement.jsMilliseconds, "jsMilliseconds is valid");
--- a/devtools/server/tests/mochitest/test_memory_allocations_01.html
+++ b/devtools/server/tests/mochitest/test_memory_allocations_01.html
@@ -8,79 +8,85 @@ Bug 1067491 - Test recording allocations
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
yield memory.startRecordingAllocations();
ok(true, "Can start recording allocations");
// Allocate some objects.
- var alloc1, alloc2, alloc3;
+ let alloc1, alloc2, alloc3;
+
+ /* eslint-disable max-nested-callbacks */
(function outer() {
(function middle() {
(function inner() {
- alloc1 = {}; alloc1.line = Error().lineNumber;
- alloc2 = []; alloc2.line = Error().lineNumber;
- alloc3 = new function() {}; alloc3.line = Error().lineNumber;
+ alloc1 = {}; alloc1.line = Error().lineNumber;
+ alloc2 = []; alloc2.line = Error().lineNumber;
+ // eslint-disable-next-line new-parens
+ alloc3 = new function () {}; alloc3.line = Error().lineNumber;
}());
}());
}());
+ /* eslint-enable max-nested-callbacks */
- var response = yield memory.getAllocations();
+ let response = yield memory.getAllocations();
yield memory.stopRecordingAllocations();
ok(true, "Can stop recording allocations");
// Filter out allocations by library and test code, and get only the
// allocations that occurred in our test case above.
function isTestAllocation(alloc) {
- var frame = response.frames[alloc];
+ let frame = response.frames[alloc];
return frame
&& frame.functionDisplayName === "inner"
&& (frame.line === alloc1.line
|| frame.line === alloc2.line
|| frame.line === alloc3.line);
}
- var testAllocations = response.allocations.filter(isTestAllocation);
+ let testAllocations = response.allocations.filter(isTestAllocation);
ok(testAllocations.length >= 3,
"Should find our 3 test allocations (plus some allocations for the error "
+ "objects used to get line numbers)");
// For each of the test case's allocations, ensure that the parent frame
// indices are correct. Also test that we did get an allocation at each
// line we expected (rather than a bunch on the first line and none on the
// others, etc).
- var expectedLines = new Set([alloc1.line, alloc2.line, alloc3.line]);
+ let expectedLines = new Set([alloc1.line, alloc2.line, alloc3.line]);
- for (var alloc of testAllocations) {
- var innerFrame = response.frames[alloc];
+ for (let alloc of testAllocations) {
+ let innerFrame = response.frames[alloc];
ok(innerFrame, "Should get the inner frame");
is(innerFrame.functionDisplayName, "inner");
expectedLines.delete(innerFrame.line);
- var middleFrame = response.frames[innerFrame.parent];
+ let middleFrame = response.frames[innerFrame.parent];
ok(middleFrame, "Should get the middle frame");
is(middleFrame.functionDisplayName, "middle");
- var outerFrame = response.frames[middleFrame.parent];
+ let outerFrame = response.frames[middleFrame.parent];
ok(outerFrame, "Should get the outer frame");
is(outerFrame.functionDisplayName, "outer");
// Not going to test the rest of the frames because they are Task.jsm
// and promise frames and it gets gross. Plus, I wouldn't want this test
// to start failing if they changed their implementations in a way that
// added or removed stack frames here.
}
--- a/devtools/server/tests/mochitest/test_memory_allocations_02.html
+++ b/devtools/server/tests/mochitest/test_memory_allocations_02.html
@@ -8,66 +8,70 @@ Bug 1132764 - Test controlling the maxim
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
- var allocs = [];
- var eventsFired = 0;
- var intervalId = null;
- function onAlloc () {
+ let allocs = [];
+ let eventsFired = 0;
+ let intervalId = null;
+ function onAlloc() {
eventsFired++;
}
- function startAllocating () {
+ function startAllocating() {
intervalId = setInterval(() => {
- for (var i = 100000; --i;) {
+ for (let i = 100000; --i;) {
allocs.push(new Object());
}
}, 1);
}
- function stopAllocating () {
+ function stopAllocating() {
clearInterval(intervalId);
}
memory.on("allocations", onAlloc);
yield memory.startRecordingAllocations({
drainAllocationsTimeout: 10
});
yield waitUntil(() => eventsFired > 5);
- ok(eventsFired > 5, "Some allocation events fired without allocating much via auto drain");
+ ok(eventsFired > 5,
+ "Some allocation events fired without allocating much via auto drain");
yield memory.stopRecordingAllocations();
// Set a really high auto drain timer so we can test if
// it fires on GC
eventsFired = 0;
- var startTime = performance.now();
- var drainTimer = 1000000;
+ let startTime = performance.now();
+ let drainTimer = 1000000;
yield memory.startRecordingAllocations({
drainAllocationsTimeout: drainTimer
});
startAllocating();
yield waitUntil(() => {
Cu.forceGC();
return eventsFired > 1;
});
stopAllocating();
- ok(performance.now() - drainTimer < startTime, "Allocation events fired on GC before timer");
+ ok(performance.now() - drainTimer < startTime,
+ "Allocation events fired on GC before timer");
yield memory.stopRecordingAllocations();
memory.off("allocations", onAlloc);
yield memory.detach();
destroyServerAndFinish(client);
});
};
</script>
--- a/devtools/server/tests/mochitest/test_memory_allocations_03.html
+++ b/devtools/server/tests/mochitest/test_memory_allocations_03.html
@@ -8,68 +8,70 @@ Bug 1067491 - Test that frames keep the
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
yield memory.startRecordingAllocations();
// Allocate twice with the exact same stack (hence setTimeout rather than
// allocating directly in the generator), but with getAllocations() calls in
// between.
- var allocs = [];
+ let allocs = [];
function allocator() {
allocs.push({});
}
setTimeout(allocator, 1);
yield waitForTime(2);
- var first = yield memory.getAllocations();
+ let first = yield memory.getAllocations();
setTimeout(allocator, 1);
yield waitForTime(2);
- var second = yield memory.getAllocations();
+ let second = yield memory.getAllocations();
yield memory.stopRecordingAllocations();
// Assert that each frame in the first response has the same index in the
// second response. This isn't commutative, so we don't check that all
// of the second response's frames are the same in the first response,
// because there might be new allocations that happen after the first query
// but before the second.
function assertSameFrame(a, b) {
- info("Checking frames at index " + i + ":");
info(" First frame = " + JSON.stringify(a, null, 4));
info(" Second frame = " + JSON.stringify(b, null, 4));
is(!!a, !!b);
if (!a || !b) {
return;
}
is(a.source, b.source);
is(a.line, b.line);
is(a.column, b.column);
is(a.functionDisplayName, b.functionDisplayName);
is(a.parent, b.parent);
}
- for (var i = 0; i < first.frames.length; i++) {
+ for (let i = 0; i < first.frames.length; i++) {
+ info("Checking frames at index " + i + ":");
assertSameFrame(first.frames[i], second.frames[i]);
}
yield memory.detach();
destroyServerAndFinish(client);
});
};
</script>
--- a/devtools/server/tests/mochitest/test_memory_allocations_04.html
+++ b/devtools/server/tests/mochitest/test_memory_allocations_04.html
@@ -8,37 +8,39 @@ Bug 1068171 - Test controlling the memor
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
- var allocs = [];
+ let allocs = [];
function allocator() {
- for (var i = 0; i < 100; i++) {
+ for (let i = 0; i < 100; i++) {
allocs.push({});
}
}
- var testProbability = Task.async(function* (p, expected) {
+ let testProbability = Task.async(function* (p, expected) {
info("probability = " + p);
yield memory.startRecordingAllocations({
probability: p
});
allocator();
- var response = yield memory.getAllocations();
+ let response = yield memory.getAllocations();
yield memory.stopRecordingAllocations();
return response.allocations.length;
});
is((yield testProbability(0.0)), 0,
"With probability = 0.0, we shouldn't get any allocations.");
ok((yield testProbability(1.0)) >= 100,
--- a/devtools/server/tests/mochitest/test_memory_allocations_05.html
+++ b/devtools/server/tests/mochitest/test_memory_allocations_05.html
@@ -8,74 +8,80 @@ Bug 1068144 - Test getting the timestamp
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
- var allocs = [];
+ let allocs = [];
function allocator() {
- allocs.push(new Object);
+ allocs.push(new Object());
}
// Using setTimeout results in wildly varying delays that make it hard to
// test our timestamps and results in intermittent failures. Instead, we
// actually spin an empty loop for a whole millisecond.
function actuallyWaitOneWholeMillisecond() {
- var start = window.performance.now();
- while (window.performance.now() - start < 1.000) ;
+ let start = window.performance.now();
+ // eslint-disable-next-line curly
+ while (window.performance.now() - start < 1.000);
}
yield memory.startRecordingAllocations();
allocator();
actuallyWaitOneWholeMillisecond();
allocator();
actuallyWaitOneWholeMillisecond();
allocator();
- var response = yield memory.getAllocations();
+ let response = yield memory.getAllocations();
yield memory.stopRecordingAllocations();
ok(response.allocationsTimestamps, "The response should have timestamps.");
is(response.allocationsTimestamps.length, response.allocations.length,
"There should be a timestamp for every allocation.");
- var allocatorIndices = response.allocations
+ let allocatorIndices = response.allocations
.map(function (a, idx) {
- var frame = response.frames[a];
+ let frame = response.frames[a];
if (frame && frame.functionDisplayName === "allocator") {
return idx;
}
+ return null;
})
.filter(function (idx) {
- return idx !== undefined;
+ return idx !== null;
});
- is(allocatorIndices.length, 3, "Should have our 3 allocations from the `allocator` timeouts.");
+ is(allocatorIndices.length, 3,
+ "Should have our 3 allocations from the `allocator` timeouts.");
- var lastTimestamp;
- for (var i = 0; i < 3; i++) {
- var timestamp = response.allocationsTimestamps[allocatorIndices[i]];
+ let lastTimestamp;
+ for (let i = 0; i < 3; i++) {
+ let timestamp = response.allocationsTimestamps[allocatorIndices[i]];
info("timestamp", timestamp);
ok(timestamp, "We should have a timestamp for the `allocator` allocation.");
if (lastTimestamp) {
- var delta = timestamp - lastTimestamp;
+ let delta = timestamp - lastTimestamp;
info("delta since last timestamp", delta);
- ok(delta >= 1 /* ms */,
+ // ms
+ ok(delta >= 1,
"The timestamp should be about 1 ms after the last timestamp.");
}
lastTimestamp = timestamp;
}
yield memory.detach();
destroyServerAndFinish(client);
--- a/devtools/server/tests/mochitest/test_memory_allocations_06.html
+++ b/devtools/server/tests/mochitest/test_memory_allocations_06.html
@@ -8,37 +8,39 @@ Bug 1132764 - Test controlling the maxim
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
- var allocs = [];
+ let allocs = [];
function allocator() {
- allocs.push(new Object);
+ allocs.push(new Object());
}
yield memory.startRecordingAllocations({
maxLogLength: 1
});
allocator();
allocator();
allocator();
- var response = yield memory.getAllocations();
+ let response = yield memory.getAllocations();
yield memory.stopRecordingAllocations();
is(response.allocations.length, 1,
"There should only be one entry in the allocations log.");
yield memory.detach();
destroyServerAndFinish(client);
});
--- a/devtools/server/tests/mochitest/test_memory_allocations_07.html
+++ b/devtools/server/tests/mochitest/test_memory_allocations_07.html
@@ -8,48 +8,51 @@ Bug 1192335 - Test getting the byte size
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
- var allocs = [];
+ let allocs = [];
function allocator() {
- allocs.push(new Object);
+ allocs.push(new Object());
}
yield memory.startRecordingAllocations();
allocator();
allocator();
allocator();
- var response = yield memory.getAllocations();
+ let response = yield memory.getAllocations();
yield memory.stopRecordingAllocations();
ok(response.allocationSizes, "The response should have bytesizes.");
is(response.allocationSizes.length, response.allocations.length,
"There should be a bytesize for every allocation.");
ok(response.allocationSizes.length >= 3,
"There are atleast 3 allocations.");
- ok(response.allocationSizes.every(isPositiveNumber), "every bytesize is a positive number");
+ ok(response.allocationSizes.every(isPositiveNumber),
+ "every bytesize is a positive number");
yield memory.detach();
destroyServerAndFinish(client);
});
};
-function isPositiveNumber (n) {
+function isPositiveNumber(n) {
return typeof n === "number" && n > 0;
}
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_memory_attach_01.html
+++ b/devtools/server/tests/mochitest/test_memory_attach_01.html
@@ -8,24 +8,26 @@ Bug 960671 - Test attaching and detachin
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
ok(true, "Shouldn't have gotten an error attaching.");
yield memory.detach();
ok(true, "Shouldn't have gotten an error detaching.");
- destroyServerAndFinish(client);
+ destroyServerAndFinish(client);
});
};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_memory_attach_02.html
+++ b/devtools/server/tests/mochitest/test_memory_attach_02.html
@@ -8,38 +8,38 @@ Bug 960671 - Test attaching and detachin
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
- var e = null;
+ let e = null;
try {
yield memory.detach();
- }
- catch (ee) {
+ } catch (ee) {
e = ee;
}
ok(e, "Should have hit the wrongState error");
yield memory.attach();
e = null;
try {
yield memory.attach();
- }
- catch (ee) {
+ } catch (ee) {
e = ee;
}
ok(e, "Should have hit the wrongState error");
yield memory.detach();
destroyServerAndFinish(client);
});
};
--- a/devtools/server/tests/mochitest/test_memory_census.html
+++ b/devtools/server/tests/mochitest/test_memory_census.html
@@ -8,24 +8,26 @@ Bug 1067491 - Test taking a census over
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
- var census = yield memory.takeCensus();
+ let census = yield memory.takeCensus();
is(typeof census, "object");
yield memory.detach();
destroyServerAndFinish(client);
});
};
</script>
</pre>
--- a/devtools/server/tests/mochitest/test_memory_gc_01.html
+++ b/devtools/server/tests/mochitest/test_memory_gc_01.html
@@ -8,37 +8,41 @@ Bug 1067491 - Test forcing a gc.
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
+
+ let beforeGC, afterGC;
do {
- var objects = [];
- for (var i = 0; i < 1000; i++) {
- var o = {};
+ let objects = [];
+ for (let i = 0; i < 1000; i++) {
+ let o = {};
o[Math.random()] = 1;
objects.push(o);
}
-
objects = null;
- var { total: beforeGC } = yield memory.measure();
+ yield { total: beforeGC } = memory.measure();
yield memory.forceGarbageCollection();
- var { total: afterGC } = yield memory.measure();
- } while(beforeGC < afterGC);
+
+ yield { total: afterGC } = memory.measure();
+ } while (beforeGC < afterGC);
ok(true, "The amount of memory after GC should eventually decrease");
destroyServerAndFinish(client);
});
};
</script>
</pre>
--- a/devtools/server/tests/mochitest/test_memory_gc_events.html
+++ b/devtools/server/tests/mochitest/test_memory_gc_events.html
@@ -8,26 +8,28 @@ Bug 1137527 - Test receiving GC events f
<title>Memory monitoring actor test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script src="memory-helpers.js" type="application/javascript"></script>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var event = require("sdk/event/core");
+ let event = require("sdk/event/core");
Task.spawn(function* () {
- var { memory, client } = yield startServerAndGetSelectedTabMemory();
+ let { memory, client } = yield startServerAndGetSelectedTabMemory();
yield memory.attach();
- var gotGcEvent = new Promise(resolve => {
+ let gotGcEvent = new Promise(resolve => {
event.on(memory, "garbage-collection", gcData => {
ok(gcData, "Got GC data");
resolve();
});
});
memory.forceGarbageCollection();
yield gotGcEvent;
--- a/devtools/server/tests/mochitest/test_preference.html
+++ b/devtools/server/tests/mochitest/test_preference.html
@@ -7,109 +7,114 @@ Bug 943251 - Allow accessing about:confi
<meta charset="utf-8">
<title>Test Preference Actor</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
function runTests() {
- var Cu = Components.utils;
- var Cc = Components.classes;
- var Ci = Components.interfaces;
+ let Cu = Components.utils;
+ let Ci = Components.interfaces;
- var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- var {DebuggerClient} = require("devtools/shared/client/main");
- var {DebuggerServer} = require("devtools/server/main");
- var Services = require("Services");
+ let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+ let {DebuggerClient} = require("devtools/shared/client/main");
+ let {DebuggerServer} = require("devtools/server/main");
+ let Services = require("Services");
SimpleTest.waitForExplicitFinish();
- var {getPreferenceFront} = require("devtools/shared/fronts/preference");
+ let {getPreferenceFront} = require("devtools/shared/fronts/preference");
DebuggerServer.init();
DebuggerServer.addBrowserActors();
- var client = new DebuggerClient(DebuggerServer.connectPipe());
+ let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() {
- client.listTabs(function onListTabs(aResponse) {
- var p = getPreferenceFront(client, aResponse);
+ client.listTabs(function onListTabs(response) {
+ let p = getPreferenceFront(client, response);
- var prefs = {};
+ let prefs = {};
- var localPref = {
+ let localPref = {
boolPref: true,
intPref: 0x1234,
charPref: "Hello World",
};
-
function checkValues() {
is(prefs.boolPref, localPref.boolPref, "read/write bool pref");
is(prefs.intPref, localPref.intPref, "read/write int pref");
is(prefs.charPref, localPref.charPref, "read/write string pref");
- ["test.all.bool", "test.all.int", "test.all.string"].forEach(function(key) {
- var expectedValue;
- switch(Services.prefs.getPrefType(key)) {
+ ["test.all.bool", "test.all.int", "test.all.string"].forEach(function (key) {
+ let expectedValue;
+ switch (Services.prefs.getPrefType(key)) {
case Ci.nsIPrefBranch.PREF_STRING:
expectedValue = Services.prefs.getCharPref(key);
break;
case Ci.nsIPrefBranch.PREF_INT:
expectedValue = Services.prefs.getIntPref(key);
break;
case Ci.nsIPrefBranch.PREF_BOOL:
expectedValue = Services.prefs.getBoolPref(key);
break;
default:
ok(false, "unexpected pref type (" + key + ")");
break;
}
- is(prefs.allPrefs[key].value, expectedValue, "valid preference value (" + key + ")");
- is(prefs.allPrefs[key].hasUserValue, Services.prefs.prefHasUserValue(key), "valid hasUserValue (" + key + ")");
+ is(prefs.allPrefs[key].value, expectedValue,
+ "valid preference value (" + key + ")");
+ is(prefs.allPrefs[key].hasUserValue, Services.prefs.prefHasUserValue(key),
+ "valid hasUserValue (" + key + ")");
});
- ["test.bool", "test.int", "test.string"].forEach(function(key) {
+ ["test.bool", "test.int", "test.string"].forEach(function (key) {
ok(!prefs.allPrefs.hasOwnProperty(key), "expect no pref (" + key + ")");
- is(Services.prefs.getPrefType(key), Ci.nsIPrefBranch.PREF_INVALID, "pref (" + key + ") is clear");
+ is(Services.prefs.getPrefType(key), Ci.nsIPrefBranch.PREF_INVALID,
+ "pref (" + key + ") is clear");
});
client.close().then(() => {
DebuggerServer.destroy();
- SimpleTest.finish()
+ SimpleTest.finish();
});
}
+ function updatePrefsProperty(key) {
+ return function (value) {
+ prefs[key] = value;
+ };
+ }
- p.getAllPrefs().then((json) => prefs["allPrefs"] = json)
+ p.getAllPrefs().then(updatePrefsProperty("allPrefs"))
.then(() => p.setBoolPref("test.bool", localPref.boolPref))
.then(() => p.setIntPref("test.int", localPref.intPref))
.then(() => p.setCharPref("test.string", localPref.charPref))
- .then(() => p.getBoolPref("test.bool")).then((value) => prefs["boolPref"] = value)
- .then(() => p.getIntPref("test.int")).then((value) => prefs["intPref"] = value)
- .then(() => p.getCharPref("test.string")).then((value) => prefs["charPref"] = value)
+ .then(() => p.getBoolPref("test.bool")).then(updatePrefsProperty("boolPref"))
+ .then(() => p.getIntPref("test.int")).then(updatePrefsProperty("intPref"))
+ .then(() => p.getCharPref("test.string")).then(updatePrefsProperty("charPref"))
.then(() => p.clearUserPref("test.bool"))
.then(() => p.clearUserPref("test.int"))
.then(() => p.clearUserPref("test.string"))
.then(checkValues);
-
});
});
-
}
window.onload = function () {
SpecialPowers.pushPrefEnv({
"set": [
["devtools.debugger.forbid-certified-apps", false],
["test.all.bool", true],
["test.all.int", 0x4321],
["test.all.string", "allizom"],
]
}, runTests);
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_setupInParentChild.html
+++ b/devtools/server/tests/mochitest/test_setupInParentChild.html
@@ -7,46 +7,45 @@ Bug 1181100 - Test DebuggerServerConnect
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script type="application/javascript">
+"use strict";
let Cu = Components.utils;
let Cc = Components.classes;
let Ci = Components.interfaces;
let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
let {DebuggerClient} = require("devtools/shared/client/main");
let {DebuggerServer} = require("devtools/server/main");
let Services = require("Services");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [
// Always log packets when running tests.
["devtools.debugger.log", true],
["dom.mozBrowserFramesEnabled", true]
]
}, runTests);
-}
+};
function runTests() {
// Create a minimal iframe with a message manager
let iframe = document.createElement("iframe");
iframe.mozbrowser = true;
document.body.appendChild(iframe);
- let mm = iframe.frameLoader.messageManager;
-
// Instantiate a minimal server
if (!DebuggerServer.initialized) {
DebuggerServer.init();
}
if (!DebuggerServer.createRootActor) {
DebuggerServer.addBrowserActors();
}
@@ -71,17 +70,17 @@ function runTests() {
module: "chrome://mochitests/content/chrome/devtools/server/tests/mochitest/setup-in-child.js",
setupChild: "callParent"
});
};
ppmm.addMessageListener("test:setupChild", onChild);
// Wait also for a reponse from setupInParent called from setup-in-child.js
let onParent = (_, topic, args) => {
- Services.obs.removeObserver(onParent, "test:setupParent", false);
+ Services.obs.removeObserver(onParent, "test:setupParent");
args = JSON.parse(args);
is(args[0], true, "Got `mm` argument, a message manager");
ok(args[1].match(/server\d+.conn\d+.child\d+/), "Got `prefix` argument");
cleanup();
};
Services.obs.addObserver(onParent, "test:setupParent", false);
@@ -94,17 +93,16 @@ function runTests() {
args: [1, "two", {three: true}]
});
});
function cleanup() {
client.close().then(function () {
DebuggerServer.destroy();
iframe.remove();
- SimpleTest.finish()
+ SimpleTest.finish();
});
}
-
}
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_styles-applied.html
+++ b/devtools/server/tests/mochitest/test_styles-applied.html
@@ -6,35 +6,33 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/server/actors/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gStyles = null;
-var gClient = null;
+let gWalker = null;
+let gStyles = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
return inspector.getPageStyle();
}).then(styles => {
gStyles = styles;
}).then(runNextTest));
});
});
@@ -45,33 +43,38 @@ addTest(function inheritedUserStyles() {
ok(!applied[0].inherited, "Entry 0 should be uninherited");
is(applied[0].rule.type, 100, "Entry 0 should be an element style");
ok(!!applied[0].rule.href, "Element styles should have a URL");
is(applied[0].rule.cssText, "", "Entry 0 should be an empty style");
is(applied[1].inherited.id, "uninheritable-rule-inheritable-style",
"Entry 1 should be inherited from the parent");
is(applied[1].rule.type, 100, "Entry 1 should be an element style");
- is(applied[1].rule.cssText, "color: red;", "Entry 1 should have the expected cssText");
+ is(applied[1].rule.cssText, "color: red;",
+ "Entry 1 should have the expected cssText");
is(applied[2].inherited.id, "inheritable-rule-inheritable-style",
"Entry 2 should be inherited from the parent's parent");
is(applied[2].rule.type, 100, "Entry 2 should be an element style");
- is(applied[2].rule.cssText, "color: blue;", "Entry 2 should have the expected cssText");
+ is(applied[2].rule.cssText, "color: blue;",
+ "Entry 2 should have the expected cssText");
is(applied[3].inherited.id, "inheritable-rule-inheritable-style",
"Entry 3 should be inherited from the parent's parent");
is(applied[3].rule.type, 1, "Entry 3 should be a rule style");
- is(applied[3].rule.cssText, "font-size: 15px;", "Entry 3 should have the expected cssText");
- ok(!applied[3].matchedSelectors, "Shouldn't get matchedSelectors with this request.");
+ is(applied[3].rule.cssText, "font-size: 15px;",
+ "Entry 3 should have the expected cssText");
+ ok(!applied[3].matchedSelectors,
+ "Shouldn't get matchedSelectors with this request.");
is(applied[4].inherited.id, "inheritable-rule-uninheritable-style",
"Entry 4 should be inherited from the parent's parent");
is(applied[4].rule.type, 1, "Entry 4 should be an rule style");
- is(applied[4].rule.cssText, "font-size: 15px;", "Entry 4 should have the expected cssText");
+ is(applied[4].rule.cssText, "font-size: 15px;",
+ "Entry 4 should have the expected cssText");
ok(!applied[4].matchedSelectors, "Shouldn't get matchedSelectors with this request.");
is(applied.length, 5, "Should have 5 rules.");
}).then(runNextTest));
});
addTest(function inheritedSystemStyles() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#test-node").then(node => {
@@ -101,37 +104,38 @@ addTest(function noInheritedStyles() {
});
addTest(function matchedSelectors() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#test-node").then(node => {
return gStyles.getApplied(node, {
inherited: true, filter: "user", matchedSelectors: true
});
}).then(applied => {
- is(applied[3].matchedSelectors[0], ".inheritable-rule", "Entry 3 should have a matched selector");
- is(applied[4].matchedSelectors[0], ".inheritable-rule", "Entry 4 should have a matched selector");
+ is(applied[3].matchedSelectors[0], ".inheritable-rule",
+ "Entry 3 should have a matched selector");
+ is(applied[4].matchedSelectors[0], ".inheritable-rule",
+ "Entry 4 should have a matched selector");
}).then(runNextTest));
});
addTest(function testMediaQuery() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#mediaqueried").then(node => {
return gStyles.getApplied(node, {
inherited: false, filter: "user", matchedSelectors: true
});
}).then(applied => {
is(applied[1].rule.type, 1, "Entry 1 is a rule style");
is(applied[1].rule.parentRule.type, 4, "Entry 1's parent rule is a media rule");
is(applied[1].rule.media[0], "screen", "Entry 1's rule has the expected medium");
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gStyles;
- delete gWalker;
- delete gClient;
+ gStyles = null;
+ gWalker = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_styles-computed.html
+++ b/devtools/server/tests/mochitest/test_styles-computed.html
@@ -6,126 +6,123 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/server/actors/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gStyles = null;
-var gClient = null;
+let gWalker = null;
+let gStyles = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
- gInspectee = doc;
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
return inspector.getPageStyle();
}).then(styles => {
gStyles = styles;
}).then(runNextTest));
});
});
addTest(function testComputed() {
- let localNode = gInspectee.querySelector("#computed-test-node");
- let elementStyle = null;
- promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
- return gStyles.getComputed(node, {});
- }).then(computed => {
- // Test a smattering of properties that include some system-defined
- // props, some props that were defined in this node's stylesheet,
- // and some default props.
- is(computed["white-space"].value, "normal", "Default value should appear");
- is(computed["display"].value, "block", "System stylesheet item should appear");
- is(computed["cursor"].value, "crosshair", "Included stylesheet rule should appear");
- is(computed["color"].value, "rgb(255, 0, 0)", "Inherited style attribute should appear");
- is(computed["font-size"].value, "15px", "Inherited inline rule should appear");
+ promiseDone(
+ gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
+ return gStyles.getComputed(node, {});
+ }).then(computed => {
+ // Test a smattering of properties that include some system-defined
+ // props, some props that were defined in this node's stylesheet,
+ // and some default props.
+ is(computed["white-space"].value, "normal", "Default value should appear");
+ is(computed.display.value, "block", "System stylesheet item should appear");
+ is(computed.cursor.value, "crosshair", "Included stylesheet rule should appear");
+ is(computed.color.value, "rgb(255, 0, 0)",
+ "Inherited style attribute should appear");
+ is(computed["font-size"].value, "15px", "Inherited inline rule should appear");
- // We didn't request markMatched, so these shouldn't be set
- ok(!computed["cursor"].matched, "Didn't ask for matched, shouldn't get it");
- ok(!computed["color"].matched, "Didn't ask for matched, shouldn't get it");
- ok(!computed["font-size"].matched, "Didn't ask for matched, shouldn't get it");
- }).then(runNextTest));
+ // We didn't request markMatched, so these shouldn't be set
+ ok(!computed.cursor.matched, "Didn't ask for matched, shouldn't get it");
+ ok(!computed.color.matched, "Didn't ask for matched, shouldn't get it");
+ ok(!computed["font-size"].matched, "Didn't ask for matched, shouldn't get it");
+ }).then(runNextTest)
+ );
});
addTest(function testComputedUserMatched() {
- let localNode = gInspectee.querySelector("#computed-test-node");
- let elementStyle = null;
- promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
- return gStyles.getComputed(node, { filter: "user", markMatched: true });
- }).then(computed => {
- ok(!computed["white-space"].matched, "Default style shouldn't match");
- ok(!computed["display"].matched, "Only user styles should match");
- ok(computed["cursor"].matched, "Asked for matched, should get it");
- ok(computed["color"].matched, "Asked for matched, should get it");
- ok(computed["font-size"].matched, "Asked for matched, should get it");
- }).then(runNextTest));
+ promiseDone(
+ gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
+ return gStyles.getComputed(node, { filter: "user", markMatched: true });
+ }).then(computed => {
+ ok(!computed["white-space"].matched, "Default style shouldn't match");
+ ok(!computed.display.matched, "Only user styles should match");
+ ok(computed.cursor.matched, "Asked for matched, should get it");
+ ok(computed.color.matched, "Asked for matched, should get it");
+ ok(computed["font-size"].matched, "Asked for matched, should get it");
+ }).then(runNextTest)
+ );
});
addTest(function testComputedSystemMatched() {
- let localNode = gInspectee.querySelector("#computed-test-node");
- let elementStyle = null;
- promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
- return gStyles.getComputed(node, { filter: "ua", markMatched: true });
- }).then(computed => {
- ok(!computed["white-space"].matched, "Default style shouldn't match");
- ok(computed["display"].matched, "System stylesheets should match");
- ok(computed["cursor"].matched, "Asked for matched, should get it");
- ok(computed["color"].matched, "Asked for matched, should get it");
- ok(computed["font-size"].matched, "Asked for matched, should get it");
- }).then(runNextTest));
+ promiseDone(
+ gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
+ return gStyles.getComputed(node, { filter: "ua", markMatched: true });
+ }).then(computed => {
+ ok(!computed["white-space"].matched, "Default style shouldn't match");
+ ok(computed.display.matched, "System stylesheets should match");
+ ok(computed.cursor.matched, "Asked for matched, should get it");
+ ok(computed.color.matched, "Asked for matched, should get it");
+ ok(computed["font-size"].matched, "Asked for matched, should get it");
+ }).then(runNextTest)
+ );
});
addTest(function testComputedUserOnlyMatched() {
- let localNode = gInspectee.querySelector("#computed-test-node");
- let elementStyle = null;
- promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
- return gStyles.getComputed(node, { filter: "user", onlyMatched: true });
- }).then(computed => {
- ok(!("white-space" in computed), "Default style shouldn't exist");
- ok(!("display" in computed), "System stylesheets shouldn't exist");
- ok(("cursor" in computed), "User items should exist.");
- ok(("color" in computed), "User items should exist.");
- ok(("font-size" in computed), "User items should exist.");
- }).then(runNextTest));
+ promiseDone(
+ gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
+ return gStyles.getComputed(node, { filter: "user", onlyMatched: true });
+ }).then(computed => {
+ ok(!("white-space" in computed), "Default style shouldn't exist");
+ ok(!("display" in computed), "System stylesheets shouldn't exist");
+ ok(("cursor" in computed), "User items should exist.");
+ ok(("color" in computed), "User items should exist.");
+ ok(("font-size" in computed), "User items should exist.");
+ }).then(runNextTest)
+ );
});
addTest(function testComputedSystemOnlyMatched() {
- let localNode = gInspectee.querySelector("#computed-test-node");
- let elementStyle = null;
- promiseDone(gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
- return gStyles.getComputed(node, { filter: "ua", onlyMatched: true });
- }).then(computed => {
- ok(!("white-space" in computed), "Default style shouldn't exist");
- ok(("display" in computed), "System stylesheets should exist");
- ok(("cursor" in computed), "User items should exist.");
- ok(("color" in computed), "User items should exist.");
- ok(("font-size" in computed), "User items should exist.");
- }).then(runNextTest));
+ promiseDone(
+ gWalker.querySelector(gWalker.rootNode, "#computed-test-node").then(node => {
+ return gStyles.getComputed(node, { filter: "ua", onlyMatched: true });
+ }).then(computed => {
+ ok(!("white-space" in computed), "Default style shouldn't exist");
+ ok(("display" in computed), "System stylesheets should exist");
+ ok(("cursor" in computed), "User items should exist.");
+ ok(("color" in computed), "User items should exist.");
+ ok(("font-size" in computed), "User items should exist.");
+ }).then(runNextTest)
+ );
});
addTest(function cleanup() {
- delete gStyles;
- delete gWalker;
- delete gClient;
+ gStyles = null;
+ gWalker = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_styles-layout.html
+++ b/devtools/server/tests/mochitest/test_styles-layout.html
@@ -4,45 +4,45 @@
<meta charset="utf-8">
<title>Test for Bug 1175040 - PageStyleActor.getLayout</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
};
let gWalker = null;
let gStyles = null;
-addTest(function() {
+addTest(function () {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
gWalker = walker;
return inspector.getPageStyle();
}).then(styles => {
gStyles = styles;
}).then(runNextTest));
});
});
-addTest(function() {
+addTest(function () {
ok(gStyles.getLayout, "The PageStyleActor has a getLayout method");
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
let node = yield gWalker.querySelector(gWalker.rootNode, "#layout-element");
let layout = yield gStyles.getLayout(node, {});
let properties = ["width", "height",
"margin-top", "margin-right", "margin-bottom",
"margin-left", "padding-top", "padding-right",
"padding-bottom", "padding-left", "border-top-width",
"border-right-width", "border-bottom-width",
@@ -50,17 +50,17 @@ addAsyncTest(function*() {
"position"];
for (let prop of properties) {
ok((prop in layout), "The layout object returned has " + prop);
}
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
let node = yield gWalker.querySelector(gWalker.rootNode, "#layout-element");
let layout = yield gStyles.getLayout(node, {});
let expected = {
"box-sizing": "border-box",
"position": "absolute",
"z-index": "2",
"display": "block",
@@ -74,17 +74,17 @@ addAsyncTest(function*() {
for (let name in expected) {
is(layout[name], expected[name], "The " + name + " property is correct");
}
runNextTest();
});
-addAsyncTest(function*() {
+addAsyncTest(function* () {
let node = yield gWalker.querySelector(gWalker.rootNode,
"#layout-auto-margin-element");
let layout = yield gStyles.getLayout(node, {});
ok(!("autoMargins" in layout),
"By default, getLayout doesn't return auto margins");
layout = yield gStyles.getLayout(node, {autoMargins: true});
@@ -93,17 +93,17 @@ addAsyncTest(function*() {
is(layout.autoMargins.left, "auto", "The left margin is auto");
is(layout.autoMargins.right, "auto", "The right margin is auto");
ok(!layout.autoMargins.bottom, "The bottom margin is not auto");
ok(!layout.autoMargins.top, "The top margin is not auto");
runNextTest();
});
-addTest(function() {
+addTest(function () {
gStyles = gWalker = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1175040">Mozilla Bug 1175040</a>
--- a/devtools/server/tests/mochitest/test_styles-matched.html
+++ b/devtools/server/tests/mochitest/test_styles-matched.html
@@ -6,63 +6,68 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/server/actors/inspector");
+"use strict";
+
const CssLogic = require("devtools/shared/inspector/css-logic");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gStyles = null;
-var gClient = null;
+let gWalker = null;
+let gStyles = null;
+let gInspectee = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
return inspector.getPageStyle();
}).then(styles => {
gStyles = styles;
}).then(runNextTest));
});
});
addTest(function testMatchedStyles() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#matched-test-node").then(node => {
return gStyles.getMatchedSelectors(node, "font-size", {});
}).then(matched => {
is(matched[0].sourceText, "this.style", "First match comes from the element style");
is(matched[0].selector, "@element.style", "Element style has a special selector");
is(matched[0].value, "10px", "First match has the expected value");
- is(matched[0].status, CssLogic.STATUS.BEST, "First match is the best match")
+ is(matched[0].status, CssLogic.STATUS.BEST, "First match is the best match");
is(matched[0].rule.type, 100, "First match is an element style");
- is(matched[0].rule.href, gInspectee.defaultView.location.href, "Node style comes from this document")
+ is(matched[0].rule.href, gInspectee.defaultView.location.href,
+ "Node style comes from this document");
is(matched[1].sourceText, ".inheritable-rule", "Second match comes from a rule");
is(matched[1].selector, ".inheritable-rule", "Second style has a selector");
is(matched[1].value, "15px", "Second match has the expected value");
- is(matched[1].status, CssLogic.STATUS.PARENT_MATCH, "Second match is from the parent")
- is(matched[1].rule.parentStyleSheet.href, null, "Inline stylesheet shouldn't have an href");
- is(matched[1].rule.parentStyleSheet.nodeHref, gInspectee.defaultView.location.href, "Inline stylesheet's nodeHref should match the current document");
- ok(!matched[1].rule.parentStyleSheet.system, "Inline stylesheet shouldn't be a system stylesheet.");
+ is(matched[1].status, CssLogic.STATUS.PARENT_MATCH,
+ "Second match is from the parent");
+ is(matched[1].rule.parentStyleSheet.href, null,
+ "Inline stylesheet shouldn't have an href");
+ is(matched[1].rule.parentStyleSheet.nodeHref, gInspectee.defaultView.location.href,
+ "Inline stylesheet's nodeHref should match the current document");
+ ok(!matched[1].rule.parentStyleSheet.system,
+ "Inline stylesheet shouldn't be a system stylesheet.");
}).then(runNextTest));
});
addTest(function testSystemStyles() {
let testNode = null;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#matched-test-node").then(node => {
testNode = node;
@@ -72,19 +77,19 @@ addTest(function testSystemStyles() {
return gStyles.getMatchedSelectors(testNode, "display", { filter: "ua" });
}).then(matched => {
is(matched[0].selector, "div", "Should match system div selector");
is(matched[0].value, "block");
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gStyles;
- delete gWalker;
- delete gClient;
+ gStyles = null;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_styles-modify.html
+++ b/devtools/server/tests/mochitest/test_styles-modify.html
@@ -6,36 +6,36 @@ https://bugzilla.mozilla.org/show_bug.cg
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/server/actors/inspector");
+"use strict";
+
const {isCssPropertyKnown} = require("devtools/server/actors/css-properties");
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
var gWalker = null;
var gStyles = null;
-var gClient = null;
+var gInspectee = null;
addAsyncTest(function* setup() {
let url = document.getElementById("inspectorContent").href;
let inspector;
yield new Promise(resolve => {
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
gInspectee = doc;
- gClient = client;
let {InspectorFront} = require("devtools/shared/fronts/inspector");
inspector = InspectorFront(client, tab);
resolve();
});
});
gWalker = yield inspector.getWalker();
gStyles = yield inspector.getPageStyle();
@@ -90,19 +90,19 @@ function* setProperty(rule, index, name,
function* removeProperty(rule, index, name) {
let changes = rule.startModifyingProperties(isCssPropertyKnown);
changes.removeProperty(index, name);
yield changes.apply();
}
addTest(function cleanup() {
- delete gStyles;
- delete gWalker;
- delete gClient;
+ gStyles = null;
+ gWalker = null;
+ gInspectee = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_styles-svg.html
+++ b/devtools/server/tests/mochitest/test_styles-svg.html
@@ -7,35 +7,33 @@ Bug 921191 - allow inspection/editing of
<head>
<meta charset="utf-8">
<title>Test for Bug </title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript" src="inspector-helpers.js"></script>
<script type="application/javascript">
-const inspector = require("devtools/server/actors/inspector");
+"use strict";
-window.onload = function() {
+window.onload = function () {
SimpleTest.waitForExplicitFinish();
runNextTest();
-}
+};
-var gWalker = null;
-var gStyles = null;
-var gClient = null;
+let gWalker = null;
+let gStyles = null;
addTest(function setup() {
let url = document.getElementById("inspectorContent").href;
- attachURL(url, function(err, client, tab, doc) {
+ attachURL(url, function (err, client, tab, doc) {
let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor.");
- gClient = client;
gWalker = walker;
return inspector.getPageStyle();
}).then(styles => {
gStyles = styles;
}).then(runNextTest));
});
});
@@ -44,19 +42,18 @@ addTest(function inheritedUserStyles() {
return gStyles.getApplied(node, { inherited: true, filter: "user" });
}).then(applied => {
is(applied.length, 2, "Should have 2 rules");
is(applied[1].rule.cssText, "fill: rgb(1, 2, 3);", "cssText is right");
}).then(runNextTest));
});
addTest(function cleanup() {
- delete gStyles;
- delete gWalker;
- delete gClient;
+ gStyles = null;
+ gWalker = null;
runNextTest();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=921191">Mozilla Bug 921191</a>
<a id="inspectorContent" target="_blank" href="inspector-styles-data.html">Test Document</a>
--- a/devtools/server/tests/mochitest/test_unsafeDereference.html
+++ b/devtools/server/tests/mochitest/test_unsafeDereference.html
@@ -11,42 +11,43 @@ xray wrapper.
<meta charset="utf-8">
<title>Mozilla Bug 837723</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
+"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
window.onload = function () {
SimpleTest.waitForExplicitFinish();
- var iframe = document.createElement("iframe");
+ let iframe = document.createElement("iframe");
iframe.src = "http://mochi.test:8888/chrome/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html";
iframe.onload = function () {
- var dbg = new Debugger;
- var contentDO = dbg.addDebuggee(iframe.contentWindow);
- var xhrDesc = contentDO.getOwnPropertyDescriptor('xhr');
+ let dbg = new Debugger();
+ let contentDO = dbg.addDebuggee(iframe.contentWindow);
+ let xhrDesc = contentDO.getOwnPropertyDescriptor("xhr");
isnot(xhrDesc, undefined, "xhr should be visible as property of content global");
isnot(xhrDesc.value, undefined, "xhr should have a value");
- var xhr = xhrDesc.value.unsafeDereference();
+ let xhr = xhrDesc.value.unsafeDereference();
is(typeof xhr, "object", "we should be able to deference xhr's value's D.O");
is(xhr.timeout, 1742, "chrome should see the xhr's 'timeout' property");
is(xhr.expando, undefined, "chrome should not see the xhr's 'expando' property");
SimpleTest.finish();
- }
+ };
document.body.appendChild(iframe);
-}
+};
</script>
</pre>
</body>
</html>
--- a/devtools/server/tests/mochitest/test_websocket-server.html
+++ b/devtools/server/tests/mochitest/test_websocket-server.html
@@ -4,17 +4,19 @@
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
const { Constructor: CC, utils: Cu } = Components;
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const { Task } = require("devtools/shared/task");
const WebSocketServer = require("devtools/server/websocket-server");
const ServerSocket = CC("@mozilla.org/network/server-socket;1",
"nsIServerSocket", "init");
@@ -71,12 +73,12 @@ window.onload = function() {
});
is(echoedMessage, message, "Echoed message matches");
// Close the connection
client.close();
yield closed;
});
-}
+};
</script>
</body>
</html>