зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325988 - Fix ESLint issues in devtools/server/tests/mochitest/ r=tromey
MozReview-Commit-ID: BFaOv5i5Tun --HG-- extra : rebase_source : 5c2b5d1867eb5b48c56725b87d71dae72a83eb34
This commit is contained in:
Родитель
33a9e6d050
Коммит
7b53fcdbb6
|
@ -134,7 +134,6 @@ 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/platform/content/test/test_clipboard.html
|
||||
devtools/shared/qrcode/tests/mochitest/test_decode.html
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
"use strict";
|
||||
|
||||
// eslint-disable-next-line no-debugger
|
||||
debugger;
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<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>
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
function heinrichFun() { franz(); }
|
||||
/* exported heinrichFun */
|
||||
"use strict";
|
||||
|
||||
function heinrichFun() {
|
||||
franz();
|
||||
}
|
||||
|
|
|
@ -101,8 +101,10 @@
|
|||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
window.opener.postMessage('ready', '*');
|
||||
"use strict";
|
||||
|
||||
window.onload = function () {
|
||||
window.opener.postMessage("ready", "*");
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
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");
|
||||
|
@ -25,12 +29,12 @@ const { Task } = require("devtools/shared/task");
|
|||
**********************************/
|
||||
|
||||
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,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/* 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");
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
window.opener.postMessage('ready', '*');
|
||||
"use strict";
|
||||
|
||||
window.onload = function () {
|
||||
window.opener.postMessage("ready", "*");
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* 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", {});
|
||||
|
@ -15,7 +21,6 @@ SimpleTest.registerCleanupFunction(function () {
|
|||
Services.prefs.clearUserPref("devtools.debugger.log");
|
||||
});
|
||||
|
||||
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.addBrowserActors();
|
||||
|
@ -40,8 +45,8 @@ SimpleTest.registerCleanupFunction(function () {
|
|||
* 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) {
|
||||
|
@ -63,7 +68,8 @@ function attachURL(url, callback) {
|
|||
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) {
|
||||
|
@ -125,15 +131,18 @@ function serverOwnershipTree(walker) {
|
|||
|
||||
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)))
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -156,7 +165,8 @@ function ownershipTreeSize(tree) {
|
|||
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);
|
||||
}
|
||||
|
@ -189,14 +199,15 @@ function checkAvailable(client, actorID) {
|
|||
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);
|
||||
|
@ -207,10 +218,6 @@ function promiseDone(promise) {
|
|||
|
||||
// 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);
|
||||
|
@ -245,7 +252,8 @@ function isNewRoot(change) {
|
|||
// 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
|
||||
|
@ -285,7 +293,6 @@ function waitForMutation(walker, test, mutations = []) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
var _tests = [];
|
||||
function addTest(test) {
|
||||
_tests.push(test);
|
||||
|
@ -300,7 +307,7 @@ function runNextTest() {
|
|||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
var fn = _tests.shift();
|
||||
let fn = _tests.shift();
|
||||
try {
|
||||
fn();
|
||||
} catch (ex) {
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
window.opener.postMessage('ready', '*');
|
||||
"use strict";
|
||||
|
||||
window.onload = function () {
|
||||
window.opener.postMessage("ready", "*");
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<html>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
window.onload = () => {
|
||||
window.opener.postMessage('ready', '*')
|
||||
}
|
||||
window.opener.postMessage("ready", "*");
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.inheritable-rule {
|
||||
|
|
|
@ -18,26 +18,27 @@
|
|||
}
|
||||
</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">
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
<head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
window.opener.postMessage('ready', '*');
|
||||
"use strict";
|
||||
|
||||
window.onload = function () {
|
||||
window.opener.postMessage("ready", "*");
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<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;
|
||||
|
@ -14,8 +16,8 @@
|
|||
ctx.fillStyle = "red";
|
||||
ctx.fillRect(0, 0, 1000, 2000);
|
||||
|
||||
window.opener.postMessage('ready', '*')
|
||||
}
|
||||
window.opener.postMessage("ready", "*");
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
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);
|
||||
|
@ -19,13 +21,13 @@ SimpleTest.registerCleanupFunction(function () {
|
|||
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 };
|
||||
});
|
||||
|
@ -48,5 +50,6 @@ 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));
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"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) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
var {Ci} = require("chrome");
|
||||
var Services = require("Services");
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ Debugger.Script.prototype.global should return innerize globals, not WindowProxi
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
@ -21,27 +22,26 @@ 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>
|
||||
|
|
|
@ -15,6 +15,7 @@ element to which code is attached (if any), and how.
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
@ -22,65 +23,65 @@ 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),
|
||||
|
@ -89,23 +90,23 @@ window.onload = function () {
|
|||
"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,
|
||||
|
@ -114,20 +115,20 @@ window.onload = function () {
|
|||
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.
|
||||
|
@ -139,43 +140,42 @@ window.onload = function () {
|
|||
// 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>
|
||||
|
|
|
@ -15,6 +15,7 @@ behave when 'eval' is called with no scripted frames active at all.
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
@ -22,10 +23,10 @@ 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);
|
||||
|
@ -33,11 +34,11 @@ window.onload = function () {
|
|||
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);
|
||||
|
@ -46,7 +47,7 @@ window.onload = function () {
|
|||
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,
|
||||
|
@ -55,7 +56,7 @@ window.onload = function () {
|
|||
// 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;
|
||||
|
@ -65,10 +66,10 @@ window.onload = function () {
|
|||
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");
|
||||
|
@ -81,7 +82,7 @@ window.onload = function () {
|
|||
// 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");
|
||||
|
@ -90,7 +91,7 @@ window.onload = function () {
|
|||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -16,13 +16,14 @@ JavaScrip appearing in an inline event handler attribute.
|
|||
<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();
|
||||
|
@ -31,7 +32,7 @@ window.onload = function () {
|
|||
|
||||
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>";
|
||||
|
@ -41,88 +42,84 @@ addTest(function setup() {
|
|||
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) {
|
||||
|
@ -133,17 +130,16 @@ addTest(function InsertRover() {
|
|||
"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'>" +
|
||||
|
@ -155,12 +151,10 @@ addTest(function XULDocumentScript() {
|
|||
|
||||
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
|
||||
|
@ -169,12 +163,11 @@ addTest(function XULDocumentScript() {
|
|||
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>
|
||||
|
|
|
@ -11,67 +11,65 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1247243
|
|||
<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");
|
||||
|
@ -79,7 +77,6 @@ window.onload = function() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
|
||||
runNextTest();
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<SDOCTYPv HTM.>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Bug 966991 - Test DebuggerServer.connectToChild
|
||||
|
@ -12,16 +12,16 @@ Bug 966991 - Test DebuggerServer.connectToChild
|
|||
<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({
|
||||
|
@ -31,7 +31,7 @@ window.onload = function() {
|
|||
["dom.mozBrowserFramesEnabled", true]
|
||||
]
|
||||
}, runTests);
|
||||
}
|
||||
};
|
||||
|
||||
function runTests() {
|
||||
// Create a minimal iframe with a message manager
|
||||
|
@ -44,14 +44,18 @@ function runTests() {
|
|||
// 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",
|
||||
|
||||
|
@ -59,7 +63,7 @@ function runTests() {
|
|||
sendAsyncMessage("test-actor-destroyed", null);
|
||||
},
|
||||
hello: function () {
|
||||
return {msg:"world"};
|
||||
return {msg: "world"};
|
||||
}
|
||||
};
|
||||
TestActor.prototype.requestTypes = {
|
||||
|
@ -90,7 +94,6 @@ function runTests() {
|
|||
to: actor.testActor,
|
||||
type: "hello",
|
||||
}, function (response) {
|
||||
|
||||
// Then close the client. That should end up cleaning our test actor
|
||||
client.close();
|
||||
|
||||
|
@ -113,7 +116,8 @@ function runTests() {
|
|||
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);
|
||||
});
|
||||
|
@ -122,12 +126,11 @@ function runTests() {
|
|||
function cleanup() {
|
||||
DebuggerServer.destroy();
|
||||
iframe.remove();
|
||||
SimpleTest.finish()
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
firstClient();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -12,70 +12,89 @@ Bug 898485 - [app manager] Implement an abstract connection manager
|
|||
<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();
|
||||
});
|
||||
|
@ -86,16 +105,17 @@ window.onload = function() {
|
|||
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();
|
||||
|
@ -106,13 +126,10 @@ window.onload = function() {
|
|||
DebuggerServer.destroy();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ConnectionManager.destroyConnection(c1);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -25,14 +25,15 @@ Test that css-logic handles media-queries correctly
|
|||
<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();
|
||||
|
@ -55,8 +56,7 @@ Test that css-logic handles media-queries correctly
|
|||
"rule.source gives correct output for rule 2");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -10,9 +10,10 @@ Test that css-logic calculates CSS specificity properly
|
|||
</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");
|
||||
|
@ -58,7 +59,7 @@ Test that css-logic calculates CSS specificity properly
|
|||
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);
|
||||
|
@ -66,7 +67,7 @@ Test that css-logic calculates CSS specificity properly
|
|||
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);
|
||||
}
|
||||
|
@ -77,8 +78,7 @@ Test that css-logic calculates CSS specificity properly
|
|||
"Element styles have specificity of 0x01000000 (16777216).");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -11,49 +11,51 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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();
|
||||
});
|
||||
|
|
|
@ -10,19 +10,21 @@ Bug 1265798 - Replace inIDOMUtils.cssPropertyIsShorthand
|
|||
<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) {
|
||||
|
@ -63,7 +65,7 @@ window.onload = function() {
|
|||
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"),
|
||||
|
@ -81,13 +83,13 @@ window.onload = function() {
|
|||
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"),
|
||||
|
@ -111,7 +113,7 @@ window.onload = function() {
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runNextTest();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -12,37 +12,38 @@ Bug 895360 - [app manager] Device meta data actor
|
|||
<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,
|
||||
|
@ -53,38 +54,38 @@ window.onload = function() {
|
|||
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>
|
||||
|
|
|
@ -14,43 +14,45 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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) {
|
||||
|
@ -70,30 +72,26 @@ function teardown() {
|
|||
}
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 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();
|
||||
|
@ -106,8 +104,6 @@ function runDirectorRegistryActorTest() {
|
|||
yield client.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -14,24 +14,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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();
|
||||
}
|
||||
|
||||
|
@ -43,7 +46,7 @@ function setup() {
|
|||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init(() => true);
|
||||
DebuggerServer.addBrowserActors();
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
SimpleTest.registerCleanupFunction(function () {
|
||||
DebuggerServer.destroy();
|
||||
});
|
||||
}
|
||||
|
@ -54,10 +57,6 @@ function teardown() {
|
|||
DebuggerServer.destroy();
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* test cases
|
||||
**********************************/
|
||||
|
||||
function runPropagateDirectorScriptsToChildTest() {
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.mozbrowser = true;
|
||||
|
@ -65,9 +64,9 @@ function runPropagateDirectorScriptsToChildTest() {
|
|||
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", {
|
||||
|
@ -75,19 +74,19 @@ function runPropagateDirectorScriptsToChildTest() {
|
|||
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();
|
||||
});
|
||||
|
|
|
@ -16,6 +16,7 @@ object.
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
@ -23,46 +24,49 @@ 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>
|
||||
|
|
|
@ -12,30 +12,29 @@ Bug 1007200 - Create a framerate actor
|
|||
<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.
|
||||
|
@ -45,19 +44,19 @@ window.onload = function() {
|
|||
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 });
|
||||
|
||||
|
@ -66,20 +65,21 @@ window.onload = function() {
|
|||
}
|
||||
|
||||
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 => {
|
||||
|
@ -87,6 +87,7 @@ window.onload = function() {
|
|||
});
|
||||
}, 1000);
|
||||
});
|
||||
/* eslint-enable max-nested-callbacks */
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
|
@ -94,15 +95,15 @@ window.onload = function() {
|
|||
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,
|
||||
|
@ -113,28 +114,24 @@ window.onload = function() {
|
|||
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>
|
||||
|
|
|
@ -12,30 +12,29 @@ Bug 1007200 - Create a framerate actor
|
|||
<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.
|
||||
|
@ -45,19 +44,19 @@ window.onload = function() {
|
|||
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 });
|
||||
|
||||
|
@ -66,24 +65,24 @@ window.onload = function() {
|
|||
}
|
||||
|
||||
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.");
|
||||
|
||||
|
@ -99,14 +98,15 @@ window.onload = function() {
|
|||
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>
|
||||
|
|
|
@ -12,47 +12,48 @@ Bug 1023018 - Tests whether or not the framerate actor can handle time ranges.
|
|||
<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 */
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -65,17 +66,17 @@ window.onload = function() {
|
|||
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>
|
||||
|
|
|
@ -13,26 +13,28 @@ Bug 1023018 - Tests if the framerate actor keeps recording after navigations.
|
|||
<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 => {
|
||||
|
@ -40,6 +42,7 @@ window.onload = function() {
|
|||
});
|
||||
}, 1000);
|
||||
});
|
||||
/* eslint-enable max-nested-callbacks */
|
||||
contentWin.location.reload();
|
||||
});
|
||||
}, 1000);
|
||||
|
@ -50,7 +53,7 @@ window.onload = function() {
|
|||
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.");
|
||||
|
||||
|
@ -61,10 +64,10 @@ window.onload = function() {
|
|||
|
||||
client.close().then(() => {
|
||||
DebuggerServer.destroy();
|
||||
SimpleTest.finish()
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
<a id="testContent" target="_blank" href="inspector_getImageData.html">Test Document</a>
|
||||
|
|
|
@ -12,37 +12,37 @@ Bug 1034648 - Tests whether a framerate recording can be cancelled.
|
|||
<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(() => {
|
||||
|
@ -60,17 +60,18 @@ window.onload = function() {
|
|||
|
||||
client.close().then(() => {
|
||||
DebuggerServer.destroy();
|
||||
SimpleTest.finish()
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
}, 1000);
|
||||
/* eslint-enable max-nested-callbacks */
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -13,34 +13,33 @@ Bug 1171489 - Tests if the framerate actor does not record timestamps from multi
|
|||
<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();
|
||||
|
@ -49,13 +48,13 @@ window.onload = function() {
|
|||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -64,17 +63,19 @@ window.onload = function() {
|
|||
// 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>
|
||||
|
|
|
@ -12,17 +12,16 @@ Bug 1060093 - Test DebuggerServer.getProcess
|
|||
<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({
|
||||
|
@ -35,7 +34,7 @@ window.onload = function() {
|
|||
["dom.ipc.processCount", 10],
|
||||
]
|
||||
}, runTests);
|
||||
}
|
||||
};
|
||||
|
||||
function runTests() {
|
||||
// Instantiate a minimal server
|
||||
|
@ -81,13 +80,13 @@ function runTests() {
|
|||
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");
|
||||
|
||||
|
@ -96,8 +95,8 @@ function runTests() {
|
|||
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);
|
||||
});
|
||||
|
@ -118,7 +117,7 @@ function runTests() {
|
|||
|
||||
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);
|
||||
|
@ -127,10 +126,10 @@ function runTests() {
|
|||
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);
|
||||
|
@ -147,7 +146,7 @@ function runTests() {
|
|||
function cleanup() {
|
||||
DebuggerServer.destroy();
|
||||
iframe.remove();
|
||||
SimpleTest.finish()
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
connect();
|
||||
|
|
|
@ -11,7 +11,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=777674
|
|||
<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} =
|
||||
|
@ -26,51 +28,50 @@ window.onload = function() {
|
|||
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(
|
||||
|
@ -78,108 +79,109 @@ window.onload = function() {
|
|||
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();
|
||||
});
|
||||
|
|
|
@ -11,31 +11,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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));
|
||||
});
|
||||
|
@ -56,34 +49,36 @@ addTest(function testChangeAttrs() {
|
|||
// 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>
|
||||
|
|
|
@ -11,31 +11,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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 Ci = Components.interfaces;
|
||||
const inspector = require("devtools/shared/fronts/inspector");
|
||||
"use strict";
|
||||
|
||||
window.onload = function() {
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
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));
|
||||
});
|
||||
|
@ -60,13 +55,10 @@ addTest(function testChangeValue() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gInspectee;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -11,20 +11,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1121528
|
|||
<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;
|
||||
|
@ -37,7 +38,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.parents(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -51,7 +52,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.children(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -65,7 +66,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.siblings(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -79,7 +80,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.nextSibling(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -93,7 +94,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.previousSibling(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -107,7 +108,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.addPseudoClassLock(nodeFront) before the load completes " +
|
||||
"shouldn't fail");
|
||||
|
@ -122,7 +123,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.removePseudoClassLock(nodeFront) before the load completes " +
|
||||
"shouldn't fail");
|
||||
|
@ -137,7 +138,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.clearPseudoClassLocks(nodeFront) before the load completes " +
|
||||
"shouldn't fail");
|
||||
|
@ -152,7 +153,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.innerHTML(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -166,7 +167,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.setInnerHTML(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -180,7 +181,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.outerHTML(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -194,7 +195,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.setOuterHTML(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -208,7 +209,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.insertAdjacentHTML(nodeFront) before the load completes shouldn't " +
|
||||
"fail");
|
||||
|
@ -224,7 +225,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.removeNode(nodeFront) before the load completes should throw");
|
||||
|
||||
|
@ -243,7 +244,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.removeNodes([nodeFront]) before the load completes should throw");
|
||||
|
||||
|
@ -264,7 +265,7 @@ addAsyncTest(function*() {
|
|||
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");
|
||||
|
@ -280,7 +281,7 @@ addAsyncTest(function*() {
|
|||
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");
|
||||
|
@ -297,7 +298,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.editTagName(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -311,7 +312,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.hideNode(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -325,7 +326,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.unhideNode(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -339,7 +340,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.releaseNode(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -353,7 +354,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Getting a nodeFront, reloading the page, and calling " +
|
||||
"walker.querySelector(nodeFront) before the load completes shouldn't fail");
|
||||
|
||||
|
@ -368,7 +369,8 @@ addAsyncTest(function*() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
gWalker = gDoc = null;
|
||||
gWalker = null;
|
||||
gDoc = null;
|
||||
runNextTest();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -11,30 +11,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1208864
|
|||
<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));
|
||||
});
|
||||
|
@ -55,9 +47,7 @@ addTest(Task.async(function* testDuplicateNode() {
|
|||
}));
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gInspectee;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -11,25 +11,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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));
|
||||
});
|
||||
|
@ -56,8 +55,8 @@ addTest(function testRearrange() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,29 +11,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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));
|
||||
});
|
||||
|
@ -47,9 +44,11 @@ addAsyncTest(function* testRearrange() {
|
|||
|
||||
// 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];
|
||||
|
@ -99,8 +98,8 @@ addAsyncTest(function* testInsertInvalidInput() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,28 +11,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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));
|
||||
});
|
||||
|
@ -50,14 +48,14 @@ 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 => {
|
||||
|
@ -77,8 +75,10 @@ function testAddAttribute() {
|
|||
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();
|
||||
});
|
||||
}
|
||||
|
@ -88,10 +88,13 @@ function testChangeAttribute() {
|
|||
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();
|
||||
});
|
||||
}
|
||||
|
@ -100,10 +103,11 @@ 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() {
|
||||
|
@ -115,7 +119,7 @@ function testQueuedMutations() {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -132,26 +136,27 @@ function testQueuedMutations() {
|
|||
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>
|
||||
|
|
|
@ -11,26 +11,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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));
|
||||
});
|
||||
|
@ -38,7 +36,6 @@ function setup(callback) {
|
|||
|
||||
function teardown() {
|
||||
gWalker = null;
|
||||
gClient = null;
|
||||
gInspectee = null;
|
||||
if (gCleanupConnection) {
|
||||
gCleanupConnection();
|
||||
|
@ -47,7 +44,7 @@ function teardown() {
|
|||
}
|
||||
|
||||
function assertOwnership() {
|
||||
let num = assertOwnershipTrees(gWalker);
|
||||
return assertOwnershipTrees(gWalker);
|
||||
}
|
||||
|
||||
function setParent(nodeSelector, newParentSelector) {
|
||||
|
@ -83,7 +80,7 @@ function doMoves(moves) {
|
|||
var gDummySerial = 0;
|
||||
|
||||
function mutationTest(testSpec) {
|
||||
return function() {
|
||||
return function () {
|
||||
setup(() => {
|
||||
promiseDone(loadSelectors(testSpec.load || ["html"]).then(() => {
|
||||
gWalker.autoCleanup = !!testSpec.autoCleanup;
|
||||
|
@ -99,6 +96,7 @@ function mutationTest(testSpec) {
|
|||
|
||||
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") {
|
||||
|
@ -114,14 +112,14 @@ function mutationTest(testSpec) {
|
|||
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.");
|
||||
}
|
||||
}));
|
||||
|
@ -134,17 +132,18 @@ addTest(mutationTest({
|
|||
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.");
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -155,13 +154,13 @@ addTest(mutationTest({
|
|||
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.");
|
||||
|
@ -177,7 +176,7 @@ addTest(mutationTest({
|
|||
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.");
|
||||
|
@ -196,7 +195,7 @@ addTest(mutationTest({
|
|||
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.");
|
||||
|
@ -211,7 +210,7 @@ addTest(mutationTest({
|
|||
moves: [
|
||||
["#longlist-sibling", "#longlist"]
|
||||
],
|
||||
postCheck: function(mutations) {
|
||||
postCheck: function (mutations) {
|
||||
is(mutations.length, 0, "Should generate no mutations.");
|
||||
}
|
||||
}));
|
||||
|
@ -223,14 +222,15 @@ addTest(mutationTest({
|
|||
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");
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -241,7 +241,7 @@ addTest(mutationTest({
|
|||
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.");
|
||||
|
@ -258,25 +258,27 @@ addTest(mutationTest({
|
|||
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.");
|
||||
|
@ -286,15 +288,11 @@ addTest(mutationTest({
|
|||
}
|
||||
}));
|
||||
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gInspectee;
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gInspectee = null;
|
||||
gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -10,9 +10,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1157469
|
|||
<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");
|
||||
|
@ -30,11 +30,11 @@ window.onload = function() {
|
|||
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();
|
||||
|
@ -48,8 +48,8 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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");
|
||||
|
@ -67,7 +67,8 @@ window.onload = function() {
|
|||
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");
|
||||
|
@ -77,10 +78,12 @@ window.onload = function() {
|
|||
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);
|
||||
|
@ -90,7 +93,8 @@ window.onload = function() {
|
|||
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();
|
||||
|
@ -108,12 +112,14 @@ window.onload = function() {
|
|||
// 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");
|
||||
|
@ -125,13 +131,17 @@ window.onload = function() {
|
|||
// 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();
|
||||
});
|
||||
|
@ -142,7 +152,7 @@ window.onload = function() {
|
|||
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();
|
||||
|
@ -153,9 +163,11 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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 => {
|
||||
|
@ -166,8 +178,7 @@ window.onload = function() {
|
|||
}
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -11,23 +11,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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);
|
||||
|
@ -42,7 +40,6 @@ function teardown() {
|
|||
gWalker = null;
|
||||
gClient = null;
|
||||
gInspectee = null;
|
||||
gChildFrame = null;
|
||||
if (gCleanupConnection) {
|
||||
gCleanupConnection();
|
||||
gCleanupConnection = null;
|
||||
|
@ -55,8 +52,8 @@ function assertOwnership() {
|
|||
|
||||
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);
|
||||
|
@ -76,7 +73,6 @@ function getUnloadedDoc(mutations) {
|
|||
|
||||
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");
|
||||
|
@ -102,7 +98,6 @@ addTest(function loadNewChild() {
|
|||
|
||||
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");
|
||||
|
@ -130,10 +125,8 @@ addTest(function loadNewChildTwice() {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
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");
|
||||
|
@ -168,7 +161,6 @@ addTest(function loadNewChildTwiceAndCareAboutIt() {
|
|||
|
||||
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");
|
||||
|
@ -178,7 +170,8 @@ addTest(function testBack() {
|
|||
// 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);
|
||||
|
|
|
@ -11,39 +11,38 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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));
|
||||
});
|
||||
|
@ -71,7 +70,7 @@ function setupValueTest() {
|
|||
}
|
||||
|
||||
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 => {
|
||||
|
@ -94,7 +93,7 @@ function checkNodeFrontValue(front, expectedValue) {
|
|||
return longstring.string();
|
||||
}).then(str => {
|
||||
is(str, expectedValue, "Node value is as expected");
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function testKeepLongValue() {
|
||||
|
@ -147,9 +146,8 @@ function testSetLongValue() {
|
|||
}
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gInspectee;
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gInspectee = null;
|
||||
gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -13,25 +13,23 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1262439
|
|||
<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", {});
|
||||
"use strict";
|
||||
|
||||
window.onload = function () {
|
||||
const {InspectorFront} = require("devtools/shared/fronts/inspector");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let win = null;
|
||||
let inspector = null;
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Setting up inspector actor");
|
||||
|
||||
let url = document.getElementById("inspectorContent").href;
|
||||
|
||||
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();
|
||||
|
@ -41,7 +39,7 @@ window.onload = function() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Start picking a color from the page");
|
||||
yield inspector.pickColorFromPage();
|
||||
|
||||
|
@ -55,7 +53,7 @@ window.onload = function() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Start picking a color from the page");
|
||||
yield inspector.pickColorFromPage();
|
||||
|
||||
|
@ -73,7 +71,7 @@ window.onload = function() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
info("Start picking a color from the page");
|
||||
yield inspector.pickColorFromPage();
|
||||
|
||||
|
|
|
@ -11,30 +11,29 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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));
|
||||
});
|
||||
|
@ -42,7 +41,6 @@ function setup(callback) {
|
|||
|
||||
function teardown() {
|
||||
gWalker = null;
|
||||
gClient = null;
|
||||
gInspectee = null;
|
||||
if (gCleanupConnection) {
|
||||
gCleanupConnection();
|
||||
|
@ -53,10 +51,13 @@ function teardown() {
|
|||
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.");
|
||||
|
@ -74,7 +75,8 @@ function checkChange(change, expectation) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +84,7 @@ function checkChange(change, expectation) {
|
|||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +96,7 @@ addTest(function testPseudoClassLock() {
|
|||
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 => {
|
||||
|
@ -107,50 +109,50 @@ addTest(function testPseudoClassLock() {
|
|||
});
|
||||
}).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);
|
||||
|
@ -170,7 +172,8 @@ addTest(function testPseudoClassLock() {
|
|||
// 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));
|
||||
});
|
||||
|
|
|
@ -11,15 +11,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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);
|
||||
|
@ -27,7 +27,7 @@ function assertOwnership() {
|
|||
|
||||
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 => {
|
||||
|
@ -45,7 +45,8 @@ addTest(function testReleaseSubtree() {
|
|||
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();
|
||||
|
@ -69,7 +70,8 @@ addTest(function testReleaseSubtree() {
|
|||
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");
|
||||
|
@ -81,12 +83,10 @@ addTest(function testReleaseSubtree() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
gClient = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -11,26 +11,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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 => {
|
||||
|
@ -41,7 +39,6 @@ addTest(function setup() {
|
|||
});
|
||||
|
||||
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 => {
|
||||
|
@ -58,13 +55,10 @@ addTest(function testReload() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gInspectee;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -11,15 +11,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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);
|
||||
|
@ -33,7 +34,7 @@ function ignoreNode(node) {
|
|||
|
||||
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);
|
||||
|
@ -80,8 +81,10 @@ addTest(function testRemoveSubtree() {
|
|||
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
|
||||
|
@ -96,12 +99,11 @@ addTest(function testRemoveSubtree() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
gClient = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -11,12 +11,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1222409
|
|||
<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();
|
||||
|
||||
|
@ -24,12 +25,13 @@ window.onload = function() {
|
|||
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();
|
||||
|
@ -39,7 +41,7 @@ window.onload = function() {
|
|||
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
|
||||
|
@ -47,6 +49,7 @@ window.onload = function() {
|
|||
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();
|
||||
|
|
|
@ -11,19 +11,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=921102
|
|||
<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);
|
||||
|
@ -31,7 +31,7 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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/" +
|
||||
|
@ -40,16 +40,16 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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 => {
|
||||
|
@ -59,18 +59,19 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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>
|
||||
|
|
|
@ -11,16 +11,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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);
|
||||
|
@ -28,13 +27,12 @@ function assertOwnership() {
|
|||
|
||||
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));
|
||||
});
|
||||
|
@ -50,7 +48,6 @@ addTest(function setup() {
|
|||
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 => {
|
||||
|
@ -60,7 +57,6 @@ addTest(function testRetain() {
|
|||
// 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];
|
||||
});
|
||||
|
@ -75,7 +71,6 @@ addTest(function testRetain() {
|
|||
// 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
|
||||
|
@ -84,26 +79,25 @@ addTest(function testRetain() {
|
|||
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));
|
||||
});
|
||||
|
||||
|
@ -123,14 +117,12 @@ addTest(function testWinRace() {
|
|||
]);
|
||||
}).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));
|
||||
});
|
||||
|
@ -149,19 +141,18 @@ addTest(function testLoseRace() {
|
|||
// 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();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,30 +11,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=901250
|
|||
<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));
|
||||
});
|
||||
|
@ -67,9 +61,8 @@ addTest(Task.async(function* testScrollIntoView() {
|
|||
}));
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gInspectee;
|
||||
delete gClient;
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -10,17 +10,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=835896
|
|||
<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
|
||||
|
@ -29,13 +29,13 @@ window.onload = function() {
|
|||
// 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();
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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();
|
||||
|
||||
|
@ -77,7 +77,7 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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();
|
||||
|
||||
|
@ -119,7 +119,7 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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();
|
||||
|
||||
|
@ -168,9 +168,8 @@ window.onload = function() {
|
|||
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");
|
||||
|
||||
|
|
|
@ -10,14 +10,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=835896
|
|||
<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();
|
||||
|
||||
|
@ -31,12 +32,13 @@ window.onload = function() {
|
|||
// 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();
|
||||
|
@ -56,7 +58,7 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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");
|
||||
|
@ -70,7 +72,7 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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");
|
||||
|
@ -88,8 +90,8 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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);
|
||||
|
@ -165,7 +167,7 @@ window.onload = function() {
|
|||
{node: inspectee.querySelector("h1 + p > strong").childNodes[0], type: "text"},
|
||||
]
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
for (let {desc, search, expected} of testData) {
|
||||
info("Running test: " + desc);
|
||||
|
@ -178,7 +180,7 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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();
|
||||
|
@ -218,7 +220,7 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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"},
|
||||
|
@ -238,6 +240,7 @@ window.onload = function() {
|
|||
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(() => {
|
||||
|
@ -254,6 +257,7 @@ window.onload = function() {
|
|||
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(() => {
|
||||
|
@ -274,6 +278,7 @@ window.onload = function() {
|
|||
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);
|
||||
|
|
|
@ -11,24 +11,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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);
|
||||
|
@ -44,7 +44,8 @@ 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));
|
||||
|
@ -121,11 +122,12 @@ addTest(function testQuerySelectors() {
|
|||
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.
|
||||
|
@ -142,17 +144,19 @@ addTest(function testQuerySelectors() {
|
|||
// 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() {
|
||||
|
@ -163,8 +167,8 @@ addTest(function testNoChildren() {
|
|||
});
|
||||
|
||||
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.
|
||||
|
@ -177,36 +181,37 @@ addTest(function testLongListTraversal() {
|
|||
}).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));
|
||||
});
|
||||
|
@ -221,7 +226,8 @@ addTest(function testObjectNodeChildren() {
|
|||
|
||||
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.");
|
||||
|
@ -255,7 +261,6 @@ addTest(function testPreviousSibling() {
|
|||
}).then(runNextTest));
|
||||
});
|
||||
|
||||
|
||||
addTest(function testFrameTraversal() {
|
||||
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
|
||||
return gWalker.children(childFrame);
|
||||
|
@ -268,7 +273,8 @@ addTest(function testFrameTraversal() {
|
|||
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");
|
||||
|
@ -278,8 +284,10 @@ addTest(function testFrameTraversal() {
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
|
@ -298,7 +306,8 @@ addTest(function testLongValue() {
|
|||
}).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));
|
||||
});
|
||||
|
||||
|
@ -318,7 +327,8 @@ addTest(function testShortValue() {
|
|||
}).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));
|
||||
});
|
||||
|
||||
|
@ -327,18 +337,16 @@ addTest(function testReleaseWalker() {
|
|||
|
||||
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>
|
||||
|
|
|
@ -17,10 +17,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1192536
|
|||
<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";
|
||||
|
@ -28,23 +31,24 @@ 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");
|
||||
|
@ -93,9 +97,9 @@ addTest(function testDelayedImage() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gImg;
|
||||
delete gNodeFront
|
||||
delete gWalker;
|
||||
gImg = null;
|
||||
gNodeFront = null;
|
||||
gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,18 +11,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=932937
|
|||
<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);
|
||||
|
||||
|
@ -45,6 +45,7 @@ addTest(function testLargeImage() {
|
|||
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);
|
||||
|
@ -66,6 +67,7 @@ addTest(function testLargeCanvas() {
|
|||
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);
|
||||
|
@ -87,6 +89,7 @@ addTest(function testSmallImage() {
|
|||
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);
|
||||
|
@ -108,6 +111,7 @@ addTest(function testDataImage() {
|
|||
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);
|
||||
|
@ -123,7 +127,7 @@ addTest(function testNonImgOrCanvasElements() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -16,10 +16,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1192536
|
|||
<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";
|
||||
|
@ -27,16 +30,16 @@ 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();
|
||||
|
@ -73,7 +76,7 @@ addTest(function testNormalImage() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gInspector;
|
||||
gInspector = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,18 +11,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1155653
|
|||
<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);
|
||||
|
||||
|
@ -32,7 +32,7 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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");
|
||||
|
@ -40,7 +40,7 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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");
|
||||
|
@ -48,7 +48,7 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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");
|
||||
|
@ -57,19 +57,19 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
|
|
@ -15,6 +15,7 @@ Debugger.prototype.makeGlobalObjectReference should dereference WindowProxy
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
@ -22,23 +23,27 @@ 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.
|
||||
|
@ -47,28 +52,32 @@ window.onload = function () {
|
|||
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");
|
||||
|
@ -78,7 +87,7 @@ window.onload = function () {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -13,12 +13,14 @@ Bug 923275 - Add a memory monitor widget to the developer toolbar
|
|||
<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");
|
||||
|
|
|
@ -13,11 +13,13 @@ Bug 1067491 - Test recording allocations.
|
|||
<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();
|
||||
|
@ -25,18 +27,22 @@ window.onload = function() {
|
|||
|
||||
// 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");
|
||||
|
@ -45,7 +51,7 @@ window.onload = function() {
|
|||
// 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
|
||||
|
@ -53,7 +59,7 @@ window.onload = function() {
|
|||
|| 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)");
|
||||
|
@ -63,19 +69,19 @@ window.onload = function() {
|
|||
// 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");
|
||||
|
||||
|
|
|
@ -13,27 +13,29 @@ Bug 1132764 - Test controlling the maximum allocations log length over the RDP.
|
|||
<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);
|
||||
}
|
||||
|
||||
|
@ -44,14 +46,15 @@ window.onload = function() {
|
|||
});
|
||||
|
||||
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
|
||||
});
|
||||
|
@ -62,7 +65,8 @@ window.onload = function() {
|
|||
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);
|
||||
|
|
|
@ -13,11 +13,13 @@ Bug 1067491 - Test that frames keep the same index while we are recording.
|
|||
<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();
|
||||
|
@ -26,18 +28,18 @@ window.onload = function() {
|
|||
// 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();
|
||||
|
||||
|
@ -48,7 +50,6 @@ window.onload = function() {
|
|||
// 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));
|
||||
|
||||
|
@ -64,7 +65,8 @@ window.onload = function() {
|
|||
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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,27 +13,29 @@ Bug 1068171 - Test controlling the memory actor's allocation sampling probabilit
|
|||
<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;
|
||||
});
|
||||
|
|
|
@ -13,24 +13,27 @@ Bug 1068144 - Test getting the timestamps for allocations.
|
|||
<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();
|
||||
|
@ -41,36 +44,39 @@ window.onload = function() {
|
|||
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.");
|
||||
}
|
||||
|
||||
|
|
|
@ -13,16 +13,18 @@ Bug 1132764 - Test controlling the maximum allocations log length over the RDP.
|
|||
<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({
|
||||
|
@ -33,7 +35,7 @@ window.onload = function() {
|
|||
allocator();
|
||||
allocator();
|
||||
|
||||
var response = yield memory.getAllocations();
|
||||
let response = yield memory.getAllocations();
|
||||
yield memory.stopRecordingAllocations();
|
||||
|
||||
is(response.allocations.length, 1,
|
||||
|
|
|
@ -13,16 +13,18 @@ Bug 1192335 - Test getting the byte sizes for allocations.
|
|||
<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();
|
||||
|
@ -31,7 +33,7 @@ window.onload = function() {
|
|||
allocator();
|
||||
allocator();
|
||||
|
||||
var response = yield memory.getAllocations();
|
||||
let response = yield memory.getAllocations();
|
||||
yield memory.stopRecordingAllocations();
|
||||
|
||||
ok(response.allocationSizes, "The response should have bytesizes.");
|
||||
|
@ -39,14 +41,15 @@ window.onload = function() {
|
|||
"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>
|
||||
|
|
|
@ -13,16 +13,18 @@ Bug 960671 - Test attaching and detaching from a memory actor.
|
|||
<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>
|
||||
|
|
|
@ -13,17 +13,18 @@ Bug 960671 - Test attaching and detaching while in the wrong state.
|
|||
<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");
|
||||
|
@ -33,8 +34,7 @@ window.onload = function() {
|
|||
e = null;
|
||||
try {
|
||||
yield memory.attach();
|
||||
}
|
||||
catch (ee) {
|
||||
} catch (ee) {
|
||||
e = ee;
|
||||
}
|
||||
ok(e, "Should have hit the wrongState error");
|
||||
|
|
|
@ -13,14 +13,16 @@ Bug 1067491 - Test taking a census over the RDP.
|
|||
<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();
|
||||
|
|
|
@ -13,27 +13,31 @@ Bug 1067491 - Test forcing a gc.
|
|||
<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");
|
||||
|
||||
|
|
|
@ -13,16 +13,18 @@ Bug 1137527 - Test receiving GC events from the memory actor.
|
|||
<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();
|
||||
|
|
|
@ -12,46 +12,45 @@ Bug 943251 - Allow accessing about:config from WebIDE
|
|||
<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;
|
||||
|
@ -66,37 +65,43 @@ function runTests() {
|
|||
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 () {
|
||||
|
@ -108,7 +113,7 @@ window.onload = function () {
|
|||
["test.all.string", "allizom"],
|
||||
]
|
||||
}, runTests);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -12,6 +12,7 @@ Bug 1181100 - Test DebuggerServerConnection.setupInParent and DebuggerServer.set
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
let Cu = Components.utils;
|
||||
let Cc = Components.classes;
|
||||
|
@ -22,7 +23,7 @@ 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({
|
||||
|
@ -32,7 +33,7 @@ window.onload = function() {
|
|||
["dom.mozBrowserFramesEnabled", true]
|
||||
]
|
||||
}, runTests);
|
||||
}
|
||||
};
|
||||
|
||||
function runTests() {
|
||||
// Create a minimal iframe with a message manager
|
||||
|
@ -40,8 +41,6 @@ function runTests() {
|
|||
iframe.mozbrowser = true;
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
let mm = iframe.frameLoader.messageManager;
|
||||
|
||||
// Instantiate a minimal server
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
|
@ -76,7 +75,7 @@ function runTests() {
|
|||
|
||||
// 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");
|
||||
|
@ -99,10 +98,9 @@ function runTests() {
|
|||
client.close().then(function () {
|
||||
DebuggerServer.destroy();
|
||||
iframe.remove();
|
||||
SimpleTest.finish()
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -11,25 +11,23 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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 => {
|
||||
|
@ -50,23 +48,28 @@ addTest(function inheritedUserStyles() {
|
|||
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.");
|
||||
|
@ -106,8 +109,10 @@ addTest(function matchedSelectors() {
|
|||
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));
|
||||
});
|
||||
|
||||
|
@ -124,9 +129,8 @@ addTest(function testMediaQuery() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gStyles;
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gStyles = null;
|
||||
gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,26 +11,23 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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 => {
|
||||
|
@ -40,87 +37,87 @@ addTest(function setup() {
|
|||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
window.onload = function() {
|
||||
window.onload = function () {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runNextTest();
|
||||
};
|
||||
|
@ -17,9 +17,9 @@ window.onload = function() {
|
|||
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 => {
|
||||
|
@ -32,12 +32,12 @@ addTest(function() {
|
|||
});
|
||||
});
|
||||
|
||||
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, {});
|
||||
|
||||
|
@ -55,7 +55,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
let node = yield gWalker.querySelector(gWalker.rootNode, "#layout-element");
|
||||
let layout = yield gStyles.getLayout(node, {});
|
||||
|
||||
|
@ -79,7 +79,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function*() {
|
||||
addAsyncTest(function* () {
|
||||
let node = yield gWalker.querySelector(gWalker.rootNode,
|
||||
"#layout-auto-margin-element");
|
||||
|
||||
|
@ -98,7 +98,7 @@ addAsyncTest(function*() {
|
|||
runNextTest();
|
||||
});
|
||||
|
||||
addTest(function() {
|
||||
addTest(function () {
|
||||
gStyles = gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
|
|
@ -11,27 +11,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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 => {
|
||||
|
@ -47,17 +47,22 @@ addTest(function testMatchedStyles() {
|
|||
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));
|
||||
});
|
||||
|
||||
|
@ -77,9 +82,9 @@ addTest(function testSystemStyles() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gStyles;
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gStyles = null;
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -11,26 +11,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
|||
<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();
|
||||
|
@ -95,9 +95,9 @@ function* removeProperty(rule, index, name) {
|
|||
}
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gStyles;
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gStyles = null;
|
||||
gWalker = null;
|
||||
gInspectee = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -12,25 +12,23 @@ Bug 921191 - allow inspection/editing of SVG elements' CSS properties
|
|||
<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 => {
|
||||
|
@ -49,9 +47,8 @@ addTest(function inheritedUserStyles() {
|
|||
});
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gStyles;
|
||||
delete gWalker;
|
||||
delete gClient;
|
||||
gStyles = null;
|
||||
gWalker = null;
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ xray wrapper.
|
|||
<body>
|
||||
<pre id="test">
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
@ -23,28 +24,28 @@ 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>
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
</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");
|
||||
|
@ -76,7 +78,7 @@ window.onload = function() {
|
|||
client.close();
|
||||
yield closed;
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче