MozReview-Commit-ID: 2CbNs260zlf
This commit is contained in:
Kartikaya Gupta 2017-03-20 10:07:29 -04:00
Родитель 803515ec05 d61e0b9ced
Коммит 0a0a696241
1805 изменённых файлов: 62025 добавлений и 29100 удалений

Просмотреть файл

@ -134,7 +134,6 @@ devtools/server/actors/stylesheets.js
devtools/server/tests/browser/storage-*.html devtools/server/tests/browser/storage-*.html
!devtools/server/tests/browser/storage-unsecured-iframe.html !devtools/server/tests/browser/storage-unsecured-iframe.html
devtools/server/tests/browser/stylesheets-nested-iframes.html devtools/server/tests/browser/stylesheets-nested-iframes.html
devtools/server/tests/mochitest/**
devtools/server/tests/unit/** devtools/server/tests/unit/**
devtools/shared/platform/content/test/test_clipboard.html devtools/shared/platform/content/test/test_clipboard.html
devtools/shared/qrcode/tests/mochitest/test_decode.html devtools/shared/qrcode/tests/mochitest/test_decode.html
@ -158,6 +157,7 @@ devtools/shared/sprintfjs/*
devtools/shared/qrcode/decoder/* devtools/shared/qrcode/decoder/*
devtools/shared/qrcode/encoder/* devtools/shared/qrcode/encoder/*
devtools/client/shared/demangle.js devtools/client/shared/demangle.js
devtools/client/shared/source-map/*
devtools/client/shared/vendor/* devtools/client/shared/vendor/*
devtools/client/sourceeditor/codemirror/*.js devtools/client/sourceeditor/codemirror/*.js
devtools/client/sourceeditor/codemirror/**/*.js devtools/client/sourceeditor/codemirror/**/*.js

Просмотреть файл

@ -329,20 +329,27 @@ NotificationController::CoalesceMutationEvents()
// queue, so we want to use the spot of the event with the higher // queue, so we want to use the spot of the event with the higher
// generation number, and keep that generation number. // generation number, and keep that generation number.
if (reorder && reorder->EventGeneration() < event->EventGeneration()) { if (reorder && reorder->EventGeneration() < event->EventGeneration()) {
// There really should be a show or hide event before the first
// reorder event.
if (reorder->PrevEvent()) {
reorder->PrevEvent()->SetNextEvent(reorder->NextEvent());
} else {
mFirstMutationEvent = reorder->NextEvent();
}
reorder->NextEvent()->SetPrevEvent(reorder->PrevEvent());
event->PrevEvent()->SetNextEvent(reorder);
reorder->SetPrevEvent(event->PrevEvent());
event->SetPrevEvent(reorder);
reorder->SetNextEvent(event);
reorder->SetEventGeneration(event->EventGeneration()); reorder->SetEventGeneration(event->EventGeneration());
// It may be true that reorder was before event, and we coalesced
// away all the show / hide events between them. In that case
// event is already immediately after reorder in the queue and we
// do not need to rearrange the list of events.
if (event != reorder->NextEvent()) {
// There really should be a show or hide event before the first
// reorder event.
if (reorder->PrevEvent()) {
reorder->PrevEvent()->SetNextEvent(reorder->NextEvent());
} else {
mFirstMutationEvent = reorder->NextEvent();
}
reorder->NextEvent()->SetPrevEvent(reorder->PrevEvent());
event->PrevEvent()->SetNextEvent(reorder);
reorder->SetPrevEvent(event->PrevEvent());
event->SetPrevEvent(reorder);
reorder->SetNextEvent(event);
}
} }
DropMutationEvent(event); DropMutationEvent(event);
break; break;

Просмотреть файл

@ -360,8 +360,7 @@ HistoryDownloadElementShell.prototype = {
DownloadsCommon.removeAndFinalizeDownload(this.download); DownloadsCommon.removeAndFinalizeDownload(this.download);
} }
if (this._historyDownload) { if (this._historyDownload) {
let uri = NetUtil.newURI(this.download.source.url); PlacesUtils.history.remove(this.download.source.url);
PlacesUtils.bhistory.removePage(uri);
} }
}, },

Просмотреть файл

@ -1204,8 +1204,7 @@ DownloadsViewItem.prototype = {
cmd_delete() { cmd_delete() {
DownloadsCommon.removeAndFinalizeDownload(this.download); DownloadsCommon.removeAndFinalizeDownload(this.download);
PlacesUtils.bhistory.removePage( PlacesUtils.history.remove(this.download.source.url).catch(Cu.reportError);
NetUtil.newURI(this.download.source.url));
}, },
downloadsCmd_unblock() { downloadsCmd_unblock() {

Просмотреть файл

@ -58,8 +58,10 @@ function getTree(rootGuid, onlyChildren) {
let children = root.children || []; let children = root.children || [];
return children.map(child => convert(child, root)); return children.map(child => convert(child, root));
} }
let treenode = convert(root, null);
treenode.parentId = root.parentGuid;
// It seems like the array always just contains the root node. // It seems like the array always just contains the root node.
return [convert(root, null)]; return [treenode];
}).catch(e => Promise.reject({message: e.message})); }).catch(e => Promise.reject({message: e.message}));
} }

Просмотреть файл

@ -517,7 +517,7 @@ MenuItem.prototype = {
} }
let docPattern = this.documentUrlMatchPattern; let docPattern = this.documentUrlMatchPattern;
let pageURI = Services.io.newURI(contextData.pageUrl); let pageURI = Services.io.newURI(contextData[contextData.inFrame ? "frameUrl" : "pageUrl"]);
if (docPattern && !docPattern.matches(pageURI)) { if (docPattern && !docPattern.matches(pageURI)) {
return false; return false;
} }

Просмотреть файл

@ -4,6 +4,7 @@ support-files =
head_pageAction.js head_pageAction.js
head_sessions.js head_sessions.js
context.html context.html
context_frame.html
ctxmenu-image.png ctxmenu-image.png
context_tabs_onUpdated_page.html context_tabs_onUpdated_page.html
context_tabs_onUpdated_iframe.html context_tabs_onUpdated_iframe.html
@ -120,6 +121,7 @@ support-files =
[browser_ext_tabs_zoom.js] [browser_ext_tabs_zoom.js]
[browser_ext_tabs_update_url.js] [browser_ext_tabs_update_url.js]
[browser_ext_themes_icons.js] [browser_ext_themes_icons.js]
[browser_ext_themes_validation.js]
[browser_ext_topwindowid.js] [browser_ext_topwindowid.js]
[browser_ext_url_overrides_newtab.js] [browser_ext_url_overrides_newtab.js]
[browser_ext_url_overrides_home.js] [browser_ext_url_overrides_home.js]

Просмотреть файл

@ -52,10 +52,16 @@ add_task(function* () {
// Test menu items using documentUrlPatterns. // Test menu items using documentUrlPatterns.
browser.contextMenus.create({ browser.contextMenus.create({
title: "documentUrlPatterns-patternMatches-contextAll", title: "documentUrlPatterns-patternMatches-contextAll",
documentUrlPatterns: ["*://*/*context.html"], documentUrlPatterns: ["*://*/*context*.html"],
contexts: ["all"], contexts: ["all"],
}); });
browser.contextMenus.create({
title: "documentUrlPatterns-patternMatches-contextFrame",
documentUrlPatterns: ["*://*/*context_frame.html"],
contexts: ["frame"],
});
browser.contextMenus.create({ browser.contextMenus.create({
title: "documentUrlPatterns-patternMatches-contextImage", title: "documentUrlPatterns-patternMatches-contextImage",
documentUrlPatterns: ["*://*/*context.html", "http://*/url-that-does-not-match"], documentUrlPatterns: ["*://*/*context.html", "http://*/url-that-does-not-match"],
@ -249,6 +255,14 @@ add_task(function* () {
yield confirmContextMenuItems(contextMenu, expected); yield confirmContextMenuItems(contextMenu, expected);
yield closeContextMenu(); yield closeContextMenu();
contextMenu = yield openContextMenuInFrame("frame");
expected = [
["documentUrlPatterns-patternMatches-contextAll", true],
["documentUrlPatterns-patternMatches-contextFrame", true],
];
yield confirmContextMenuItems(contextMenu, expected);
yield closeContextMenu();
yield extension.unload(); yield extension.unload();
yield BrowserTestUtils.removeTab(tab1); yield BrowserTestUtils.removeTab(tab1);
}); });

Просмотреть файл

@ -116,7 +116,8 @@ add_task(function* testExecuteScript() {
}).then(result => { }).then(result => {
browser.test.fail("Expected error when returning non-structured-clonable object"); browser.test.fail("Expected error when returning non-structured-clonable object");
}, error => { }, error => {
browser.test.assertEq("Script returned non-structured-clonable data", browser.test.assertEq("<anonymous code>", error.fileName, "Got expected fileName");
browser.test.assertEq("Script '<anonymous code>' result is non-structured-clonable data",
error.message, "Got expected error"); error.message, "Got expected error");
}), }),
@ -125,10 +126,21 @@ add_task(function* testExecuteScript() {
}).then(result => { }).then(result => {
browser.test.fail("Expected error when returning non-structured-clonable object"); browser.test.fail("Expected error when returning non-structured-clonable object");
}, error => { }, error => {
browser.test.assertEq("Script returned non-structured-clonable data", browser.test.assertEq("<anonymous code>", error.fileName, "Got expected fileName");
browser.test.assertEq("Script '<anonymous code>' result is non-structured-clonable data",
error.message, "Got expected error"); error.message, "Got expected error");
}), }),
browser.tabs.executeScript({
file: "script3.js",
}).then(result => {
browser.test.fail("Expected error when returning non-structured-clonable object");
}, error => {
const expected = /Script '.*script3.js' result is non-structured-clonable data/;
browser.test.assertTrue(expected.test(error.message), "Got expected error");
browser.test.assertTrue(error.fileName.endsWith("script3.js"), "Got expected fileName");
}),
browser.tabs.executeScript({ browser.tabs.executeScript({
frameId: Number.MAX_SAFE_INTEGER, frameId: Number.MAX_SAFE_INTEGER,
code: "42", code: "42",
@ -236,6 +248,8 @@ add_task(function* testExecuteScript() {
}, },
"script2.js": "27", "script2.js": "27",
"script3.js": "window",
}, },
}); });

Просмотреть файл

@ -0,0 +1,56 @@
"use strict";
add_task(function* setup() {
yield SpecialPowers.pushPrefEnv({
set: [["extensions.webextensions.themes.enabled", true]],
});
});
/**
* Helper function for testing a theme with invalid properties.
* @param {object} invalidProps The invalid properties to load the theme with.
*/
function* testThemeWithInvalidProperties(invalidProps) {
let manifest = {
"theme": {},
};
invalidProps.forEach(prop => {
// Some properties require additional information:
switch (prop) {
case "background":
manifest[prop] = {"scripts": ["background.js"]};
break;
case "permissions":
manifest[prop] = ["tabs"];
break;
case "omnibox":
manifest[prop] = {"keyword": "test"};
break;
default:
manifest[prop] = {};
}
});
let extension = ExtensionTestUtils.loadExtension({manifest});
SimpleTest.waitForExplicitFinish();
let waitForConsole = new Promise(resolve => {
SimpleTest.monitorConsole(resolve, [{
message: /Reading manifest: Themes defined in the manifest may only contain static resources/,
}]);
});
yield Assert.rejects(extension.startup(), null, "Theme should fail to load if it contains invalid properties");
SimpleTest.endMonitorConsole();
yield waitForConsole;
}
add_task(function* test_that_theme_with_invalid_properties_fails_to_load() {
let invalidProps = ["page_action", "browser_action", "background", "permissions", "omnibox", "commands"];
for (let prop in invalidProps) {
yield testThemeWithInvalidProperties([prop]);
}
yield testThemeWithInvalidProperties(invalidProps);
});

Просмотреть файл

@ -20,5 +20,6 @@
<input type="text" id="edit-me"><br> <input type="text" id="edit-me"><br>
<input type="password" id="password"> <input type="password" id="password">
</p> </p>
<iframe id="frame" src="context_frame.html"/>
</body> </body>
</html> </html>

Просмотреть файл

@ -0,0 +1,8 @@
<html>
<head>
<meta charset="utf-8">
</head>
<body>
Just some text
</body>
</html>

Просмотреть файл

@ -16,7 +16,7 @@
* getListStyleImage getPanelForNode * getListStyleImage getPanelForNode
* awaitExtensionPanel awaitPopupResize * awaitExtensionPanel awaitPopupResize
* promiseContentDimensions alterContent * promiseContentDimensions alterContent
* promisePrefChangeObserved * promisePrefChangeObserved openContextMenuInFrame
*/ */
const {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm", {}); const {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm", {});
@ -232,6 +232,16 @@ function closeBrowserAction(extension, win = window) {
return Promise.resolve(); return Promise.resolve();
} }
async function openContextMenuInFrame(frameId) {
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
let doc = gBrowser.selectedBrowser.contentDocument;
let frame = doc.getElementById(frameId);
EventUtils.synthesizeMouseAtCenter(frame.contentDocument.body, {type: "contextmenu"}, frame.contentWindow);
await popupShownPromise;
return contentAreaContextMenu;
}
async function openContextMenu(selector = "#img1") { async function openContextMenu(selector = "#img1") {
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown"); let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");

Просмотреть файл

@ -287,6 +287,7 @@ add_task(async function test_bookmarks() {
}).then(results => { }).then(results => {
browser.test.assertEq(1, results.length, "Expected number of nodes returned by getSubTree"); browser.test.assertEq(1, results.length, "Expected number of nodes returned by getSubTree");
browser.test.assertEq("Mozilla Folder", results[0].title, "Folder has the expected title"); browser.test.assertEq("Mozilla Folder", results[0].title, "Folder has the expected title");
browser.test.assertEq(bookmarkGuids.unfiledGuid, results[0].parentId, "Folder has the expected parentId");
let children = results[0].children; let children = results[0].children;
browser.test.assertEq(4, children.length, "Expected number of bookmarks returned by getSubTree"); browser.test.assertEq(4, children.length, "Expected number of bookmarks returned by getSubTree");
browser.test.assertEq("Firefox", children[0].title, "Bookmark has the expected title"); browser.test.assertEq("Firefox", children[0].title, "Bookmark has the expected title");

Просмотреть файл

@ -23,10 +23,6 @@ const RELOAD_ACTION_REMOVE = 2;
// rows. // rows.
const RELOAD_ACTION_MOVE = 3; const RELOAD_ACTION_MOVE = 3;
// When removing a bunch of pages we split them in chunks to give some breath
// to the main-thread.
const REMOVE_PAGES_CHUNKLEN = 300;
/** /**
* Represents an insertion point within a container where we can insert * Represents an insertion point within a container where we can insert
* items. * items.
@ -892,7 +888,7 @@ PlacesController.prototype = {
PlacesUtils.asQuery(node.parent).queryOptions.queryType == PlacesUtils.asQuery(node.parent).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) { Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
// This is a uri node inside an history query. // This is a uri node inside an history query.
PlacesUtils.bhistory.removePage(NetUtil.newURI(node.uri)); PlacesUtils.history.removePage(node.uri).catch(Components.utils.reportError);
// History deletes are not undoable, so we don't have a transaction. // History deletes are not undoable, so we don't have a transaction.
} else if (node.itemId == -1 && } else if (node.itemId == -1 &&
PlacesUtils.nodeIsQuery(node) && PlacesUtils.nodeIsQuery(node) &&
@ -945,21 +941,17 @@ PlacesController.prototype = {
}), }),
/** /**
* Removes the set of selected ranges from history. * Removes the set of selected ranges from history, asynchronously.
* *
* @note history deletes are not undoable. * @note history deletes are not undoable.
*/ */
_removeRowsFromHistory: function PC__removeRowsFromHistory() { _removeRowsFromHistory: function PC__removeRowsFromHistory() {
let nodes = this._view.selectedNodes; let nodes = this._view.selectedNodes;
let URIs = []; let URIs = new Set();
for (let i = 0; i < nodes.length; ++i) { for (let i = 0; i < nodes.length; ++i) {
let node = nodes[i]; let node = nodes[i];
if (PlacesUtils.nodeIsURI(node)) { if (PlacesUtils.nodeIsURI(node)) {
let uri = NetUtil.newURI(node.uri); URIs.add(node.uri);
// Avoid duplicates.
if (URIs.indexOf(uri) < 0) {
URIs.push(uri);
}
} else if (PlacesUtils.nodeIsQuery(node) && } else if (PlacesUtils.nodeIsQuery(node) &&
PlacesUtils.asQuery(node).queryOptions.queryType == PlacesUtils.asQuery(node).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) { Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
@ -967,18 +959,7 @@ PlacesController.prototype = {
} }
} }
// Do removal in chunks to give some breath to main-thread. PlacesUtils.history.remove([...URIs]).catch(Components.utils.reportError);
function* pagesChunkGenerator(aURIs) {
while (aURIs.length) {
let URIslice = aURIs.splice(0, REMOVE_PAGES_CHUNKLEN);
PlacesUtils.bhistory.removePages(URIslice, URIslice.length);
Services.tm.mainThread.dispatch(() => gen.next(),
Ci.nsIThread.DISPATCH_NORMAL);
yield undefined;
}
}
let gen = pagesChunkGenerator(URIs);
gen.next();
}, },
/** /**

Просмотреть файл

@ -41,6 +41,26 @@
* Ensures that history views are updated after deleting entries. * Ensures that history views are updated after deleting entries.
*/ */
function promiseURIDeleted() {
return new Promise(resolve => {
let historyObserver = {
onBeginUpdateBatch: function PEX_onBeginUpdateBatch() {},
onEndUpdateBatch: function PEX_onEndUpdateBatch() {},
onClearHistory() {},
onVisit() {},
onTitleChanged() {},
onDeleteURI(aURI, aGUID, aReason) {
PlacesUtils.history.removeObserver(historyObserver);
resolve();
},
onPageChanged() {},
onDeleteVisits(aURI, aTime) { },
};
PlacesUtils.history.addObserver(historyObserver, false);
});
}
function runTest() { function runTest() {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
@ -106,10 +126,12 @@
for (let i = 0; i < rc; i++) { for (let i = 0; i < rc; i++) {
selection.select(0); selection.select(0);
let node = tree.selectedNode; let node = tree.selectedNode;
let promiseDeleted = promiseURIDeleted();
tree.controller.remove("Removing page"); tree.controller.remove("Removing page");
yield promiseDeleted;
ok(treeView.treeIndexForNode(node) == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE, ok(treeView.treeIndexForNode(node) == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE,
node.uri + " removed."); node.uri + " removed.");
ok(treeView.rowCount == rc - i - 1, "Rows count decreased"); is(treeView.rowCount, rc - i - 1, "Rows count decreased");
} }
// Cleanup. // Cleanup.

Просмотреть файл

@ -70,6 +70,7 @@ support-files =
[browser_async_duplicate_tab.js] [browser_async_duplicate_tab.js]
[browser_async_flushes.js] [browser_async_flushes.js]
run-if = e10s && crashreporter run-if = e10s && crashreporter
skip-if = debug # bug 1167933
[browser_async_remove_tab.js] [browser_async_remove_tab.js]
run-if = e10s run-if = e10s
[browser_attributes.js] [browser_attributes.js]

Просмотреть файл

@ -1,3 +1,3 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.7.359 Current extension version is: 1.7.367

Просмотреть файл

@ -3667,8 +3667,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
} }
}; };
}(); }();
exports.version = '1.7.359'; exports.version = '1.7.367';
exports.build = 'd471e356'; exports.build = 'f0c45f03';
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport; exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker; exports.PDFWorker = PDFWorker;
@ -4685,8 +4685,8 @@ if (!globalScope.PDFJS) {
globalScope.PDFJS = {}; globalScope.PDFJS = {};
} }
var PDFJS = globalScope.PDFJS; var PDFJS = globalScope.PDFJS;
PDFJS.version = '1.7.359'; PDFJS.version = '1.7.367';
PDFJS.build = 'd471e356'; PDFJS.build = 'f0c45f03';
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
sharedUtil.setVerbosityLevel(PDFJS.verbosity); sharedUtil.setVerbosityLevel(PDFJS.verbosity);
@ -7051,7 +7051,7 @@ var TilingPattern = function TilingPatternClosure() {
0, 0,
0 0
]; ];
this.bbox = IR[4]; this.bbox = Util.normalizeRect(IR[4]);
this.xstep = IR[5]; this.xstep = IR[5];
this.ystep = IR[6]; this.ystep = IR[6];
this.paintType = IR[7]; this.paintType = IR[7];
@ -7135,7 +7135,7 @@ var TilingPattern = function TilingPatternClosure() {
this.ctx.scale(1 / scale[0], 1 / scale[1]); this.ctx.scale(1 / scale[0], 1 / scale[1]);
}, },
clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) { clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
if (bbox && isArray(bbox) && bbox.length === 4) { if (isArray(bbox) && bbox.length === 4) {
var bboxWidth = x1 - x0; var bboxWidth = x1 - x0;
var bboxHeight = y1 - y0; var bboxHeight = y1 - y0;
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight); graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
@ -7186,8 +7186,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.7.359'; var pdfjsVersion = '1.7.367';
var pdfjsBuild = 'd471e356'; var pdfjsBuild = 'f0c45f03';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(8); var pdfjsDisplayGlobal = __w_pdfjs_require__(8);
var pdfjsDisplayAPI = __w_pdfjs_require__(3); var pdfjsDisplayAPI = __w_pdfjs_require__(3);

Просмотреть файл

@ -19175,7 +19175,7 @@ var CFFParser = function CFFParserClosure() {
return cffDict; return cffDict;
}, },
parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) { parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
if (state.callDepth > MAX_SUBR_NESTING) { if (!data || state.callDepth > MAX_SUBR_NESTING) {
return false; return false;
} }
var stackSize = state.stackSize; var stackSize = state.stackSize;
@ -19241,7 +19241,7 @@ var CFFParser = function CFFParserClosure() {
bias = 1131; bias = 1131;
} }
var subrNumber = stack[--stackSize] + bias; var subrNumber = stack[--stackSize] + bias;
if (subrNumber < 0 || subrNumber >= subrsIndex.count) { if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
validationCommand = CharstringValidationData[value]; validationCommand = CharstringValidationData[value];
warn('Out of bounds subrIndex for ' + validationCommand.id); warn('Out of bounds subrIndex for ' + validationCommand.id);
return false; return false;
@ -49132,8 +49132,8 @@ exports.Type1Parser = Type1Parser;
"use strict"; "use strict";
var pdfjsVersion = '1.7.359'; var pdfjsVersion = '1.7.367';
var pdfjsBuild = 'd471e356'; var pdfjsBuild = 'f0c45f03';
var pdfjsCoreWorker = __w_pdfjs_require__(17); var pdfjsCoreWorker = __w_pdfjs_require__(17);
; ;
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler; exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

Просмотреть файл

@ -72,13 +72,13 @@ See https://github.com/adobe-type-tools/cmap-resources
<div id="mainContainer"> <div id="mainContainer">
<div class="findbar hidden doorHanger" id="findbar"> <div class="findbar hidden doorHanger" id="findbar">
<div id="findbarInputContainer"> <div id="findbarInputContainer">
<input id="findInput" class="toolbarField" title="Find" placeholder="Find in document" tabindex="91" data-l10n-id="find_input"> <input id="findInput" class="toolbarField" title="Find" placeholder="Find in document" tabindex="91" data-l10n-id="find_input">
<div class="splitToolbarButton"> <div class="splitToolbarButton">
<button class="toolbarButton findPrevious" title="" id="findPrevious" tabindex="92" data-l10n-id="find_previous"> <button id="findPrevious" class="toolbarButton findPrevious" title="Find the previous occurrence of the phrase" tabindex="92" data-l10n-id="find_previous">
<span data-l10n-id="find_previous_label">Previous</span> <span data-l10n-id="find_previous_label">Previous</span>
</button> </button>
<div class="splitToolbarButtonSeparator"></div> <div class="splitToolbarButtonSeparator"></div>
<button class="toolbarButton findNext" title="" id="findNext" tabindex="93" data-l10n-id="find_next"> <button id="findNext" class="toolbarButton findNext" title="Find the next occurrence of the phrase" tabindex="93" data-l10n-id="find_next">
<span data-l10n-id="find_next_label">Next</span> <span data-l10n-id="find_next_label">Next</span>
</button> </button>
</div> </div>
@ -160,7 +160,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</button> </button>
<div class="toolbarButtonSpacer"></div> <div class="toolbarButtonSpacer"></div>
<button id="viewFind" class="toolbarButton" title="Find in Document" tabindex="12" data-l10n-id="findbar"> <button id="viewFind" class="toolbarButton" title="Find in Document" tabindex="12" data-l10n-id="findbar">
<span data-l10n-id="findbar_label">Find</span> <span data-l10n-id="findbar_label">Find</span>
</button> </button>
<div class="splitToolbarButton hiddenSmallView"> <div class="splitToolbarButton hiddenSmallView">
<button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="13" data-l10n-id="previous"> <button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="13" data-l10n-id="previous">

Просмотреть файл

@ -504,10 +504,12 @@ exports.localized = localized;
{ {
var pdfjsLib; var pdfjsLib;
if (typeof __pdfjsdev_webpack__ === 'undefined') { if (typeof __pdfjsdev_webpack__ === 'undefined') {
if (typeof require === 'function') { if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
pdfjsLib = window['pdfjs-dist/build/pdf'];
} else if (typeof require === 'function') {
pdfjsLib = require('../build/pdf.js'); pdfjsLib = require('../build/pdf.js');
} else { } else {
pdfjsLib = window['pdfjs-dist/build/pdf']; throw new Error('Neither `require` nor `window` found');
} }
} }
module.exports = pdfjsLib; module.exports = pdfjsLib;

Просмотреть файл

@ -491,12 +491,13 @@ geolocation.shareWithSite3=Will you allow %S to access your location?
geolocation.shareWithFile3=Will you allow this local file to access your location? geolocation.shareWithFile3=Will you allow this local file to access your location?
geolocation.remember=Remember this decision geolocation.remember=Remember this decision
webNotifications.remember=Remember this decision
webNotifications.rememberForSession=Remember decision for this session
webNotifications.allow=Allow Notifications webNotifications.allow=Allow Notifications
webNotifications.allow.accesskey=A webNotifications.allow.accesskey=A
webNotifications.dontAllow=Dont Allow webNotifications.notNow=Not Now
webNotifications.dontAllow.accesskey=n webNotifications.notNow.accesskey=n
webNotifications.never=Never Allow
webNotifications.neverForSession=Never For This Session
webNotifications.never.accesskey=v
webNotifications.receiveFromSite2=Will you allow %S to send notifications? webNotifications.receiveFromSite2=Will you allow %S to send notifications?
# LOCALIZATION NOTE (webNotifications.upgradeTitle): When using native notifications on OS X, the title may be truncated around 32 characters. # LOCALIZATION NOTE (webNotifications.upgradeTitle): When using native notifications on OS X, the title may be truncated around 32 characters.
webNotifications.upgradeTitle=Upgraded notifications webNotifications.upgradeTitle=Upgraded notifications

Просмотреть файл

@ -301,7 +301,8 @@ this.PermissionPromptPrototype = {
if (this.permissionKey) { if (this.permissionKey) {
// Permanently store permission. // Permanently store permission.
if (state && state.checkboxChecked) { if ((state && state.checkboxChecked) ||
promptAction.scope == SitePermissions.SCOPE_PERSISTENT) {
let scope = SitePermissions.SCOPE_PERSISTENT; let scope = SitePermissions.SCOPE_PERSISTENT;
// Only remember permission for session if in PB mode. // Only remember permission for session if in PB mode.
if (PrivateBrowsingUtils.isBrowserPrivate(this.browser)) { if (PrivateBrowsingUtils.isBrowserPrivate(this.browser)) {
@ -539,22 +540,8 @@ DesktopNotificationPermissionPrompt.prototype = {
let learnMoreURL = let learnMoreURL =
Services.urlFormatter.formatURLPref("app.support.baseURL") + "push"; Services.urlFormatter.formatURLPref("app.support.baseURL") + "push";
let checkbox = {
show: true,
checked: true,
label: gBrowserBundle.GetStringFromName("webNotifications.remember")
};
// In PB mode, the "always remember" checkbox should only remember for the
// session.
if (PrivateBrowsingUtils.isWindowPrivate(this.browser.ownerGlobal)) {
checkbox.label =
gBrowserBundle.GetStringFromName("webNotifications.rememberForSession");
}
return { return {
learnMoreURL, learnMoreURL,
checkbox,
displayURI: false displayURI: false
}; };
}, },
@ -583,13 +570,23 @@ DesktopNotificationPermissionPrompt.prototype = {
accessKey: accessKey:
gBrowserBundle.GetStringFromName("webNotifications.allow.accesskey"), gBrowserBundle.GetStringFromName("webNotifications.allow.accesskey"),
action: SitePermissions.ALLOW, action: SitePermissions.ALLOW,
scope: SitePermissions.SCOPE_PERSISTENT,
}, },
{ {
label: gBrowserBundle.GetStringFromName("webNotifications.dontAllow"), label: gBrowserBundle.GetStringFromName("webNotifications.notNow"),
accessKey: accessKey:
gBrowserBundle.GetStringFromName("webNotifications.dontAllow.accesskey"), gBrowserBundle.GetStringFromName("webNotifications.notNow.accesskey"),
action: SitePermissions.BLOCK, action: SitePermissions.BLOCK,
}, },
{
label: PrivateBrowsingUtils.isBrowserPrivate(this.browser) ?
gBrowserBundle.GetStringFromName("webNotifications.neverForSession") :
gBrowserBundle.GetStringFromName("webNotifications.never"),
accessKey:
gBrowserBundle.GetStringFromName("webNotifications.never.accesskey"),
action: SitePermissions.BLOCK,
scope: SitePermissions.SCOPE_PERSISTENT,
},
]; ];
}, },
}; };

Просмотреть файл

@ -50,8 +50,11 @@ function* testPrompt(Prompt) {
let popupNotification = getPopupNotificationNode(); let popupNotification = getPopupNotificationNode();
popupNotification.checkbox.checked = false; popupNotification.checkbox.checked = false;
Assert.equal(notification.secondaryActions.length, 1, let isNotificationPrompt = Prompt == PermissionUI.DesktopNotificationPermissionPrompt;
"There should only be 1 secondary action");
let expectedSecondaryActionsCount = isNotificationPrompt ? 2 : 1;
Assert.equal(notification.secondaryActions.length, expectedSecondaryActionsCount,
"There should only be " + expectedSecondaryActionsCount + " secondary action(s)");
yield clickSecondaryAction(); yield clickSecondaryAction();
curPerm = SitePermissions.get(principal.URI, permissionKey, browser); curPerm = SitePermissions.get(principal.URI, permissionKey, browser);
Assert.deepEqual(curPerm, { Assert.deepEqual(curPerm, {
@ -73,13 +76,19 @@ function* testPrompt(Prompt) {
TestPrompt.prompt(); TestPrompt.prompt();
yield shownPromise; yield shownPromise;
// Test denying the permission request with the checkbox checked. // Test denying the permission request with the checkbox checked (for geolocation)
// or by clicking the "never" option from the dropdown (for notifications).
popupNotification = getPopupNotificationNode(); popupNotification = getPopupNotificationNode();
popupNotification.checkbox.checked = true; let secondaryActionToClickIndex = 0;
if (isNotificationPrompt) {
secondaryActionToClickIndex = 1;
} else {
popupNotification.checkbox.checked = true;
}
Assert.equal(notification.secondaryActions.length, 1, Assert.equal(notification.secondaryActions.length, expectedSecondaryActionsCount,
"There should only be 1 secondary action"); "There should only be " + expectedSecondaryActionsCount + " secondary action(s)");
yield clickSecondaryAction(); yield clickSecondaryAction(secondaryActionToClickIndex);
curPerm = SitePermissions.get(principal.URI, permissionKey); curPerm = SitePermissions.get(principal.URI, permissionKey);
Assert.deepEqual(curPerm, { Assert.deepEqual(curPerm, {
state: SitePermissions.BLOCK, state: SitePermissions.BLOCK,

Просмотреть файл

@ -178,16 +178,39 @@ function clickMainAction() {
* For an opened PopupNotification, clicks on the secondary action, * For an opened PopupNotification, clicks on the secondary action,
* and waits for the panel to fully close. * and waits for the panel to fully close.
* *
* @param actionIndex (Number)
* The index of the secondary action to be clicked. The default
* secondary action (the button shown directly in the panel) is
* treated as having index 0.
*
* @return {Promise} * @return {Promise}
* Resolves once the panel has fired the "popuphidden" * Resolves once the panel has fired the "popuphidden"
* event. * event.
*/ */
function clickSecondaryAction() { function clickSecondaryAction(actionIndex) {
let removePromise = let removePromise =
BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden"); BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden");
let popupNotification = getPopupNotificationNode(); let popupNotification = getPopupNotificationNode();
popupNotification.secondaryButton.click(); if (!actionIndex) {
return removePromise; popupNotification.secondaryButton.click();
return removePromise;
}
return Task.spawn(function* () {
// Click the dropmarker arrow and wait for the menu to show up.
let dropdownPromise =
BrowserTestUtils.waitForEvent(popupNotification.menupopup, "popupshown");
yield EventUtils.synthesizeMouseAtCenter(popupNotification.menubutton, {});
yield dropdownPromise;
// The menuitems in the dropdown are accessible as direct children of the panel,
// because they are injected into a <children> node in the XBL binding.
// The target action is the menuitem at index actionIndex - 1, because the first
// secondary action (index 0) is the button shown directly in the panel.
let actionMenuItem = popupNotification.querySelectorAll("menuitem")[actionIndex - 1];
yield EventUtils.synthesizeMouseAtCenter(actionMenuItem, {});
yield removePromise;
});
} }
/** /**

Просмотреть файл

@ -511,11 +511,10 @@ exports.ToolboxButtons = [
osString == "Darwin" ? "Cmd+Opt+M" : "Ctrl+Shift+M"), osString == "Darwin" ? "Cmd+Opt+M" : "Ctrl+Shift+M"),
isTargetSupported: target => target.isLocalTab, isTargetSupported: target => target.isLocalTab,
onClick(event, toolbox) { onClick(event, toolbox) {
let browserWindow = toolbox.win.top; let tab = toolbox.target.tab;
ResponsiveUIManager.handleGcliCommand(browserWindow, let browserWindow = tab.ownerDocument.defaultView;
browserWindow.gBrowser.selectedTab, ResponsiveUIManager.handleGcliCommand(browserWindow, tab,
"resize toggle", "resize toggle", null);
null);
}, },
isChecked(toolbox) { isChecked(toolbox) {
if (!toolbox.target.tab) { if (!toolbox.target.tab) {

Просмотреть файл

@ -751,7 +751,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
// Destroy toolboxes for closed window // Destroy toolboxes for closed window
for (let [target, toolbox] of gDevTools._toolboxes) { for (let [target, toolbox] of gDevTools._toolboxes) {
if (toolbox.win.top == win) { if (target.tab && target.tab.ownerDocument.defaultView == win) {
toolbox.destroy(); toolbox.destroy();
} }
} }

Просмотреть файл

@ -11,6 +11,7 @@ DIRS += [
'components', 'components',
'redux', 'redux',
'shim', 'shim',
'source-map',
'vendor', 'vendor',
'widgets', 'widgets',
] ]

Просмотреть файл

@ -0,0 +1,12 @@
devtools-source-map is maintained on GitHub at:
https://github.com/devtools-html/devtools-core/tree/master/packages/devtools-source-map
All the files in this folder are copied from the above repository and
should not be modified here.
For any issue or feature request on devtools-source-map, please log an issue at:
https://github.com/devtools-html/devtools-core/issues
and label it with "source-map".

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,10 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DevToolsModules(
'index.js',
'worker.js',
)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -15,6 +15,7 @@ const {
} = require("./utils/markup"); } = require("./utils/markup");
const { const {
getCurrentZoom, getCurrentZoom,
getDisplayPixelRatio,
setIgnoreLayoutChanges, setIgnoreLayoutChanges,
getWindowDimensions, getWindowDimensions,
getMaxSurfaceSize, getMaxSurfaceSize,
@ -28,6 +29,9 @@ const DEFAULT_GRID_COLOR = "#4B0082";
const COLUMNS = "cols"; const COLUMNS = "cols";
const ROWS = "rows"; const ROWS = "rows";
const GRID_FONT_SIZE = 10;
const GRID_FONT_FAMILY = "sans-serif";
const GRID_LINES_PROPERTIES = { const GRID_LINES_PROPERTIES = {
"edge": { "edge": {
lineDash: [0, 0], lineDash: [0, 0],
@ -879,19 +883,21 @@ CssGridHighlighter.prototype = extend(AutoRefreshHighlighter.prototype, {
* The grid dimension type which is either the constant COLUMNS or ROWS. * The grid dimension type which is either the constant COLUMNS or ROWS.
*/ */
renderGridLineNumber(lineNumber, linePos, startPos, dimensionType) { renderGridLineNumber(lineNumber, linePos, startPos, dimensionType) {
let ratio = this.win.devicePixelRatio; let devicePixelRatio = this.win.devicePixelRatio;
let displayPixelRatio = getDisplayPixelRatio(this.win);
linePos = Math.round(linePos * ratio); linePos = Math.round(linePos * devicePixelRatio);
startPos = Math.round(startPos * ratio); startPos = Math.round(startPos * devicePixelRatio);
this.ctx.save(); this.ctx.save();
let fontSize = (GRID_FONT_SIZE * displayPixelRatio);
this.ctx.font = fontSize + "px " + GRID_FONT_FAMILY;
let textWidth = this.ctx.measureText(lineNumber).width; let textWidth = this.ctx.measureText(lineNumber).width;
// Guess the font height based on the measured width
let textHeight = textWidth * 2;
if (dimensionType === COLUMNS) { if (dimensionType === COLUMNS) {
let yPos = Math.max(startPos, textHeight); let yPos = Math.max(startPos, fontSize);
this.ctx.fillText(lineNumber, linePos, yPos); this.ctx.fillText(lineNumber, linePos, yPos);
} else { } else {
let xPos = Math.max(startPos, textWidth); let xPos = Math.max(startPos, textWidth);

Просмотреть файл

@ -1 +1,4 @@
"use strict";
// eslint-disable-next-line no-debugger
debugger; debugger;

Просмотреть файл

@ -1,6 +1,14 @@
<head> <head>
<!-- Static (not dynamically inserted) inline script. --> <!-- 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. --> <!-- Static out-of-line script element. -->
<script id='heinrich' src='Debugger.Source.prototype.element.js'></script> <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> </style>
<script type="text/javascript"> <script type="text/javascript">
window.onload = function() { "use strict";
window.opener.postMessage('ready', '*');
window.onload = function () {
window.opener.postMessage("ready", "*");
}; };
</script> </script>
</head> </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 {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const {DebuggerClient} = require("devtools/shared/client/main"); const {DebuggerClient} = require("devtools/shared/client/main");
const {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
@ -25,12 +29,12 @@ const { Task } = require("devtools/shared/task");
**********************************/ **********************************/
function* newConnectedDebuggerClient(opts) { function* newConnectedDebuggerClient(opts) {
var transport = DebuggerServer.connectPipe(); let transport = DebuggerServer.connectPipe();
var client = new DebuggerClient(transport); let client = new DebuggerClient(transport);
yield client.connect(); yield client.connect();
var root = yield client.listTabs(); let root = yield client.listTabs();
return { return {
client: client, client: client,

Просмотреть файл

@ -1,5 +1,7 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
/* exported HelloActor */
"use strict";
const protocol = require("devtools/shared/protocol"); const protocol = require("devtools/shared/protocol");

Просмотреть файл

@ -1,18 +1,20 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Inspector Eyedropper tests</title> <title>Inspector Eyedropper tests</title>
<style> <style>
html { html {
background: black; background: black;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
window.onload = function() { "use strict";
window.opener.postMessage('ready', '*');
}; window.onload = function () {
</script> window.opener.postMessage("ready", "*");
</head> };
</body> </script>
</body> </head>
</html> </body>
</body>
</html>

Просмотреть файл

@ -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; var Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
@ -15,7 +21,6 @@ SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log"); Services.prefs.clearUserPref("devtools.debugger.log");
}); });
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
@ -40,8 +45,8 @@ SimpleTest.registerCleanupFunction(function () {
* and disconnect its debugger client. * and disconnect its debugger client.
*/ */
function attachURL(url, callback) { function attachURL(url, callback) {
var win = window.open(url, "_blank"); let win = window.open(url, "_blank");
var client = null; let client = null;
let cleanup = () => { let cleanup = () => {
if (client) { if (client) {
@ -63,7 +68,8 @@ function attachURL(url, callback) {
for (let tab of response.tabs) { for (let tab of response.tabs) {
if (tab.url === url) { if (tab.url === url) {
window.removeEventListener("message", loadListener); 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 { try {
callback(null, client, tab, win.document); callback(null, client, tab, win.document);
} catch (ex) { } catch (ex) {
@ -125,15 +131,18 @@ function serverOwnershipTree(walker) {
return { return {
root: serverOwnershipSubtree(serverWalker, serverWalker.rootDoc), root: serverOwnershipSubtree(serverWalker, serverWalker.rootDoc),
orphaned: [...serverWalker._orphaned].map(o => serverOwnershipSubtree(serverWalker, o.rawNode)), orphaned: [...serverWalker._orphaned]
retained: [...serverWalker._retainedOrphans].map(o => serverOwnershipSubtree(serverWalker, o.rawNode)) .map(o => serverOwnershipSubtree(serverWalker, o.rawNode)),
retained: [...serverWalker._retainedOrphans]
.map(o => serverOwnershipSubtree(serverWalker, o.rawNode))
}; };
} }
function clientOwnershipSubtree(node) { function clientOwnershipSubtree(node) {
return { return {
name: node.actorID, 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) { function assertOwnershipTrees(walker) {
let serverTree = serverOwnershipTree(walker); let serverTree = serverOwnershipTree(walker);
let clientTree = clientOwnershipTree(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); return ownershipTreeSize(clientTree.root);
} }
@ -189,14 +199,15 @@ function checkAvailable(client, actorID) {
to: actorID, to: actorID,
type: "garbageAvailableTest", type: "garbageAvailableTest",
}, response => { }, response => {
is(response.error, "unrecognizedPacketType", "node list actor should be contactable."); is(response.error, "unrecognizedPacketType",
"node list actor should be contactable.");
deferred.resolve(undefined); deferred.resolve(undefined);
}); });
return deferred.promise; return deferred.promise;
} }
function promiseDone(promise) { function promiseDone(currentPromise) {
promise.then(null, err => { currentPromise.then(null, err => {
ok(false, "Promise failed: " + err); ok(false, "Promise failed: " + err);
if (err.stack) { if (err.stack) {
dump(err.stack); dump(err.stack);
@ -207,10 +218,6 @@ function promiseDone(promise) {
// Mutation list testing // Mutation list testing
function isSrcChange(change) {
return (change.type === "attributes" && change.attributeName === "src");
}
function assertAndStrip(mutations, message, test) { function assertAndStrip(mutations, message, test) {
let size = mutations.length; let size = mutations.length;
mutations = mutations.filter(test); mutations = mutations.filter(test);
@ -245,7 +252,8 @@ function isNewRoot(change) {
// Make sure an iframe's src attribute changed and then // Make sure an iframe's src attribute changed and then
// strip that mutation out of the list. // strip that mutation out of the list.
function assertSrcChange(mutations) { 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 // Make sure there's an unload in the mutation list and strip
@ -285,7 +293,6 @@ function waitForMutation(walker, test, mutations = []) {
return deferred.promise; return deferred.promise;
} }
var _tests = []; var _tests = [];
function addTest(test) { function addTest(test) {
_tests.push(test); _tests.push(test);
@ -300,7 +307,7 @@ function runNextTest() {
SimpleTest.finish(); SimpleTest.finish();
return; return;
} }
var fn = _tests.shift(); let fn = _tests.shift();
try { try {
fn(); fn();
} catch (ex) { } catch (ex) {

Просмотреть файл

@ -15,8 +15,10 @@
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
window.onload = function() { "use strict";
window.opener.postMessage('ready', '*');
window.onload = function () {
window.opener.postMessage("ready", "*");
}; };
</script> </script>
</head> </head>
@ -49,4 +51,4 @@
<div class="💩" id="💩" 💩="💩"></div> <div class="💩" id="💩" 💩="💩"></div>
</body> </body>
</html> </html>

Просмотреть файл

@ -1,8 +1,10 @@
<html> <html>
<script> <script>
"use strict";
window.onload = () => { window.onload = () => {
window.opener.postMessage('ready', '*') window.opener.postMessage("ready", "*");
} };
</script> </script>
<style> <style>
.inheritable-rule { .inheritable-rule {

Просмотреть файл

@ -18,26 +18,27 @@
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
window.onload = function() { "use strict";
window.onload = function () {
// Set up a basic shadow DOM // Set up a basic shadow DOM
var host = document.querySelector('#shadow'); let host = document.querySelector("#shadow");
if (host.createShadowRoot) { if (host.createShadowRoot) {
var root = host.createShadowRoot(); let root = host.createShadowRoot();
root.innerHTML = '<h3>Shadow <em>DOM</em></h3><select multiple></select>'; root.innerHTML = "<h3>Shadow <em>DOM</em></h3><select multiple></select>";
} }
// Put a copy of the body in an iframe to test frame traversal. // Put a copy of the body in an iframe to test frame traversal.
var body = document.querySelector("body"); let body = document.querySelector("body");
var data = "data:text/html,<html>" + body.outerHTML + "<html>"; let data = "data:text/html,<html>" + body.outerHTML + "<html>";
var iframe = document.createElement("iframe"); let iframe = document.createElement("iframe");
iframe.setAttribute("id", "childFrame"); iframe.setAttribute("id", "childFrame");
iframe.onload = function() { iframe.onload = function () {
window.opener.postMessage('ready', '*') window.opener.postMessage("ready", "*");
}; };
iframe.src = data; iframe.src = data;
body.appendChild(iframe); body.appendChild(iframe);
} };
</script> </script>
</head> </head>
<body style="background-color:white"> <body style="background-color:white">

Просмотреть файл

@ -2,8 +2,10 @@
<head> <head>
<body> <body>
<script type="text/javascript"> <script type="text/javascript">
window.onload = function() { "use strict";
window.opener.postMessage('ready', '*');
window.onload = function () {
window.opener.postMessage("ready", "*");
}; };
</script> </script>
</body> </body>

Просмотреть файл

@ -7,6 +7,8 @@
<img class="small" src="small-image.gif"> <img class="small" src="small-image.gif">
<img class="data" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAJklEQVRIie3NMREAAAgAoe9fWls4eAzMVM0xoVAoFAqFQqFQ+C9chp4NHvu+4Q4AAAAASUVORK5CYII="> <img class="data" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAAJklEQVRIie3NMREAAAgAoe9fWls4eAzMVM0xoVAoFAqFQqFQ+C9chp4NHvu+4Q4AAAAASUVORK5CYII=">
<script> <script>
"use strict";
window.onload = () => { window.onload = () => {
var canvas = document.querySelector("canvas"), ctx = canvas.getContext("2d"); var canvas = document.querySelector("canvas"), ctx = canvas.getContext("2d");
canvas.width = 1000; canvas.width = 1000;
@ -14,8 +16,8 @@
ctx.fillStyle = "red"; ctx.fillStyle = "red";
ctx.fillRect(0, 0, 1000, 2000); ctx.fillRect(0, 0, 1000, 2000);
window.opener.postMessage('ready', '*') window.opener.postMessage("ready", "*");
} };
</script> </script>
</body> </body>
</html> </html>

Просмотреть файл

@ -1,14 +1,16 @@
var Cu = Components.utils; /* exported Task, startServerAndGetSelectedTabMemory, destroyServerAndFinish,
var Cc = Components.classes; waitForTime, waitUntil */
var Ci = Components.interfaces; "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"); const { Task } = require("devtools/shared/task");
var Services = require("Services"); const { DebuggerClient } = require("devtools/shared/client/main");
var { DebuggerClient } = require("devtools/shared/client/main"); const { DebuggerServer } = require("devtools/server/main");
var { 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. // Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true); Services.prefs.setBoolPref("devtools.debugger.log", true);
@ -19,13 +21,13 @@ SimpleTest.registerCleanupFunction(function () {
function startServerAndGetSelectedTabMemory() { function startServerAndGetSelectedTabMemory() {
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
var client = new DebuggerClient(DebuggerServer.connectPipe()); let client = new DebuggerClient(DebuggerServer.connectPipe());
return client.connect() return client.connect()
.then(() => client.listTabs()) .then(() => client.listTabs())
.then(response => { .then(response => {
var form = response.tabs[response.selected]; let form = response.tabs[response.selected];
var memory = MemoryFront(client, form, response); let memory = MemoryFront(client, form, response);
return { memory, client }; return { memory, client };
}); });
@ -48,5 +50,6 @@ function waitUntil(predicate) {
if (predicate()) { if (predicate()) {
return Promise.resolve(true); 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> <!DOCTYPE HTML>
<html> <html>
<script> <script>
var xhr = new XMLHttpRequest; "use strict";
var xhr = new XMLHttpRequest();
xhr.timeout = 1742; xhr.timeout = 1742;
xhr.expando = 'Expando!'; xhr.expando = "Expando!";
</script> </script>
</html> </html>

Просмотреть файл

@ -1,6 +1,8 @@
"use strict";
const {Cc, Ci} = require("chrome"); const {Cc, Ci} = require("chrome");
const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]. const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
getService(Ci.nsIMessageListenerManager); .getService(Ci.nsIMessageListenerManager);
const { DebuggerServer } = require("devtools/server/main"); const { DebuggerServer } = require("devtools/server/main");
exports.setupChild = function (a, b, c) { exports.setupChild = function (a, b, c) {

Просмотреть файл

@ -1,3 +1,5 @@
"use strict";
var {Ci} = require("chrome"); var {Ci} = require("chrome");
var Services = require("Services"); var Services = require("Services");

Просмотреть файл

@ -14,6 +14,7 @@ Debugger.Script.prototype.global should return innerize globals, not WindowProxi
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm"); Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this); addDebuggerToGlobal(this);
@ -21,27 +22,26 @@ addDebuggerToGlobal(this);
window.onload = function () { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var iframe = document.createElement("iframe"); let iframe = document.createElement("iframe");
iframe.src = "data:text/html,<script>function glorp() { }<\/script>"; iframe.src = "data:text/html,<script>function glorp() { }<\/script>";
iframe.onload = firstOnLoadHandler; iframe.onload = firstOnLoadHandler;
document.body.appendChild(iframe); document.body.appendChild(iframe);
function firstOnLoadHandler() { function firstOnLoadHandler() {
var dbg = new Debugger; let dbg = new Debugger();
var iframeDO = dbg.addDebuggee(iframe.contentWindow); let iframeDO = dbg.addDebuggee(iframe.contentWindow);
// For sanity: check that the debuggee global is the inner window, // For sanity: check that the debuggee global is the inner window,
// and that the outer window gets a distinct D.O. // 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); ok(iframeDO !== iframeWindowProxyDO);
// The real test: Debugger.Script.prototype.global returns inner windows. // 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(); SimpleTest.finish();
} }
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -15,6 +15,7 @@ element to which code is attached (if any), and how.
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm"); Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this); addDebuggerToGlobal(this);
@ -22,65 +23,65 @@ addDebuggerToGlobal(this);
window.onload = function () { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var log = ''; let log = "";
var doc, dieter, ulrich, isolde, albrecht; let doc, dieter, ulrich, isolde, albrecht;
var dbg, iframeDO, DOFor; let dbg, iframeDO, DOFor;
// Create an iframe to debug. // Create an iframe to debug.
// We can't use a data: URL here, because we want to test script elements // 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 // that refer to the JavaScript via 'src' attributes, and data: documents
// can't refer to those. So we use a separate HTML document. // 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.src = "Debugger.Source.prototype.element.html";
iframe.onload = onLoadHandler; iframe.onload = onLoadHandler;
document.body.appendChild(iframe); document.body.appendChild(iframe);
function onLoadHandler() { function onLoadHandler() {
log += 'l'; log += "l";
// Now that the iframe's window has been created, we can add // Now that the iframe's window has been created, we can add
// it as a debuggee. // it as a debuggee.
dbg = new Debugger; dbg = new Debugger();
dbg.onDebuggerStatement = franzDebuggerHandler; dbg.onDebuggerStatement = franzDebuggerHandler;
iframeDO = dbg.addDebuggee(iframe.contentWindow); iframeDO = dbg.addDebuggee(iframe.contentWindow);
DOFor = iframeDO.makeDebuggeeValue.bind(iframeDO); DOFor = iframeDO.makeDebuggeeValue.bind(iframeDO);
// Send a click event to heidi. // Send a click event to heidi.
doc = iframe.contentWindow.document; doc = iframe.contentWindow.document;
doc.getElementById('heidi').dispatchEvent(new Event('click')); doc.getElementById("heidi").dispatchEvent(new Event("click"));
} }
function franzDebuggerHandler(frame) { function franzDebuggerHandler(frame) {
log += 'f'; log += "f";
// The top stack frame should be franz, belonging to the script element. // The top stack frame should be franz, belonging to the script element.
ok(frame.callee.displayName === 'franz', 'top frame is franz'); ok(frame.callee.displayName === "franz", "top frame is franz");
ok(frame.script.source.element === DOFor(doc.getElementById('franz')), ok(frame.script.source.element === DOFor(doc.getElementById("franz")),
'top frame source belongs to element franz'); "top frame source belongs to element franz");
ok(frame.script.source.elementAttributeName === undefined, ok(frame.script.source.elementAttributeName === undefined,
"top frame source doesn't belong to an attribute"); "top frame source doesn't belong to an attribute");
// The second stack frame should belong to heinrich. // 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"); "second frame source belongs to element heinrich");
ok(frame.older.script.source.elementAttributeName === undefined, ok(frame.older.script.source.elementAttributeName === undefined,
"second frame source doesn't belong to an attribute"); "second frame source doesn't belong to an attribute");
// The next stack frame should belong to heidi's onclick handler. // The next stack frame should belong to heidi's onclick handler.
ok(frame.older.older.script.source.element === DOFor(doc.getElementById('heidi')), ok(frame.older.older.script.source.element === DOFor(doc.getElementById("heidi")),
'third frame source belongs to element heidi'); "third frame source belongs to element heidi");
ok(frame.older.older.script.source.elementAttributeName === 'onclick', ok(frame.older.older.script.source.elementAttributeName === "onclick",
"third frame source belongs to 'onclick' attribute"); "third frame source belongs to 'onclick' attribute");
// Try a dynamically inserted inline script element. // Try a dynamically inserted inline script element.
ulrich = doc.createElement('script'); ulrich = doc.createElement("script");
ulrich.text = 'debugger;' ulrich.text = "debugger;";
dbg.onDebuggerStatement = ulrichDebuggerHandler; dbg.onDebuggerStatement = ulrichDebuggerHandler;
doc.body.appendChild(ulrich); doc.body.appendChild(ulrich);
} }
function ulrichDebuggerHandler(frame) { function ulrichDebuggerHandler(frame) {
log += 'u'; log += "u";
// The top frame should be ulrich's text. // The top frame should be ulrich's text.
ok(frame.script.source.element === DOFor(ulrich), ok(frame.script.source.element === DOFor(ulrich),
@ -89,23 +90,23 @@ window.onload = function () {
"top frame is not on an attribute of ulrich"); "top frame is not on an attribute of ulrich");
// Try a dynamically inserted out-of-line script element. // Try a dynamically inserted out-of-line script element.
isolde = doc.createElement('script'); isolde = doc.createElement("script");
isolde.setAttribute('src', 'Debugger.Source.prototype.element-2.js'); isolde.setAttribute("src", "Debugger.Source.prototype.element-2.js");
isolde.setAttribute('id', 'idolde, my dear'); isolde.setAttribute("id", "idolde, my dear");
dbg.onDebuggerStatement = isoldeDebuggerHandler; dbg.onDebuggerStatement = isoldeDebuggerHandler;
doc.body.appendChild(isolde); doc.body.appendChild(isolde);
} }
function isoldeDebuggerHandler(frame) { function isoldeDebuggerHandler(frame) {
log += 'i'; log += "i";
// The top frame should belong to isolde. // The top frame should belong to isolde.
ok(frame.script.source.element === DOFor(isolde), ok(frame.script.source.element === DOFor(isolde),
"top frame belongs to isolde"); "top frame belongs to isolde");
info("frame.script.source.element is: " + uneval(frame.script.source.element)); info("frame.script.source.element is: " + uneval(frame.script.source.element));
if (typeof frame.script.source.element.unsafeDereference() == 'object') { if (typeof frame.script.source.element.unsafeDereference() == "object") {
info(" toString: " + frame.script.source.element.unsafeDereference()); info(" toString: " + frame.script.source.element.unsafeDereference());
info(" id: " + frame.script.source.element.unsafeDereference().id); info(" id: " + frame.script.source.element.unsafeDereference().id);
} }
ok(frame.script.source.elementAttributeName === undefined, ok(frame.script.source.elementAttributeName === undefined,
@ -114,20 +115,20 @@ window.onload = function () {
uneval(frame.script.source.elementAttributeName)); uneval(frame.script.source.elementAttributeName));
// Try a dynamically created div element with a handler. // Try a dynamically created div element with a handler.
dieter = doc.createElement('div'); dieter = doc.createElement("div");
dieter.setAttribute('id', 'dieter'); dieter.setAttribute("id", "dieter");
dieter.setAttribute('ondrag', 'debugger;'); dieter.setAttribute("ondrag", "debugger;");
dbg.onDebuggerStatement = dieterDebuggerHandler; dbg.onDebuggerStatement = dieterDebuggerHandler;
dieter.dispatchEvent(new Event('drag')); dieter.dispatchEvent(new Event("drag"));
} }
function dieterDebuggerHandler(frame) { function dieterDebuggerHandler(frame) {
log += 'd'; log += "d";
// The top frame should belong to dieter's ondrag handler. // The top frame should belong to dieter's ondrag handler.
ok(frame.script.source.element === DOFor(dieter), ok(frame.script.source.element === DOFor(dieter),
"second event's handler belongs to 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"); "second event's handler is on dieter's 'ondrag' element");
// Try sending an 'onresize' event to the window. // 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 // won't affect propagation. Then, the content event only runs its
// 'debugger' statement when the event is cancelable. It's a kludge. // 'debugger' statement when the event is cancelable. It's a kludge.
dbg.onDebuggerStatement = resizeDebuggerHandler; dbg.onDebuggerStatement = resizeDebuggerHandler;
iframe.contentWindow.dispatchEvent(new Event('resize', { cancelable: true })); iframe.contentWindow.dispatchEvent(new Event("resize", { cancelable: true }));
} }
function resizeDebuggerHandler(frame) { function resizeDebuggerHandler(frame) {
log += 'e'; log += "e";
// The top frame should belong to the body's 'onresize' handler, even // The top frame should belong to the body's 'onresize' handler, even
// though we sent the message to the window and it was handled. // though we sent the message to the window and it was handled.
ok(frame.script.source.element === DOFor(doc.body), ok(frame.script.source.element === DOFor(doc.body),
"onresize event handler belongs to body element"); "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"); "onresize event handler is on body element's 'onresize' attribute");
// In SVG, the event and the attribute that holds that event's handler // In SVG, the event and the attribute that holds that event's handler
// have different names. Debugger.Source.prototype.elementAttributeName // have different names. Debugger.Source.prototype.elementAttributeName
// should report (as one might infer) the attribute name, not the event // should report (as one might infer) the attribute name, not the event
// name. // name.
albrecht = doc.createElementNS('http://www.w3.org/2000/svg', 'svg'); albrecht = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
albrecht.setAttribute('onload', 'debugger;'); albrecht.setAttribute("onload", "debugger;");
dbg.onDebuggerStatement = SVGLoadHandler; dbg.onDebuggerStatement = SVGLoadHandler;
albrecht.dispatchEvent(new Event("SVGLoad")); albrecht.dispatchEvent(new Event("SVGLoad"));
} }
function SVGLoadHandler(frame) { function SVGLoadHandler(frame) {
log += 's'; log += "s";
// The top frame's source should be on albrecht's 'onload' attribute. // The top frame's source should be on albrecht's 'onload' attribute.
ok(frame.script.source.element === DOFor(albrecht), ok(frame.script.source.element === DOFor(albrecht),
"SVGLoad event handler belongs to 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"); "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(); SimpleTest.finish();
} }
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -15,6 +15,7 @@ behave when 'eval' is called with no scripted frames active at all.
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm"); Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this); addDebuggerToGlobal(this);
@ -22,10 +23,10 @@ addDebuggerToGlobal(this);
window.onload = function () { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var dbg, iframeDO, doc, script2DO; let dbg, iframeDO, doc, script2DO;
// Create an iframe to debug. // Create an iframe to debug.
var iframe = document.createElement("iframe"); let iframe = document.createElement("iframe");
iframe.src = "data:text/html,<div>Hi!</div>"; iframe.src = "data:text/html,<div>Hi!</div>";
iframe.onload = onLoadHandler; iframe.onload = onLoadHandler;
document.body.appendChild(iframe); document.body.appendChild(iframe);
@ -33,11 +34,11 @@ window.onload = function () {
function onLoadHandler() { function onLoadHandler() {
// Now that the iframe's window has been created, we can add // Now that the iframe's window has been created, we can add
// it as a debuggee. // it as a debuggee.
dbg = new Debugger; dbg = new Debugger();
iframeDO = dbg.addDebuggee(iframe.contentWindow); iframeDO = dbg.addDebuggee(iframe.contentWindow);
doc = iframe.contentWindow.document; doc = iframe.contentWindow.document;
var script = doc.createElement('script'); let script = doc.createElement("script");
script.text = "setTimeout(eval.bind(null, 'debugger;'), 0);"; script.text = "setTimeout(eval.bind(null, 'debugger;'), 0);";
dbg.onDebuggerStatement = timerHandler; dbg.onDebuggerStatement = timerHandler;
doc.body.appendChild(script); doc.body.appendChild(script);
@ -46,7 +47,7 @@ window.onload = function () {
function timerHandler(frame) { function timerHandler(frame) {
// The top stack frame's source should have an undefined // The top stack frame's source should have an undefined
// introduction script and introduction offset. // introduction script and introduction offset.
var source = frame.script.source; let source = frame.script.source;
ok(source.introductionScript === undefined, ok(source.introductionScript === undefined,
"setTimeout eval introductionScript is undefined"); "setTimeout eval introductionScript is undefined");
ok(source.introductionOffset === 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 // Check that the above isn't just some quirk of iframes, or the
// browser milieu destroying information: an eval script should indeed // browser milieu destroying information: an eval script should indeed
// have proper introduction information. // have proper introduction information.
var script2 = doc.createElement('script'); let script2 = doc.createElement("script");
script2.text = "eval('debugger;');"; script2.text = "eval('debugger;');";
script2DO = iframeDO.makeDebuggeeValue(script2); script2DO = iframeDO.makeDebuggeeValue(script2);
dbg.onDebuggerStatement = evalHandler; dbg.onDebuggerStatement = evalHandler;
@ -65,10 +66,10 @@ window.onload = function () {
function evalHandler(frame) { function evalHandler(frame) {
// The top stack frame's source should be introduced by the script that // The top stack frame's source should be introduced by the script that
// called eval. // called eval.
var source = frame.script.source; let source = frame.script.source;
var frame2 = frame.older; let frame2 = frame.older;
ok(source.introductionType === 'eval', ok(source.introductionType === "eval",
"top frame's source was introduced by 'eval'"); "top frame's source was introduced by 'eval'");
ok(source.introductionScript === frame2.script, ok(source.introductionScript === frame2.script,
"eval frame's introduction script is the older frame's 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 // information. (In the future, we certainly could point at the call
// that inserted the script element into the document; if that happens, // that inserted the script element into the document; if that happens,
// we can update this test.) // we can update this test.)
ok(frame2.script.source.introductionType === 'scriptElement', ok(frame2.script.source.introductionType === "scriptElement",
"older frame has no introduction type"); "older frame has no introduction type");
ok(frame2.script.source.introductionScript === undefined, ok(frame2.script.source.introductionScript === undefined,
"older frame has no introduction script"); "older frame has no introduction script");
@ -90,7 +91,7 @@ window.onload = function () {
SimpleTest.finish(); SimpleTest.finish();
} }
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -16,13 +16,14 @@ JavaScrip appearing in an inline event handler attribute.
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm"); Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this); addDebuggerToGlobal(this);
var dbg; let dbg;
var iframeDO, doc; let iframeDO, doc;
var Tootles, TootlesDO; let Tootles, TootlesDO;
window.onload = function () { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
@ -31,7 +32,7 @@ window.onload = function () {
addTest(function setup() { addTest(function setup() {
// Create an iframe to debug. // Create an iframe to debug.
var iframe = document.createElement("iframe"); let iframe = document.createElement("iframe");
iframe.src = "data:text/html," + iframe.src = "data:text/html," +
"<div id='Tootles' onclick='debugger;'>I'm a DIV!</div>" + "<div id='Tootles' onclick='debugger;'>I'm a DIV!</div>" +
"<script id='Auddie'>function auddie() { debugger; }<\/script>"; "<script id='Auddie'>function auddie() { debugger; }<\/script>";
@ -41,88 +42,84 @@ addTest(function setup() {
function onLoadHandler() { function onLoadHandler() {
// Now that the iframe's window has been created, we can add // Now that the iframe's window has been created, we can add
// it as a debuggee. // it as a debuggee.
dbg = new Debugger; dbg = new Debugger();
iframeDO = dbg.addDebuggee(iframe.contentWindow); iframeDO = dbg.addDebuggee(iframe.contentWindow);
doc = iframe.contentWindow.document; doc = iframe.contentWindow.document;
Tootles = doc.getElementById('Tootles'); Tootles = doc.getElementById("Tootles");
TootlesDO = iframeDO.makeDebuggeeValue(Tootles); TootlesDO = iframeDO.makeDebuggeeValue(Tootles);
runNextTest(); runNextTest();
} }
}); });
// Check the introduction type of in-markup event handler code. // Check the introduction type of in-markup event handler code.
// Send a click event to Tootles, whose handler has a 'debugger' statement, // Send a click event to Tootles, whose handler has a 'debugger' statement,
// and check that script's introduction type. // and check that script's introduction type.
addTest(function ClickOnTootles() { addTest(function ClickOnTootles() {
dbg.onDebuggerStatement = TootlesClickDebugger; dbg.onDebuggerStatement = TootlesClickDebugger;
Tootles.dispatchEvent(new Event('click')); Tootles.dispatchEvent(new Event("click"));
function TootlesClickDebugger(frame) { function TootlesClickDebugger(frame) {
// some sanity checks // some sanity checks
ok(frame.script.source.element === TootlesDO, ok(frame.script.source.element === TootlesDO,
"top frame source belongs to element 'Tootles'"); "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"); "top frame source belongs to 'onclick' attribute");
// And, the actual point of this test: // 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'"); "top frame source's introductionType is 'eventHandler'");
runNextTest(); runNextTest();
} }
}); });
// Check the introduction type of dynamically added event handler code. // Check the introduction type of dynamically added event handler code.
// Add a drag event handler to Tootles as a string, and then send // Add a drag event handler to Tootles as a string, and then send
// Tootles a drag event. // Tootles a drag event.
addTest(function DragTootles() { addTest(function DragTootles() {
dbg.onDebuggerStatement = TootlesDragDebugger; dbg.onDebuggerStatement = TootlesDragDebugger;
Tootles.setAttribute('ondrag', 'debugger;'); Tootles.setAttribute("ondrag", "debugger;");
Tootles.dispatchEvent(new Event('drag')); Tootles.dispatchEvent(new Event("drag"));
function TootlesDragDebugger(frame) { function TootlesDragDebugger(frame) {
// sanity checks // sanity checks
ok(frame.script.source.element === TootlesDO, ok(frame.script.source.element === TootlesDO,
"top frame source belongs to element 'Tootles'"); "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"); "top frame source belongs to 'ondrag' attribute");
// And, the actual point of this test: // 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'"); "top frame source's introductionType is 'eventHandler'");
runNextTest(); runNextTest();
} }
}); });
// Check the introduction type of an in-markup script element. // Check the introduction type of an in-markup script element.
addTest(function checkAuddie() { addTest(function checkAuddie() {
var fnDO = iframeDO.getOwnPropertyDescriptor('auddie').value; let fnDO = iframeDO.getOwnPropertyDescriptor("auddie").value;
var AuddieDO = iframeDO.makeDebuggeeValue(doc.getElementById('Auddie')); let AuddieDO = iframeDO.makeDebuggeeValue(doc.getElementById("Auddie"));
is(fnDO.class, 'Function', is(fnDO.class, "Function",
"Script element 'Auddie' defined function 'auddie'."); "Script element 'Auddie' defined function 'auddie'.");
ok(fnDO.script.source.element === AuddieDO, ok(fnDO.script.source.element === AuddieDO,
"Function auddie's script belongs to script element 'Auddie'"); "Function auddie's script belongs to script element 'Auddie'");
is(fnDO.script.source.elementAttributeName, undefined, is(fnDO.script.source.elementAttributeName, undefined,
"Function auddie's script doesn't belong to any attribute of 'Auddie'"); "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"); "Function auddie's script's source was introduced by a script element");
runNextTest(); runNextTest();
}); });
// Check the introduction type of a dynamically inserted script element. // Check the introduction type of a dynamically inserted script element.
addTest(function InsertRover() { addTest(function InsertRover() {
dbg.onDebuggerStatement = RoverDebugger; dbg.onDebuggerStatement = RoverDebugger;
var rover = doc.createElement('script'); let rover = doc.createElement("script");
var roverDO = iframeDO.makeDebuggeeValue(rover); let roverDO = iframeDO.makeDebuggeeValue(rover);
rover.text = 'debugger;'; rover.text = "debugger;";
doc.body.appendChild(rover); doc.body.appendChild(rover);
function RoverDebugger(frame) { function RoverDebugger(frame) {
@ -133,17 +130,16 @@ addTest(function InsertRover() {
"Rover script doesn't belong to an attribute of Rover"); "Rover script doesn't belong to an attribute of Rover");
// Check the introduction type. // Check the introduction type.
ok(frame.script.source.introductionType === 'scriptElement', ok(frame.script.source.introductionType === "scriptElement",
"Rover script's introduction type is 'scriptElement'"); "Rover script's introduction type is 'scriptElement'");
runNextTest(); runNextTest();
} }
}); });
// Create a XUL document with a script element, and check its introduction type. // Create a XUL document with a script element, and check its introduction type.
addTest(function XULDocumentScript() { addTest(function XULDocumentScript() {
var xulFrame = document.createElement('iframe'); let xulFrame = document.createElement("iframe");
xulFrame.src = "data:application/vnd.mozilla.xul+xml;charset=utf-8," + xulFrame.src = "data:application/vnd.mozilla.xul+xml;charset=utf-8," +
"<?xml version=\"1.0\"?>" + "<?xml version=\"1.0\"?>" +
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'>" + "<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'>" +
@ -155,12 +151,10 @@ addTest(function XULDocumentScript() {
function xulLoaded() { function xulLoaded() {
info("Loaded XUL document"); info("Loaded XUL document");
var xulFrameDO = dbg.addDebuggee(xulFrame.contentWindow); let xulFrameDO = dbg.addDebuggee(xulFrame.contentWindow);
var xulDoc = xulFrame.contentWindow.document; let xulFnDO = xulFrameDO.getOwnPropertyDescriptor("xulScriptFunc").value;
var xulieDO = xulFrameDO.makeDebuggeeValue(xulDoc.getElementById('xulie')); is(typeof xulFnDO, "object", "XUL script element defined 'xulScriptFunc'");
var xulFnDO = xulFrameDO.getOwnPropertyDescriptor('xulScriptFunc').value; is(xulFnDO.class, "Function",
is(typeof xulFnDO, 'object', "XUL script element defined 'xulScriptFunc'");
is(xulFnDO.class, 'Function',
"XUL global 'xulScriptFunc' is indeed a function"); "XUL global 'xulScriptFunc' is indeed a function");
// A XUL document's script elements' code gets shared amongst all // A XUL document's script elements' code gets shared amongst all
@ -169,12 +163,11 @@ addTest(function XULDocumentScript() {
is(xulFnDO.script.source.element, undefined, is(xulFnDO.script.source.element, undefined,
"XUL script code should not be attributed to any individual element"); "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'"); "xulScriptFunc's introduction type is 'scriptElement'");
runNextTest(); runNextTest();
} }
}); });
</script> </script>
</pre> </pre>
</body> </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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
const Ci = Components.interfaces;
window.onload = function () {
const {AnimationsFront} = require("devtools/shared/fronts/animation"); const {AnimationsFront} = require("devtools/shared/fronts/animation");
const {InspectorFront} = require("devtools/shared/fronts/inspector"); const {InspectorFront} = require("devtools/shared/fronts/inspector");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
let gWalker = null; let gWalker = null;
let gClient = null;
let animationsFront = null; let animationsFront = null;
addTest(function setup() { addTest(function setup() {
info ("Setting up inspector and animation actors."); info("Setting up inspector and animation actors.");
let url = document.getElementById("animationContent").href; 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); let inspector = InspectorFront(client, tab);
animationsFront = new AnimationsFront(client, tab); animationsFront = new AnimationsFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
}); });
addAsyncTest(function* testActorLifetime() { addAsyncTest(function* testActorLifetime() {
info("Testing animated node actor");
info ("Testing animated node actor");
let animatedNodeActor = yield gWalker.querySelector(gWalker.rootNode, let animatedNodeActor = yield gWalker.querySelector(gWalker.rootNode,
".animated"); ".animated");
yield animationsFront.getAnimationPlayersForNode(animatedNodeActor); yield animationsFront.getAnimationPlayersForNode(animatedNodeActor);
let animationsActor = DebuggerServer._searchAllConnectionsForActor(animationsFront.actorID); let animationsActor = DebuggerServer
._searchAllConnectionsForActor(animationsFront.actorID);
is(animationsActor.actors.length, 1, is(animationsActor.actors.length, 1,
"AnimationActor have 1 AnimationPlayerActors"); "AnimationActor have 1 AnimationPlayerActors");
info ("Testing AnimationPlayerActors release"); info("Testing AnimationPlayerActors release");
let stillNodeActor = yield gWalker.querySelector(gWalker.rootNode, let stillNodeActor = yield gWalker.querySelector(gWalker.rootNode,
".still"); ".still");
yield animationsFront.getAnimationPlayersForNode(stillNodeActor); yield animationsFront.getAnimationPlayersForNode(stillNodeActor);
is(animationsActor.actors.length, 0, is(animationsActor.actors.length, 0,
"AnimationActor does not have any AnimationPlayerActors anymore"); "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, let multiNodeActor = yield gWalker.querySelector(gWalker.rootNode,
".multi"); ".multi");
yield animationsFront.getAnimationPlayersForNode(multiNodeActor); yield animationsFront.getAnimationPlayersForNode(multiNodeActor);
is(animationsActor.actors.length, 2, is(animationsActor.actors.length, 2,
"AnimationActor has now 2 AnimationPlayerActors"); "AnimationActor has now 2 AnimationPlayerActors");
info ("Testing single animated node actor"); info("Testing single animated node actor");
yield animationsFront.getAnimationPlayersForNode(animatedNodeActor); yield animationsFront.getAnimationPlayersForNode(animatedNodeActor);
is(animationsActor.actors.length, 1, is(animationsActor.actors.length, 1,
"AnimationActor has only one AnimationPlayerActors"); "AnimationActor has only one AnimationPlayerActors");
info ("Testing AnimationPlayerActors release again"); info("Testing AnimationPlayerActors release again");
yield animationsFront.getAnimationPlayersForNode(stillNodeActor); yield animationsFront.getAnimationPlayersForNode(stillNodeActor);
is(animationsActor.actors.length, 0, is(animationsActor.actors.length, 0,
"AnimationActor does not have any AnimationPlayerActors anymore"); "AnimationActor does not have any AnimationPlayerActors anymore");
@ -79,7 +77,6 @@ window.onload = function() {
runNextTest(); runNextTest();
}); });
runNextTest(); runNextTest();
}; };
</script> </script>

Просмотреть файл

@ -1,4 +1,4 @@
<SDOCTYPv HTM.> <!DOCTYPE HTML>
<html> <html>
<!-- <!--
Bug 966991 - Test DebuggerServer.connectToChild Bug 966991 - Test DebuggerServer.connectToChild
@ -12,16 +12,16 @@ Bug 966991 - Test DebuggerServer.connectToChild
<body> <body>
<pre id="test"> <pre id="test">
<script type="application/javascript"> <script type="application/javascript">
"use strict";
let Cu = Components.utils; let Cu = Components.utils;
let Cc = Components.classes;
let Ci = Components.interfaces; let Ci = Components.interfaces;
let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
let { DebuggerClient } = require("devtools/shared/client/main"); let { DebuggerClient } = require("devtools/shared/client/main");
let { DebuggerServer } = require("devtools/server/main"); let { DebuggerServer } = require("devtools/server/main");
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({ SpecialPowers.pushPrefEnv({
@ -31,7 +31,7 @@ window.onload = function() {
["dom.mozBrowserFramesEnabled", true] ["dom.mozBrowserFramesEnabled", true]
] ]
}, runTests); }, runTests);
} };
function runTests() { function runTests() {
// Create a minimal iframe with a message manager // 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 // Register a test actor in the child process so that we can know if and when
// this fake actor is destroyed. // this fake actor is destroyed.
mm.loadFrameScript("data:text/javascript,new " + function FrameScriptScope() { mm.loadFrameScript("data:text/javascript,new " + function FrameScriptScope() {
/* eslint-disable no-shadow */
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const { DebuggerServer } = require("devtools/server/main"); const { DebuggerServer } = require("devtools/server/main");
/* eslint-enable no-shadow */
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(); DebuggerServer.init();
} }
function TestActor() {dump("instanciate test actor\n");} function TestActor() {
dump("instanciate test actor\n");
}
TestActor.prototype = { TestActor.prototype = {
actorPrefix: "test", actorPrefix: "test",
@ -59,7 +63,7 @@ function runTests() {
sendAsyncMessage("test-actor-destroyed", null); sendAsyncMessage("test-actor-destroyed", null);
}, },
hello: function () { hello: function () {
return {msg:"world"}; return {msg: "world"};
} }
}; };
TestActor.prototype.requestTypes = { TestActor.prototype.requestTypes = {
@ -90,7 +94,6 @@ function runTests() {
to: actor.testActor, to: actor.testActor,
type: "hello", type: "hello",
}, function (response) { }, function (response) {
// Then close the client. That should end up cleaning our test actor // Then close the client. That should end up cleaning our test actor
client.close(); client.close();
@ -113,7 +116,8 @@ function runTests() {
let client = new DebuggerClient(transport); let client = new DebuggerClient(transport);
DebuggerServer.connectToChild(conn, iframe).then(actor => { DebuggerServer.connectToChild(conn, iframe).then(actor => {
ok(actor.testActor, "Got a test actor for the second connection"); 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); client.close(cleanup);
}); });
@ -122,12 +126,11 @@ function runTests() {
function cleanup() { function cleanup() {
DebuggerServer.destroy(); DebuggerServer.destroy();
iframe.remove(); iframe.remove();
SimpleTest.finish() SimpleTest.finish();
} }
firstClient(); firstClient();
} }
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -12,70 +12,89 @@ Bug 898485 - [app manager] Implement an abstract connection manager
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var Cu = Components.utils; const Cu = Components.utils;
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
var Services = require("Services"); const Services = require("Services");
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); 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) => { 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(); let c1 = ConnectionManager.createConnection();
var c2 = ConnectionManager.createConnection(); let c2 = ConnectionManager.createConnection();
is(ConnectionManager.connections[orgCount], c1, "Connection 1 registered"); is(ConnectionManager.connections[orgCount], c1, "Connection 1 registered");
is(ConnectionManager.connections[orgCount + 1], c2, "Connection 2 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"); 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"; let eventsRef = "connecting connected disconnecting disconnected host-changed"
var events = []; + " disconnected timeout destroyed";
let events = [];
var s = Connection.Status; let s = Connection.Status;
is(c.status, s.DISCONNECTED, "disconnected"); 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.CONNECTING, function (e) {
c.once(Connection.Events.CONNECTED, function(e) { events.push(e); is(c.status, s.CONNECTED, "connected"); c.disconnect()}); events.push(e);
c.once(Connection.Events.DISCONNECTING, function(e) { events.push(e); is(c.status, s.DISCONNECTING, "disconnecting"); }); is(c.status, s.CONNECTING, "connecting");
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.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(); 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() { function testError() {
c.once(Connection.Events.DISCONNECTED, function(e) { c.once(Connection.Events.DISCONNECTED, function (e) {
events.push(e); events.push(e);
testKeepConnecting(); testKeepConnecting();
}); });
c.once(Connection.Events.HOST_CHANGED, function(e) { c.once(Connection.Events.HOST_CHANGED, function (e) {
events.push(e); events.push(e);
c.connect(); c.connect();
}); });
@ -86,16 +105,17 @@ window.onload = function() {
function testKeepConnecting() { function testKeepConnecting() {
// ensure that keepConnecting keep trying connecting // ensure that keepConnecting keep trying connecting
// until the connection attempts timeout // 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); Services.prefs.setIntPref("devtools.debugger.remote-timeout", 1000);
c.once("timeout", function (e) { c.once("timeout", function (e) {
events.push(e); events.push(e);
Services.prefs.setIntPref("devtools.debugger.remote-timeout", originalTimeout); Services.prefs.setIntPref(prefRemoteTimeout, originalTimeout);
ConnectionManager.destroyConnection(c); ConnectionManager.destroyConnection(c);
}); });
c.keepConnecting = true; c.keepConnecting = true;
var port = ConnectionManager.getFreeTCPPort(); let port = ConnectionManager.getFreeTCPPort();
ok(parseInt(port), "Free TCP port looks like a port number"); ok(parseInt(port, 10), "Free TCP port looks like a port number");
c.port = port; c.port = port;
c.host = "locahost"; c.host = "locahost";
c.connect(); c.connect();
@ -106,13 +126,10 @@ window.onload = function() {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish(); SimpleTest.finish();
} }
}); });
ConnectionManager.destroyConnection(c1); ConnectionManager.destroyConnection(c1);
};
}
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -25,14 +25,15 @@ Test that css-logic handles media-queries correctly
<body> <body>
<div></div> <div></div>
<script type="application/javascript"> <script type="application/javascript">
"use strict";
window.onload = function() { window.onload = function () {
var { classes: Cc, utils: Cu, interfaces: Ci } = Components; const { classes: Cc, utils: Cu, interfaces: Ci } = Components;
const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"] const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils); .getService(Ci.inIDOMUtils);
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var Services = require("Services"); const Services = require("Services");
const {CssLogic} = require("devtools/server/css-logic"); const {CssLogic} = require("devtools/server/css-logic");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
@ -55,8 +56,7 @@ Test that css-logic handles media-queries correctly
"rule.source gives correct output for rule 2"); "rule.source gives correct output for rule 2");
SimpleTest.finish(); SimpleTest.finish();
} };
</script> </script>
</body> </body>
</html> </html>

Просмотреть файл

@ -10,9 +10,10 @@ Test that css-logic calculates CSS specificity properly
</head> </head>
<body style="background:blue;"> <body style="background:blue;">
<script type="application/javascript"> <script type="application/javascript">
"use strict";
window.onload = function() { window.onload = function () {
var {utils: Cu, classes: Cc, interfaces: Ci} = Components; const {utils: Cu, classes: Cc, interfaces: Ci} = Components;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const {CssLogic, CssSelector} = require("devtools/server/css-logic"); 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 cssRule = cssSheet.domSheet.cssRules[0];
let selectors = CssLogic.getSelectors(cssRule); 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++) { for (let i = 0; i < selectors.length; i++) {
let selectorText = selectors[i]; let selectorText = selectors[i];
info("Testing selector " + selectorText); info("Testing selector " + selectorText);
@ -66,7 +67,7 @@ Test that css-logic calculates CSS specificity properly
let selector = new CssSelector(cssRule, selectorText, i); let selector = new CssSelector(cssRule, selectorText, i);
let expected = getExpectedSpecificity(selectorText); let expected = getExpectedSpecificity(selectorText);
let specificity = DOMUtils.getSpecificity(selector.cssRule, let specificity = DOMUtils.getSpecificity(selector.cssRule,
selector.selectorIndex) selector.selectorIndex);
is(specificity, expected, is(specificity, expected,
'Selector "' + selectorText + '" has a specificity of ' + 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)."); "Element styles have specificity of 0x01000000 (16777216).");
SimpleTest.finish(); SimpleTest.finish();
} };
</script> </script>
</body> </body>
</html> </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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
"use strict";
const {CssLogic} = require("devtools/server/css-logic"); const {CssLogic} = require("devtools/server/css-logic");
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
addTest(function getComputedStyle() { addTest(function getComputedStyle() {
let node = document.querySelector("#computed-style"); 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)"); "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)"); "10px", "Computed style on a normal node works (height)");
let firstChild = new _documentWalker(node, window).firstChild(); let firstChild = new _documentWalker(node, window).firstChild();
is (CssLogic.getComputedStyle(firstChild).getPropertyValue("content"), is(CssLogic.getComputedStyle(firstChild).getPropertyValue("content"),
"\"before\"", "Computed style on a ::before node works (content)"); "\"before\"", "Computed style on a ::before node works (content)");
let lastChild = new _documentWalker(node, window).lastChild(); let lastChild = new _documentWalker(node, window).lastChild();
is (CssLogic.getComputedStyle(lastChild).getPropertyValue("content"), is(CssLogic.getComputedStyle(lastChild).getPropertyValue("content"),
"\"after\"", "Computed style on a ::after node works (content)"); "\"after\"", "Computed style on a ::after node works (content)");
runNextTest(); runNextTest();
}); });
addTest(function getBindingElementAndPseudo() { addTest(function getBindingElementAndPseudo() {
let node = document.querySelector("#computed-style"); let node = document.querySelector("#computed-style");
var {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node); let {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node);
is (bindingElement, node, is(bindingElement, node,
"Binding element is the node itself for a normal node"); "Binding element is the node itself for a normal node");
ok (!pseudo, "Pseudo is null for a normal node"); ok(!pseudo, "Pseudo is null for a normal node");
let firstChild = new _documentWalker(node, window).firstChild(); let firstChild = new _documentWalker(node, window).firstChild();
var {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(firstChild); ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(firstChild));
is (bindingElement, node, is(bindingElement, node,
"Binding element is the parent for a pseudo node"); "Binding element is the parent for a pseudo node");
is (pseudo, ":before", "Pseudo is correct for a ::before node"); is(pseudo, ":before", "Pseudo is correct for a ::before node");
let lastChild = new _documentWalker(node, window).lastChild(); let lastChild = new _documentWalker(node, window).lastChild();
var {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(lastChild); ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(lastChild));
is (bindingElement, node, is(bindingElement, node,
"Binding element is the parent for a pseudo node"); "Binding element is the parent for a pseudo node");
is (pseudo, ":after", "Pseudo is correct for a ::after node"); is(pseudo, ":after", "Pseudo is correct for a ::after node");
runNextTest(); runNextTest();
}); });

Просмотреть файл

@ -10,19 +10,21 @@ Bug 1265798 - Replace inIDOMUtils.cssPropertyIsShorthand
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
window.onload = function () {
const { initCssProperties, getCssProperties } = const { initCssProperties, getCssProperties } =
require("devtools/shared/fronts/css-properties"); require("devtools/shared/fronts/css-properties");
function promiseAttachUrl (url) { function promiseAttachUrl(url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
if (err) { if (err) {
return reject(err); return reject(err);
} }
resolve({client, tab, doc}); return resolve({client, tab, doc});
}); });
}) });
} }
function toSortedString(array) { function toSortedString(array) {
@ -63,7 +65,7 @@ window.onload = function() {
is(cssProperties, cssPropertiesA, is(cssProperties, cssPropertiesA,
"Multiple calls with the same toolbox returns the same object."); "Multiple calls with the same toolbox returns the same object.");
isnot(cssProperties, cssPropertiesB, isnot(cssProperties, cssPropertiesB,
"Multiple calls with the different toolboxes return different "+ "Multiple calls with the different toolboxes return different " +
" objects."); " objects.");
ok(cssProperties.isKnown("border"), ok(cssProperties.isKnown("border"),
@ -81,13 +83,13 @@ window.onload = function() {
ok(!cssProperties.isKnown("--foo bar"), ok(!cssProperties.isKnown("--foo bar"),
"A CSS variable with spaces fails"); "A CSS variable with spaces fails");
is(toSortedString(cssProperties.getValues('margin')), is(toSortedString(cssProperties.getValues("margin")),
toSortedString(["auto","calc","inherit","initial","unset"]), toSortedString(["auto", "calc", "inherit", "initial", "unset"]),
"Can get values for the CSS margin."); "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."); "Unknown values return an empty array.");
const bgColorValues = cssProperties.getValues('background-color'); const bgColorValues = cssProperties.getValues("background-color");
ok(bgColorValues.includes("blanchedalmond"), ok(bgColorValues.includes("blanchedalmond"),
"A property with color values includes blanchedalmond."); "A property with color values includes blanchedalmond.");
ok(bgColorValues.includes("papayawhip"), ok(bgColorValues.includes("papayawhip"),
@ -111,7 +113,7 @@ window.onload = function() {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
</script> </script>
</head> </head>
<body> <body>

Просмотреть файл

@ -12,37 +12,38 @@ Bug 895360 - [app manager] Device meta data actor
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
var Cu = Components.utils; const Cu = Components.utils;
var Cc = Components.classes; const Cc = Components.classes;
var Ci = Components.interfaces; const Ci = Components.interfaces;
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {DebuggerClient} = require("devtools/shared/client/main"); const {DebuggerClient} = require("devtools/shared/client/main");
var {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
var Services = require("Services"); const Services = require("Services");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var {getDeviceFront} = require("devtools/shared/fronts/device"); const {getDeviceFront} = require("devtools/shared/fronts/device");
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
} }
var client = new DebuggerClient(DebuggerServer.connectPipe()); let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() { client.connect().then(function onConnect() {
client.listTabs(function onListTabs(aResponse) { client.listTabs(function onListTabs(response) {
var d = getDeviceFront(client, aResponse); let d = getDeviceFront(client, response);
var desc; let desc;
var appInfo = Services.appinfo; let appInfo = Services.appinfo;
var utils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let localDesc = {
var localDesc = {
appid: appInfo.ID, appid: appInfo.ID,
vendor: appInfo.vendor, vendor: appInfo.vendor,
name: appInfo.name, name: appInfo.name,
@ -53,38 +54,38 @@ window.onload = function() {
geckobuildid: appInfo.platformBuildID, geckobuildid: appInfo.platformBuildID,
geckoversion: appInfo.platformVersion, geckoversion: appInfo.platformVersion,
useragent: window.navigator.userAgent, 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, os: appInfo.OS,
processor: appInfo.XPCOMABI.split("-")[0], processor: appInfo.XPCOMABI.split("-")[0],
compiler: appInfo.XPCOMABI.split("-")[1], compiler: appInfo.XPCOMABI.split("-")[1],
dpi: utils.displayDPI, dpi: utils.displayDPI,
width: window.screen.width, width: window.screen.width,
height: window.screen.height height: window.screen.height
} };
function checkValues() { function checkValues() {
for (var key in localDesc) { for (let key in localDesc) {
is(desc[key], localDesc[key], "valid field (" + key + ")"); is(desc[key], localDesc[key], "valid field (" + key + ")");
} }
var currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile); let currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile);
var profileDir = currProfD.path; let profileDir = currProfD.path;
ok(profileDir.indexOf(desc.profile.length > 0 && desc.profile) != -1, "valid profile name"); ok(profileDir.indexOf(desc.profile.length > 0 && desc.profile) != -1,
"valid profile name");
client.close().then(() => { client.close().then(() => {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish() SimpleTest.finish();
}); });
} }
d.getDescription().then(function (v) {
d.getDescription().then((v) => desc = v) desc = v;
.then(checkValues); }).then(checkValues);
}); });
}); });
};
}
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -14,43 +14,45 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
<pre id="test"> <pre id="test">
<script type="application/javascript" src="./director-helpers.js"></script> <script type="application/javascript" src="./director-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const WAIT_EVENT_TIMEOUT = 3000; "use strict";
window.onload = function() { window.onload = function () {
Task.spawn(function* () { Task.spawn(function* () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var tests = [ let tests = [
runDirectorRegistryActorTest runDirectorRegistryActorTest
].map((testCase) => { ].map((testCase) => {
return function* () { return function* () {
setup(); setup();
yield testCase().then(null, (e) => { yield testCase().then(null, (e) => {
console.error("Exception during testCase run", 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(); teardown();
}; };
}); });
for (var test of tests) { for (let test of tests) {
yield test(); yield test();
} }
}).then( }).then(
function success() { function success() {
SimpleTest.finish() SimpleTest.finish();
}, },
function error(e) { function error(e) {
console.error("Exception during testCase run", 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(); SimpleTest.finish();
} }
); );
}; };
var targetWin = null; let targetWin = null;
function setup() { function setup() {
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
@ -70,30 +72,26 @@ function teardown() {
} }
} }
/***********************************
* test cases
**********************************/
function runDirectorRegistryActorTest() { function runDirectorRegistryActorTest() {
let testDirectorScriptOptions = { let testDirectorScriptOptions = {
scriptCode: "(" + (function() { scriptCode: "(" + (function () {
module.exports = function({port}) { module.exports = function ({port}) {
port.onmessage = function(evt) { port.onmessage = function (evt) {
// echo messages // echo messages
evt.target.postMessage(evt.data); evt.target.postMessage(evt.data);
}; };
}; };
}).toString() + ")();", }).toString() + ")();",
scriptOptions: {} scriptOptions: {}
} };
return Task.spawn(function* () { return Task.spawn(function* () {
let { client, root } = yield newConnectedDebuggerClient(); 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"); is(installed, true, "DirectorManager.install returns true");
let list = yield directorRegistryClient.list(); let list = yield directorRegistryClient.list();
@ -106,8 +104,6 @@ function runDirectorRegistryActorTest() {
yield client.close(); yield client.close();
}); });
} }
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -14,24 +14,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
<pre id="test"> <pre id="test">
<script type="application/javascript" src="./director-helpers.js"></script> <script type="application/javascript" src="./director-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
window.onload = function () {
Task.spawn(function* () { Task.spawn(function* () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var tests = [ let tests = [
runPropagateDirectorScriptsToChildTest, runPropagateDirectorScriptsToChildTest,
].map((testCase) => { ].map((testCase) => {
return function* () { return function* () {
setup(); setup();
yield testCase().then(null, (e) => { 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(); teardown();
}; };
}); });
for (var test of tests) { for (let test of tests) {
yield test(); yield test();
} }
@ -43,7 +46,7 @@ function setup() {
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(() => true); DebuggerServer.init(() => true);
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
SimpleTest.registerCleanupFunction(function() { SimpleTest.registerCleanupFunction(function () {
DebuggerServer.destroy(); DebuggerServer.destroy();
}); });
} }
@ -54,10 +57,6 @@ function teardown() {
DebuggerServer.destroy(); DebuggerServer.destroy();
} }
/***********************************
* test cases
**********************************/
function runPropagateDirectorScriptsToChildTest() { function runPropagateDirectorScriptsToChildTest() {
let iframe = document.createElement("iframe"); let iframe = document.createElement("iframe");
iframe.mozbrowser = true; iframe.mozbrowser = true;
@ -65,9 +64,9 @@ function runPropagateDirectorScriptsToChildTest() {
document.body.appendChild(iframe); document.body.appendChild(iframe);
return Task.spawn(function* () { 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 // install a director script
yield directorRegistryClient.install("testPropagatedDirectorScript", { yield directorRegistryClient.install("testPropagatedDirectorScript", {
@ -75,19 +74,19 @@ function runPropagateDirectorScriptsToChildTest() {
scriptOptions: {} scriptOptions: {}
}); });
var conn = transport._serverConnection; let conn = transport._serverConnection;
var childActor = yield DebuggerServer.connectToChild(conn, iframe); let childActor = yield DebuggerServer.connectToChild(conn, iframe);
ok(typeof childActor.directorManagerActor !== "undefined", ok(typeof childActor.directorManagerActor !== "undefined",
"childActor.directorActor should be defined"); "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 && ok(directorScriptList.installed.length === 1 &&
directorScriptList.installed[0] === "testPropagatedDirectorScript", directorScriptList.installed[0] === "testPropagatedDirectorScript",
"director scripts propagated correctly") "director scripts propagated correctly");
yield client.close(); yield client.close();
}); });

Просмотреть файл

@ -16,6 +16,7 @@ object.
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
Components.utils.import("resource://gre/modules/jsdebugger.jsm"); Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this); addDebuggerToGlobal(this);
@ -23,46 +24,49 @@ addDebuggerToGlobal(this);
window.onload = function () { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var iframe = document.createElement("iframe"); let iframe = document.createElement("iframe");
iframe.src = "data:text/html,<script>var me = 'page 1';<\/script>"; iframe.src = "data:text/html,<script>var me = 'page 1';<\/script>";
iframe.onload = firstOnLoadHandler; iframe.onload = firstOnLoadHandler;
document.body.appendChild(iframe); document.body.appendChild(iframe);
function firstOnLoadHandler() { function firstOnLoadHandler() {
var dbg = new Debugger; let dbg = new Debugger();
var page1DO = dbg.addDebuggee(iframe.contentWindow); let page1DO = dbg.addDebuggee(iframe.contentWindow);
iframe.src = "data:text/html,<script>var me = 'page 2';<\/script>"; iframe.src = "data:text/html,<script>var me = 'page 2';<\/script>";
iframe.onload = function () { 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 !== page2DO, "the two pages' globals get distinct D.O's");
ok(page1DO.unsafeDereference() === page2DO.unsafeDereference(), ok(page1DO.unsafeDereference() === page2DO.unsafeDereference(),
"unwrapping page1DO and page2DO outerizes both, yielding the same outer window"); "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(page1DO.executeInGlobal("me").return,
is(page2DO.executeInGlobal('me').return, 'page 2', "page2DO refers to current page"); "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'"); "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'"); "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'"); "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'"); "page 2: Debugger.Object.prototype.executeInGlobal should outerize 'this'");
// Debugger doesn't let one use outer windows as globals. You have to innerize. // Debugger doesn't let one use outer windows as globals. You have to innerize.
var outerDO = page1DO.makeDebuggeeValue(page1DO.unsafeDereference()); let outerDO = page1DO.makeDebuggeeValue(page1DO.unsafeDereference());
ok(outerDO !== page1DO, "outer window gets its own D.O, distinct from page 1's global"); ok(outerDO !== page1DO,
ok(outerDO !== page2DO, "outer window gets its own D.O, distinct from page 2's global"); "outer window gets its own D.O, distinct from page 1's global");
SimpleTest.doesThrow(function () { outerDO.executeInGlobal('me'); }, 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"); "outer window D.Os can't be used as globals");
SimpleTest.finish(); SimpleTest.finish();
} };
} }
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -12,30 +12,29 @@ Bug 1007200 - Create a framerate actor
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
var Cu = Components.utils; const Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;
var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
var Services = require("Services"); const Services = require("Services");
var { DebuggerClient } = require("devtools/shared/client/main"); const { DebuggerClient } = require("devtools/shared/client/main");
var { DebuggerServer } = require("devtools/server/main"); const { DebuggerServer } = require("devtools/server/main");
// Always log packets when running tests. // Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true); Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(function() { SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log"); Services.prefs.clearUserPref("devtools.debugger.log");
}); });
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/shared/fronts/framerate"); const { FramerateFront } = require("devtools/shared/fronts/framerate");
function plotFPS(ticks, interval = 100, clamp = 60) { function plotFPS(ticks, interval = 100, clamp = 60) {
var timeline = []; let timeline = [];
var totalTicks = ticks.length; let totalTicks = ticks.length;
// If the refresh driver didn't get a chance to tick before the // If the refresh driver didn't get a chance to tick before the
// recording was stopped, assume framerate was 0. // recording was stopped, assume framerate was 0.
@ -45,19 +44,19 @@ window.onload = function() {
return timeline; return timeline;
} }
var frameCount = 0; let frameCount = 0;
var prevTime = ticks[0]; let prevTime = ticks[0];
for (var i = 1; i < totalTicks; i++) { for (let i = 1; i < totalTicks; i++) {
var currTime = ticks[i]; let currTime = ticks[i];
frameCount++; frameCount++;
var elapsedTime = currTime - prevTime; let elapsedTime = currTime - prevTime;
if (elapsedTime < interval) { if (elapsedTime < interval) {
continue; 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: prevTime, value: framerate });
timeline.push({ delta: currTime, value: framerate }); timeline.push({ delta: currTime, value: framerate });
@ -66,20 +65,21 @@ window.onload = function() {
} }
return timeline; return timeline;
}; }
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
} }
var client = new DebuggerClient(DebuggerServer.connectPipe()); let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() { client.connect().then(function onConnect() {
client.listTabs(function onListTabs(aResponse) { client.listTabs(function onListTabs(response) {
var form = aResponse.tabs[aResponse.selected]; let form = response.tabs[response.selected];
var front = FramerateFront(client, form); let front = FramerateFront(client, form);
window.setTimeout(() => { window.setTimeout(() => {
/* eslint-disable max-nested-callbacks */
front.startRecording().then(() => { front.startRecording().then(() => {
window.setTimeout(() => { window.setTimeout(() => {
front.stopRecording().then(rawData => { front.stopRecording().then(rawData => {
@ -87,6 +87,7 @@ window.onload = function() {
}); });
}, 1000); }, 1000);
}); });
/* eslint-enable max-nested-callbacks */
}, 1000); }, 1000);
}); });
}); });
@ -94,15 +95,15 @@ window.onload = function() {
function onRecordingStopped(front, rawData) { function onRecordingStopped(front, rawData) {
ok(rawData, "There should be a recording available."); ok(rawData, "There should be a recording available.");
var timeline = plotFPS(rawData); let timeline = plotFPS(rawData);
ok(timeline.length >= 2, ok(timeline.length >= 2,
"There should be at least one measurement available, with two entries."); "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) { for (let i = 0; i < timeline.length; i += 2) {
var currTimeStart = timeline[i].delta; let currTimeStart = timeline[i].delta;
var currTimeEnd = timeline[i + 1].delta; let currTimeEnd = timeline[i + 1].delta;
info("Testing delta: " + currTimeStart + " vs. " + currTimeEnd); info("Testing delta: " + currTimeStart + " vs. " + currTimeEnd);
ok(currTimeStart < currTimeEnd, ok(currTimeStart < currTimeEnd,
@ -113,28 +114,24 @@ window.onload = function() {
prevTimeStart = currTimeEnd; prevTimeStart = currTimeEnd;
} }
var prevFramerateValue = -1; for (let i = 0; i < timeline.length; i += 2) {
let currFramerateStart = timeline[i].value;
for (var i = 0; i < timeline.length; i += 2) { let currFramerateEnd = timeline[i + 1].value;
var currFramerateStart = timeline[i].value;
var currFramerateEnd = timeline[i + 1].value;
info("Testing framerate: " + currFramerateStart); info("Testing framerate: " + currFramerateStart);
is(currFramerateStart, currFramerateEnd, is(currFramerateStart, currFramerateEnd,
"The start and end framerate values should be equal."); "The start and end framerate values should be equal.");
is(typeof currFramerateStart, "number", "All values should be numbers."); is(typeof currFramerateStart, "number", "All values should be numbers.");
ok(currFramerateStart <= 60, "All values were correctly clamped.") ok(currFramerateStart <= 60, "All values were correctly clamped.");
prevFramerateValue = currFramerateStart;
} }
client.close().then(() => { client.close().then(() => {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish() SimpleTest.finish();
}); });
} }
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -12,30 +12,29 @@ Bug 1007200 - Create a framerate actor
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
var Cu = Components.utils; const Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {DebuggerClient} = require("devtools/shared/client/main"); const {DebuggerClient} = require("devtools/shared/client/main");
var {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
var Services = require("Services"); const Services = require("Services");
// Always log packets when running tests. // Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true); Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(function() { SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log"); Services.prefs.clearUserPref("devtools.debugger.log");
}); });
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/shared/fronts/framerate"); const {FramerateFront} = require("devtools/shared/fronts/framerate");
function plotFPS(ticks, interval = 100, clamp = 60) { function plotFPS(ticks, interval = 100, clamp = 60) {
var timeline = []; let timeline = [];
var totalTicks = ticks.length; let totalTicks = ticks.length;
// If the refresh driver didn't get a chance to tick before the // If the refresh driver didn't get a chance to tick before the
// recording was stopped, assume framerate was 0. // recording was stopped, assume framerate was 0.
@ -45,19 +44,19 @@ window.onload = function() {
return timeline; return timeline;
} }
var frameCount = 0; let frameCount = 0;
var prevTime = ticks[0]; let prevTime = ticks[0];
for (var i = 1; i < totalTicks; i++) { for (let i = 1; i < totalTicks; i++) {
var currTime = ticks[i]; let currTime = ticks[i];
frameCount++; frameCount++;
var elapsedTime = currTime - prevTime; let elapsedTime = currTime - prevTime;
if (elapsedTime < interval) { if (elapsedTime < interval) {
continue; 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: prevTime, value: framerate });
timeline.push({ delta: currTime, value: framerate }); timeline.push({ delta: currTime, value: framerate });
@ -66,24 +65,24 @@ window.onload = function() {
} }
return timeline; return timeline;
}; }
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
} }
var client = new DebuggerClient(DebuggerServer.connectPipe()); let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() { client.connect().then(function onConnect() {
client.listTabs(function onListTabs(aResponse) { client.listTabs(function onListTabs(response) {
var form = aResponse.tabs[aResponse.selected]; let form = response.tabs[response.selected];
var front = FramerateFront(client, form); let front = FramerateFront(client, form);
front.stopRecording().then(rawData => { front.stopRecording().then(rawData => {
ok(rawData, "There should be a recording available."); ok(rawData, "There should be a recording available.");
is(rawData.length, 0, "...but it should be empty."); is(rawData.length, 0, "...but it should be empty.");
var timeline = plotFPS(rawData); let timeline = plotFPS(rawData);
is(timeline.length, 2, is(timeline.length, 2,
"There should be one measurement plotted, with two entries."); "There should be one measurement plotted, with two entries.");
@ -99,14 +98,15 @@ window.onload = function() {
is(timeline[1].value, 0, is(timeline[1].value, 0,
"The last framerate value should be 0."); "The last framerate value should be 0.");
// eslint-disable-next-line max-nested-callbacks
client.close().then(() => { client.close().then(() => {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish() SimpleTest.finish();
}); });
}); });
}); });
}); });
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -12,47 +12,48 @@ Bug 1023018 - Tests whether or not the framerate actor can handle time ranges.
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
var Cu = Components.utils; const Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {DebuggerClient} = require("devtools/shared/client/main"); const {DebuggerClient} = require("devtools/shared/client/main");
var {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
var Services = require("Services"); const Services = require("Services");
// Always log packets when running tests. // Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true); Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(function() { SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log"); Services.prefs.clearUserPref("devtools.debugger.log");
}); });
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/shared/fronts/framerate"); const {FramerateFront} = require("devtools/shared/fronts/framerate");
var START_TICK = 2000; const START_TICK = 2000;
var STOP_TICK = 3000; const STOP_TICK = 3000;
var TOTAL_TIME = 5000; const TOTAL_TIME = 5000;
if (!DebuggerServer.initialized) { if (!DebuggerServer.initialized) {
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
} }
var client = new DebuggerClient(DebuggerServer.connectPipe()); let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() { client.connect().then(function onConnect() {
client.listTabs(function onListTabs(aResponse) { client.listTabs(function onListTabs(response) {
var form = aResponse.tabs[aResponse.selected]; let form = response.tabs[response.selected];
var front = FramerateFront(client, form); let front = FramerateFront(client, form);
front.startRecording().then(() => { front.startRecording().then(() => {
/* eslint-disable max-nested-callbacks */
window.setTimeout(() => { window.setTimeout(() => {
front.stopRecording(START_TICK, STOP_TICK).then(rawData => { front.stopRecording(START_TICK, STOP_TICK).then(rawData => {
onRecordingStopped(front, rawData); onRecordingStopped(front, rawData);
}); });
}, TOTAL_TIME); }, TOTAL_TIME);
/* eslint-enable max-nested-callbacks */
}); });
}); });
}); });
@ -65,17 +66,17 @@ window.onload = function() {
ok(!rawData.find(e => e > STOP_TICK), ok(!rawData.find(e => e > STOP_TICK),
"There should be no tick after 3000ms."); "There should be no tick after 3000ms.");
for (var tick of rawData) { for (let tick of rawData) {
info("Testing tick: " + tick); info("Testing tick: " + tick);
is(typeof tick, "number", "All values should be numbers."); is(typeof tick, "number", "All values should be numbers.");
} }
client.close().then(() => { client.close().then(() => {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish() SimpleTest.finish();
}); });
} }
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -13,26 +13,28 @@ Bug 1023018 - Tests if the framerate actor keeps recording after navigations.
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/shared/fronts/framerate"); const {FramerateFront} = require("devtools/shared/fronts/framerate");
var {TargetFactory} = require("devtools/client/framework/target"); const {TargetFactory} = require("devtools/client/framework/target");
var url = document.getElementById("testContent").href; let url = document.getElementById("testContent").href;
attachURL(url, onTab); attachURL(url, onTab);
function onTab(_, client, form, contentDoc) { function onTab(_, client, form, contentDoc) {
var contentWin = contentDoc.defaultView; let contentWin = contentDoc.defaultView;
var chromeWin = Services.wm.getMostRecentWindow("navigator:browser"); let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
var selectedTab = chromeWin.gBrowser.selectedTab; let selectedTab = chromeWin.gBrowser.selectedTab;
var target = TargetFactory.forTab(selectedTab); let target = TargetFactory.forTab(selectedTab);
var front = FramerateFront(client, form); let front = FramerateFront(client, form);
front.startRecording().then(() => { front.startRecording().then(() => {
window.setTimeout(() => { window.setTimeout(() => {
front.getPendingTicks().then(firstBatch => { front.getPendingTicks().then(firstBatch => {
/* eslint-disable max-nested-callbacks */
target.once("will-navigate", () => { target.once("will-navigate", () => {
window.setTimeout(() => { window.setTimeout(() => {
front.stopRecording().then(secondBatch => { front.stopRecording().then(secondBatch => {
@ -40,6 +42,7 @@ window.onload = function() {
}); });
}, 1000); }, 1000);
}); });
/* eslint-enable max-nested-callbacks */
contentWin.location.reload(); contentWin.location.reload();
}); });
}, 1000); }, 1000);
@ -50,7 +53,7 @@ window.onload = function() {
ok(firstBatch, "There should be a first batch recording available."); ok(firstBatch, "There should be a first batch recording available.");
ok(secondBatch, "There should be a second 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); info("Difference in ticks: " + diff);
ok(diff > 0, "More ticks should be recorded in the second batch."); ok(diff > 0, "More ticks should be recorded in the second batch.");
@ -61,10 +64,10 @@ window.onload = function() {
client.close().then(() => { client.close().then(() => {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish() SimpleTest.finish();
}); });
} }
} };
</script> </script>
</pre> </pre>
<a id="testContent" target="_blank" href="inspector_getImageData.html">Test Document</a> <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> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
var Cu = Components.utils; let Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
var {DebuggerClient} = require("devtools/shared/client/main"); const {DebuggerClient} = require("devtools/shared/client/main");
var {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
var Services = require("Services"); const Services = require("Services");
// Always log packets when running tests. // Always log packets when running tests.
Services.prefs.setBoolPref("devtools.debugger.log", true); Services.prefs.setBoolPref("devtools.debugger.log", true);
SimpleTest.registerCleanupFunction(function() { SimpleTest.registerCleanupFunction(function () {
Services.prefs.clearUserPref("devtools.debugger.log"); Services.prefs.clearUserPref("devtools.debugger.log");
}); });
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/shared/fronts/framerate"); const {FramerateFront} = require("devtools/shared/fronts/framerate");
DebuggerServer.init(); DebuggerServer.init();
DebuggerServer.addBrowserActors(); DebuggerServer.addBrowserActors();
var client = new DebuggerClient(DebuggerServer.connectPipe()); let client = new DebuggerClient(DebuggerServer.connectPipe());
client.connect().then(function onConnect() { client.connect().then(function onConnect() {
client.listTabs(function onListTabs(aResponse) { client.listTabs(function onListTabs(response) {
var form = aResponse.tabs[aResponse.selected]; let form = response.tabs[response.selected];
var front = FramerateFront(client, form); let front = FramerateFront(client, form);
front.startRecording().then(() => { front.startRecording().then(() => {
/* eslint-disable max-nested-callbacks */
window.setTimeout(() => { window.setTimeout(() => {
front.cancelRecording().then(() => { front.cancelRecording().then(() => {
window.setTimeout(() => { window.setTimeout(() => {
@ -60,17 +60,18 @@ window.onload = function() {
client.close().then(() => { client.close().then(() => {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish() SimpleTest.finish();
}); });
}); });
}); });
}, 1000); }, 1000);
}); });
}, 1000); }, 1000);
/* eslint-enable max-nested-callbacks */
}); });
}); });
}); });
} };
</script> </script>
</pre> </pre>
</body> </body>

Просмотреть файл

@ -13,34 +13,33 @@ Bug 1171489 - Tests if the framerate actor does not record timestamps from multi
<body> <body>
<pre id="test"> <pre id="test">
<script> <script>
"use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/shared/fronts/framerate"); const {FramerateFront} = require("devtools/shared/fronts/framerate");
var {TargetFactory} = require("devtools/client/framework/target");
var url = document.getElementById("testContent").href; let url = document.getElementById("testContent").href;
attachURL(url, onTab); attachURL(url, onTab);
function onTab(_, client, form, contentDoc) { function onTab(_, client, form, contentDoc) {
var contentWin = contentDoc.defaultView; let contentWin = contentDoc.defaultView;
var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
var selectedTab = chromeWin.gBrowser.selectedTab;
var target = TargetFactory.forTab(selectedTab); let front = FramerateFront(client, form);
var front = FramerateFront(client, form);
front.startRecording().then(() => { front.startRecording().then(() => {
window.setTimeout(() => { window.setTimeout(() => {
// Wait for the iframe to be loaded again // Wait for the iframe to be loaded again
window.addEventListener("message", function loaded (event) { window.addEventListener("message", function loaded(event) {
if (event.data === "ready") { if (event.data === "ready") {
window.removeEventListener("message", loaded); window.removeEventListener("message", loaded);
/* eslint-disable max-nested-callbacks */
window.setTimeout(() => { window.setTimeout(() => {
front.stopRecording().then(ticks => { front.stopRecording().then(ticks => {
onRecordingStopped(client, ticks); onRecordingStopped(client, ticks);
}); });
}, 1000); }, 1000);
/* eslint-enable max-nested-callbacks */
} }
}); });
contentWin.location.reload(); contentWin.location.reload();
@ -49,13 +48,13 @@ window.onload = function() {
} }
function onRecordingStopped(client, ticks) { function onRecordingStopped(client, ticks) {
var diffs = []; let diffs = [];
info(`Got ${ticks.length} ticks.`); info(`Got ${ticks.length} ticks.`);
for (var i = 1; i < ticks.length; i++) { for (let i = 1; i < ticks.length; i++) {
var prev = ticks[i - 1]; let prev = ticks[i - 1];
var curr = ticks[i]; let curr = ticks[i];
diffs.push(curr - prev); diffs.push(curr - prev);
info(curr + " - " + (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 // 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 // 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 // frame), so use a low number (2) to be our threshold
var THRESHOLD = 2; let THRESHOLD = 2;
ok(ticks.length >= 20, "we should have atleast 20 ticks over the course of two seconds."); ok(ticks.length >= 20,
var belowThreshold = diffs.filter(v => v <= THRESHOLD); "we should have atleast 20 ticks over the course of two seconds.");
ok(belowThreshold.length <= 10, "we should have very few frames less than the threshold"); let belowThreshold = diffs.filter(v => v <= THRESHOLD);
ok(belowThreshold.length <= 10,
"we should have very few frames less than the threshold");
client.close().then(() => { client.close().then(() => {
DebuggerServer.destroy(); DebuggerServer.destroy();
SimpleTest.finish() SimpleTest.finish();
}); });
} }
} };
</script> </script>
</pre> </pre>
<a id="testContent" target="_blank" href="inspector-traversal-data.html">Test Document</a> <a id="testContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>

Просмотреть файл

@ -12,17 +12,16 @@ Bug 1060093 - Test DebuggerServer.getProcess
<body> <body>
<pre id="test"> <pre id="test">
<script type="application/javascript"> <script type="application/javascript">
"use strict";
let Cu = Components.utils; let Cu = Components.utils;
let Cc = Components.classes;
let Ci = Components.interfaces;
let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
let {DebuggerClient} = require("devtools/shared/client/main"); let {DebuggerClient} = require("devtools/shared/client/main");
let {DebuggerServer} = require("devtools/server/main"); let {DebuggerServer} = require("devtools/server/main");
let Services = require("Services"); let Services = require("Services");
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({ SpecialPowers.pushPrefEnv({
@ -35,7 +34,7 @@ window.onload = function() {
["dom.ipc.processCount", 10], ["dom.ipc.processCount", 10],
] ]
}, runTests); }, runTests);
} };
function runTests() { function runTests() {
// Instantiate a minimal server // Instantiate a minimal server
@ -81,13 +80,13 @@ function runTests() {
function getProcess() { function getProcess() {
client.mainRoot.listProcesses(response => { client.mainRoot.listProcesses(response => {
ok(response.processes.length >= 2, "Got at least the parent process and one child"); 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 // Connect to the first content processe available
let content = response.processes.filter(p => (!p.parent))[0]; let content = response.processes.filter(p => (!p.parent))[0];
client.getProcess(content.id).then(response => { client.getProcess(content.id).then(({form: actor}) => {
let actor = response.form;
ok(actor.consoleActor, "Got the console actor"); ok(actor.consoleActor, "Got the console actor");
ok(actor.chromeDebugger, "Got the thread actor"); ok(actor.chromeDebugger, "Got the thread actor");
@ -96,8 +95,8 @@ function runTests() {
to: actor.consoleActor, to: actor.consoleActor,
type: "evaluateJS", type: "evaluateJS",
text: "var a = 42; a" text: "var a = 42; a"
}, function (response) { }, function ({result}) {
ok(response.result, 42, "console.eval worked"); ok(result, 42, "console.eval worked");
getProcessAgain(actor, content.id); getProcessAgain(actor, content.id);
}); });
@ -118,7 +117,7 @@ function runTests() {
function processScript() { function processScript() {
let listener = function () { let listener = function () {
Services.obs.removeObserver(listener, "sdk:loader:destroy", false); Services.obs.removeObserver(listener, "sdk:loader:destroy");
sendAsyncMessage("test:getProcess-destroy", null); sendAsyncMessage("test:getProcess-destroy", null);
}; };
Services.obs.addObserver(listener, "sdk:loader:destroy", false); Services.obs.addObserver(listener, "sdk:loader:destroy", false);
@ -127,10 +126,10 @@ function runTests() {
function closeClient() { function closeClient() {
let onLoaderDestroyed = new Promise(done => { let onLoaderDestroyed = new Promise(done => {
let processListener = function () { let processListener = function () {
Services.ppmm.removeMessageListener("test:getProcess-destroy", processListener) Services.ppmm.removeMessageListener("test:getProcess-destroy", processListener);
done(); done();
}; };
Services.ppmm.addMessageListener("test:getProcess-destroy", processListener) Services.ppmm.addMessageListener("test:getProcess-destroy", processListener);
}); });
let script = "data:,(" + processScript + ")()"; let script = "data:,(" + processScript + ")()";
Services.ppmm.loadProcessScript(script, true); Services.ppmm.loadProcessScript(script, true);
@ -147,7 +146,7 @@ function runTests() {
function cleanup() { function cleanup() {
DebuggerServer.destroy(); DebuggerServer.destroy();
iframe.remove(); iframe.remove();
SimpleTest.finish() SimpleTest.finish();
} }
connect(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
window.onload = function () {
const {InspectorFront} = const {InspectorFront} =
require("devtools/shared/fronts/inspector"); require("devtools/shared/fronts/inspector");
const {_documentWalker} = const {_documentWalker} =
@ -26,51 +28,50 @@ window.onload = function() {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
let gWalker = null; let gWalker = null;
let gClient = null; let gInspectee = null;
addTest(function setup() { addTest(function setup() {
info ("Setting up inspector and walker actors."); info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
}); });
addAsyncTest(function* testXBLAnonymousInHTMLDocument() { 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"); let rawToolbarbutton = gInspectee.createElementNS(XUL_NS, "toolbarbutton");
gInspectee.documentElement.appendChild(rawToolbarbutton); gInspectee.documentElement.appendChild(rawToolbarbutton);
let toolbarbutton = yield gWalker.querySelector(gWalker.rootNode, "toolbarbutton"); let toolbarbutton = yield gWalker.querySelector(gWalker.rootNode, "toolbarbutton");
let children = yield gWalker.children(toolbarbutton); let children = yield gWalker.children(toolbarbutton);
is (toolbarbutton.numChildren, 0, "XBL content is not visible 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"); is(children.nodes.length, 0, "XBL content is not returned in HTML doc");
runNextTest(); runNextTest();
}); });
addAsyncTest(function* testNativeAnonymous() { 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 select = yield gWalker.querySelector(gWalker.rootNode, "select");
let children = yield gWalker.children(select); let children = yield gWalker.children(select);
is (select.numChildren, 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"); is(children.nodes.length, 2, "No native anon content for form control");
runNextTest(); runNextTest();
}); });
addAsyncTest(function* testNativeAnonymousStartingNode() { 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 serverWalker = DebuggerServer._searchAllConnectionsForActor(gWalker.actorID);
let docwalker = new _documentWalker( let docwalker = new _documentWalker(
@ -78,108 +79,109 @@ window.onload = function() {
gInspectee.defaultView, gInspectee.defaultView,
nodeFilterConstants.SHOW_ALL, nodeFilterConstants.SHOW_ALL,
() => { () => {
return nodeFilterConstants.FILTER_ACCEPT return nodeFilterConstants.FILTER_ACCEPT;
} }
); );
let scrollbar = docwalker.lastChild(); 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); let node = yield serverWalker.attachElement(scrollbar);
ok (node, "A response has arrived"); ok(node, "A response has arrived");
ok (node.node, "A node is in the response"); ok(node.node, "A node is in the response");
is (node.node.rawNode.tagName, "SELECT", is(node.node.rawNode.tagName, "SELECT",
"The node has changed to a parent that the walker recognizes"); "The node has changed to a parent that the walker recognizes");
runNextTest(); runNextTest();
}); });
addAsyncTest(function* testPseudoElements() { addAsyncTest(function* testPseudoElements() {
info ("Testing pseudo elements with walker."); info("Testing pseudo elements with walker.");
// Markup looks like: <div><::before /><span /><::after /></div> // Markup looks like: <div><::before /><span /><::after /></div>
let pseudo = yield gWalker.querySelector(gWalker.rootNode, "#pseudo"); let pseudo = yield gWalker.querySelector(gWalker.rootNode, "#pseudo");
let children = yield gWalker.children(pseudo); let children = yield gWalker.children(pseudo);
is (pseudo.numChildren, 1, "::before/::after are not counted if there is a child"); is(pseudo.numChildren, 1, "::before/::after are not counted if there is a child");
is (children.nodes.length, 3, "Correct number of children"); is(children.nodes.length, 3, "Correct number of children");
let before = children.nodes[0]; let before = children.nodes[0];
ok (before.isAnonymous, "Child is anonymous"); ok(before.isAnonymous, "Child is anonymous");
ok (!before._form.isXBLAnonymous, "Child is not XBL anonymous"); ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (!before._form.isShadowAnonymous, "Child is not shadow anonymous"); ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
ok (before._form.isNativeAnonymous, "Child is native anonymous"); ok(before._form.isNativeAnonymous, "Child is native anonymous");
let span = children.nodes[1]; let span = children.nodes[1];
ok (!span.isAnonymous, "Child is not anonymous"); ok(!span.isAnonymous, "Child is not anonymous");
let after = children.nodes[2]; let after = children.nodes[2];
ok (after.isAnonymous, "Child is anonymous"); ok(after.isAnonymous, "Child is anonymous");
ok (!after._form.isXBLAnonymous, "Child is not XBL anonymous"); ok(!after._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (!after._form.isShadowAnonymous, "Child is not shadow anonymous"); ok(!after._form.isShadowAnonymous, "Child is not shadow anonymous");
ok (after._form.isNativeAnonymous, "Child is native anonymous"); ok(after._form.isNativeAnonymous, "Child is native anonymous");
runNextTest(); runNextTest();
}); });
addAsyncTest(function* testEmptyWithPseudo() { 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 pseudo = yield gWalker.querySelector(gWalker.rootNode, "#pseudo-empty");
let children = yield gWalker.children(pseudo); let children = yield gWalker.children(pseudo);
is (pseudo.numChildren, 1, "::before/::after are is counted if there are no other children"); is(pseudo.numChildren, 1,
is (children.nodes.length, 1, "Correct number of children"); "::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]; let before = children.nodes[0];
ok (before.isAnonymous, "Child is anonymous"); ok(before.isAnonymous, "Child is anonymous");
ok (!before._form.isXBLAnonymous, "Child is not XBL anonymous"); ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (!before._form.isShadowAnonymous, "Child is not shadow anonymous"); ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
ok (before._form.isNativeAnonymous, "Child is native anonymous"); ok(before._form.isNativeAnonymous, "Child is native anonymous");
runNextTest(); runNextTest();
}); });
addAsyncTest(function* testShadowAnonymous() { addAsyncTest(function* testShadowAnonymous() {
info ("Testing shadow DOM content."); info("Testing shadow DOM content.");
let shadow = yield gWalker.querySelector(gWalker.rootNode, "#shadow"); let shadow = yield gWalker.querySelector(gWalker.rootNode, "#shadow");
let children = yield gWalker.children(shadow); let children = yield gWalker.children(shadow);
is (shadow.numChildren, 3, "Children of the shadow root are counted"); is(shadow.numChildren, 3, "Children of the shadow root are counted");
is (children.nodes.length, 3, "Children returned from walker"); is(children.nodes.length, 3, "Children returned from walker");
let before = children.nodes[0]; let before = children.nodes[0];
ok (before.isAnonymous, "Child is anonymous"); ok(before.isAnonymous, "Child is anonymous");
ok (!before._form.isXBLAnonymous, "Child is not XBL anonymous"); ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (!before._form.isShadowAnonymous, "Child is not shadow anonymous"); ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
ok (before._form.isNativeAnonymous, "Child is native anonymous"); ok(before._form.isNativeAnonymous, "Child is native anonymous");
// <h3>Shadow <em>DOM</em></h3> // <h3>Shadow <em>DOM</em></h3>
let shadowChild1 = children.nodes[1]; let shadowChild1 = children.nodes[1];
ok (shadowChild1.isAnonymous, "Child is anonymous"); ok(shadowChild1.isAnonymous, "Child is anonymous");
ok (!shadowChild1._form.isXBLAnonymous, "Child is not XBL anonymous"); ok(!shadowChild1._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (shadowChild1._form.isShadowAnonymous, "Child is shadow anonymous"); ok(shadowChild1._form.isShadowAnonymous, "Child is shadow anonymous");
ok (!shadowChild1._form.isNativeAnonymous, "Child is not native anonymous"); ok(!shadowChild1._form.isNativeAnonymous, "Child is not native anonymous");
let shadowSubChildren = yield gWalker.children(children.nodes[1]); let shadowSubChildren = yield gWalker.children(children.nodes[1]);
is (shadowChild1.numChildren, 2, "Subchildren of the shadow root are counted"); is(shadowChild1.numChildren, 2, "Subchildren of the shadow root are counted");
is (shadowSubChildren.nodes.length, 2, "Subchildren are returned from walker"); is(shadowSubChildren.nodes.length, 2, "Subchildren are returned from walker");
// <em>DOM</em> // <em>DOM</em>
let shadowSubChild = children.nodes[1]; let shadowSubChild = children.nodes[1];
ok (shadowSubChild.isAnonymous, "Child is anonymous"); ok(shadowSubChild.isAnonymous, "Child is anonymous");
ok (!shadowSubChild._form.isXBLAnonymous, "Child is not XBL anonymous"); ok(!shadowSubChild._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (shadowSubChild._form.isShadowAnonymous, "Child is shadow anonymous"); ok(shadowSubChild._form.isShadowAnonymous, "Child is shadow anonymous");
ok (!shadowSubChild._form.isNativeAnonymous, "Child is not native anonymous"); ok(!shadowSubChild._form.isNativeAnonymous, "Child is not native anonymous");
// <select multiple></select> // <select multiple></select>
let shadowChild2 = children.nodes[2]; let shadowChild2 = children.nodes[2];
ok (shadowChild2.isAnonymous, "Child is anonymous"); ok(shadowChild2.isAnonymous, "Child is anonymous");
ok (!shadowChild2._form.isXBLAnonymous, "Child is not XBL anonymous"); ok(!shadowChild2._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (shadowChild2._form.isShadowAnonymous, "Child is shadow anonymous"); ok(shadowChild2._form.isShadowAnonymous, "Child is shadow anonymous");
ok (!shadowChild2._form.isNativeAnonymous, "Child is not native anonymous"); ok(!shadowChild2._form.isNativeAnonymous, "Child is not native anonymous");
runNextTest(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gClient = null; let gWalker = null;
var gWalker = null;
var checkActorIDs = [];
function assertOwnership() {
assertOwnershipTrees(gWalker);
}
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -56,34 +49,36 @@ addTest(function testChangeAttrs() {
// We're only going to test that the change hit the document. // We're only going to test that the change hit the document.
// There are other tests that make sure changes are propagated // There are other tests that make sure changes are propagated
// to the client. // to the client.
is(attrNode.getAttribute("data-newattr"), "newvalue", "Node should have the first new attribute"); is(attrNode.getAttribute("data-newattr"), "newvalue",
is(attrNode.getAttribute("data-newattr2"), "newvalue", "Node should have the second new attribute."); "Node should have the first new attribute");
is(attrNode.getAttribute("data-newattr2"), "newvalue",
"Node should have the second new attribute.");
}).then(() => { }).then(() => {
// Change an attribute. // Change an attribute.
let list = attrFront.startModifyingAttributes(); let list = attrFront.startModifyingAttributes();
list.setAttribute("data-newattr", "changedvalue"); list.setAttribute("data-newattr", "changedvalue");
return list.apply(); return list.apply();
}).then(() => { }).then(() => {
is(attrNode.getAttribute("data-newattr"), "changedvalue", "Node should have the changed first value."); is(attrNode.getAttribute("data-newattr"), "changedvalue",
is(attrNode.getAttribute("data-newattr2"), "newvalue", "Second value should remain unchanged."); "Node should have the changed first value.");
is(attrNode.getAttribute("data-newattr2"), "newvalue",
"Second value should remain unchanged.");
}).then(() => { }).then(() => {
let list = attrFront.startModifyingAttributes(); let list = attrFront.startModifyingAttributes();
list.removeAttribute("data-newattr2"); list.removeAttribute("data-newattr2");
return list.apply(); return list.apply();
}).then(() => { }).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."); ok(!attrNode.hasAttribute("data-newattr2"), "Second value should be removed.");
}).then(runNextTest)); }).then(runNextTest));
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gInspectee; gInspectee = null;
delete gClient;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const Ci = Components.interfaces; "use strict";
const inspector = require("devtools/shared/fronts/inspector");
window.onload = function() { const Ci = Components.interfaces;
window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gClient = null; let gWalker = null;
var gWalker = null;
function assertOwnership() {
assertOwnershipTrees(gWalker);
}
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -60,13 +55,10 @@ addTest(function testChangeValue() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gInspectee; gInspectee = null;
delete gClient;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gWalker, gDoc; let gWalker = null;
let gDoc = null;
addAsyncTest(function*() { addAsyncTest(function* () {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
let def = promise.defer(); let def = promise.defer();
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
def.resolve({client, tab, doc}); def.resolve({client, tab, doc});
}); });
let {client, tab, doc} = yield def.promise; let {client, tab, doc} = yield def.promise;
@ -37,7 +38,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.parents(nodeFront) before the load completes shouldn't fail"); "walker.parents(nodeFront) before the load completes shouldn't fail");
@ -51,7 +52,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.children(nodeFront) before the load completes shouldn't fail"); "walker.children(nodeFront) before the load completes shouldn't fail");
@ -65,7 +66,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.siblings(nodeFront) before the load completes shouldn't fail"); "walker.siblings(nodeFront) before the load completes shouldn't fail");
@ -79,7 +80,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.nextSibling(nodeFront) before the load completes shouldn't fail"); "walker.nextSibling(nodeFront) before the load completes shouldn't fail");
@ -93,7 +94,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.previousSibling(nodeFront) before the load completes shouldn't fail"); "walker.previousSibling(nodeFront) before the load completes shouldn't fail");
@ -107,7 +108,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.addPseudoClassLock(nodeFront) before the load completes " + "walker.addPseudoClassLock(nodeFront) before the load completes " +
"shouldn't fail"); "shouldn't fail");
@ -122,7 +123,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.removePseudoClassLock(nodeFront) before the load completes " + "walker.removePseudoClassLock(nodeFront) before the load completes " +
"shouldn't fail"); "shouldn't fail");
@ -137,7 +138,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.clearPseudoClassLocks(nodeFront) before the load completes " + "walker.clearPseudoClassLocks(nodeFront) before the load completes " +
"shouldn't fail"); "shouldn't fail");
@ -152,7 +153,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.innerHTML(nodeFront) before the load completes shouldn't fail"); "walker.innerHTML(nodeFront) before the load completes shouldn't fail");
@ -166,7 +167,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.setInnerHTML(nodeFront) before the load completes shouldn't fail"); "walker.setInnerHTML(nodeFront) before the load completes shouldn't fail");
@ -180,7 +181,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.outerHTML(nodeFront) before the load completes shouldn't fail"); "walker.outerHTML(nodeFront) before the load completes shouldn't fail");
@ -194,7 +195,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.setOuterHTML(nodeFront) before the load completes shouldn't fail"); "walker.setOuterHTML(nodeFront) before the load completes shouldn't fail");
@ -208,7 +209,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.insertAdjacentHTML(nodeFront) before the load completes shouldn't " + "walker.insertAdjacentHTML(nodeFront) before the load completes shouldn't " +
"fail"); "fail");
@ -224,7 +225,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.removeNode(nodeFront) before the load completes should throw"); "walker.removeNode(nodeFront) before the load completes should throw");
@ -243,7 +244,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.removeNodes([nodeFront]) before the load completes should throw"); "walker.removeNodes([nodeFront]) before the load completes should throw");
@ -264,7 +265,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.insertBefore(nodeFront, parent, null) before the load completes " + "walker.insertBefore(nodeFront, parent, null) before the load completes " +
"shouldn't fail"); "shouldn't fail");
@ -280,7 +281,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.insertBefore(nodeFront, parent, sibling) before the load completes " + "walker.insertBefore(nodeFront, parent, sibling) before the load completes " +
"shouldn't fail"); "shouldn't fail");
@ -297,7 +298,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.editTagName(nodeFront) before the load completes shouldn't fail"); "walker.editTagName(nodeFront) before the load completes shouldn't fail");
@ -311,7 +312,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.hideNode(nodeFront) before the load completes shouldn't fail"); "walker.hideNode(nodeFront) before the load completes shouldn't fail");
@ -325,7 +326,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.unhideNode(nodeFront) before the load completes shouldn't fail"); "walker.unhideNode(nodeFront) before the load completes shouldn't fail");
@ -339,7 +340,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.releaseNode(nodeFront) before the load completes shouldn't fail"); "walker.releaseNode(nodeFront) before the load completes shouldn't fail");
@ -353,7 +354,7 @@ addAsyncTest(function*() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
info("Getting a nodeFront, reloading the page, and calling " + info("Getting a nodeFront, reloading the page, and calling " +
"walker.querySelector(nodeFront) before the load completes shouldn't fail"); "walker.querySelector(nodeFront) before the load completes shouldn't fail");
@ -368,7 +369,8 @@ addAsyncTest(function*() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
gWalker = gDoc = null; gWalker = null;
gDoc = null;
runNextTest(); runNextTest();
}); });
</script> </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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gWalker = null;
var gClient = null;
var gWalker = null;
function assertOwnership() {
assertOwnershipTrees(gWalker);
}
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; 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 {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -55,9 +47,7 @@ addTest(Task.async(function* testDuplicateNode() {
})); }));
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gInspectee;
delete gClient;
runNextTest(); runNextTest();
}); });
</script> </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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gWalker = null; let gWalker = null;
var gClient = null; let gInspectee = null;
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -56,8 +55,8 @@ addTest(function testRearrange() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gClient; gInspectee = null;
runNextTest(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
"use strict";
const inspector = require("devtools/server/actors/inspector"); const inspector = require("devtools/server/actors/inspector");
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gWalker = null; let gWalker = null;
var gClient = null; let gInspectee = null;
function assertOwnership() {
return assertOwnershipTrees(gWalker);
}
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspectorFront = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspectorFront.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -47,9 +44,11 @@ addAsyncTest(function* testRearrange() {
// Move nodeA to the end of the list. // Move nodeA to the end of the list.
yield gWalker.insertBefore(nodeA, longlist, null); 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); 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. // Now move it to the middle of the list.
let nextNode = children.nodes[13]; let nextNode = children.nodes[13];
@ -99,8 +98,8 @@ addAsyncTest(function* testInsertInvalidInput() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gClient; gInspectee = null;
runNextTest(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gWalker = null; let gWalker = null;
var gClient = null; let attrNode;
var attrNode; let attrFront;
var attrFront;
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -50,14 +48,14 @@ addTest(testRemoveAttribute);
addTest(testQueuedMutations); addTest(testQueuedMutations);
function setupAttrTest() { function setupAttrTest() {
attrNode = gInspectee.querySelector("#a") attrNode = gInspectee.querySelector("#a");
promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(node => { promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(node => {
attrFront = node; attrFront = node;
}).then(runNextTest)); }).then(runNextTest));
} }
function setupFrameAttrTest() { function setupFrameAttrTest() {
let frame = gInspectee.querySelector('#childFrame'); let frame = gInspectee.querySelector("#childFrame");
attrNode = frame.contentDocument.querySelector("#a"); attrNode = frame.contentDocument.querySelector("#a");
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => { promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
@ -77,8 +75,10 @@ function testAddAttribute() {
attrNode.setAttribute("data-newattr2", "newvalue"); attrNode.setAttribute("data-newattr2", "newvalue");
gWalker.once("mutations", () => { gWalker.once("mutations", () => {
is(attrFront.attributes.length, 3, "Should have id and two new attributes."); 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-newattr"), "newvalue",
is(attrFront.getAttribute("data-newattr2"), "newvalue", "Node front should have the second new attribute."); "Node front should have the first new attribute");
is(attrFront.getAttribute("data-newattr2"), "newvalue",
"Node front should have the second new attribute.");
runNextTest(); runNextTest();
}); });
} }
@ -88,10 +88,13 @@ function testChangeAttribute() {
attrNode.setAttribute("data-newattr", "changedvalue2"); attrNode.setAttribute("data-newattr", "changedvalue2");
attrNode.setAttribute("data-newattr", "changedvalue3"); attrNode.setAttribute("data-newattr", "changedvalue3");
gWalker.once("mutations", mutations => { 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.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-newattr"), "changedvalue3",
is(attrFront.getAttribute("data-newattr2"), "newvalue", "Second value should remain unchanged."); "Node front should have the changed first value");
is(attrFront.getAttribute("data-newattr2"), "newvalue",
"Second value should remain unchanged.");
runNextTest(); runNextTest();
}); });
} }
@ -100,10 +103,11 @@ function testRemoveAttribute() {
attrNode.removeAttribute("data-newattr2"); attrNode.removeAttribute("data-newattr2");
gWalker.once("mutations", () => { gWalker.once("mutations", () => {
is(attrFront.attributes.length, 2, "Should have id and one remaining attribute."); 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."); ok(!attrFront.hasAttribute("data-newattr2"), "Second value should be removed.");
runNextTest(); runNextTest();
}) });
} }
function testQueuedMutations() { function testQueuedMutations() {
@ -115,7 +119,7 @@ function testQueuedMutations() {
attrNode.setAttribute("data-newattr", "2"); attrNode.setAttribute("data-newattr", "2");
attrNode.removeAttribute("data-newattr"); attrNode.removeAttribute("data-newattr");
for (var i = 0; i <= 1000; i++) { for (let i = 0; i <= 1000; i++) {
attrNode.setAttribute("data-newattr2", i); attrNode.setAttribute("data-newattr2", i);
} }
@ -132,26 +136,27 @@ function testQueuedMutations() {
attrNode.removeAttribute("data-newattr4"); attrNode.removeAttribute("data-newattr4");
gWalker.once("mutations", mutations => { gWalker.once("mutations", mutations => {
is(mutations.length, 4, "Only one mutation each is sent for multiple queued attribute changes"); is(mutations.length, 4,
is(attrFront.attributes.length, 3, "Should have id, data-newattr2, and data-newattr3."); "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-newattr2"), "1000",
is(attrFront.getAttribute("data-newattr3"), "3", "Node front should still have the correct value"); "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-newattr"), "Attribute value should be removed.");
ok(!attrFront.hasAttribute("data-newattr4"), "Attribute value should be removed."); ok(!attrFront.hasAttribute("data-newattr4"), "Attribute value should be removed.");
runNextTest(); runNextTest();
}) });
} }
addTest(function cleanup() { addTest(function cleanup() {
delete gInspectee; gInspectee = null;
delete gWalker; gWalker = null;
delete gClient;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gWalker = null; let gWalker = null;
var gClient = null; let gCleanupConnection = null;
var gCleanupConnection = null;
function setup(callback) { function setup(callback) {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
gCleanupConnection = attachURL(url, function(err, client, tab, doc) { gCleanupConnection = attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
gClient = client;
gWalker = walker; gWalker = walker;
}).then(callback)); }).then(callback));
}); });
@ -38,7 +36,6 @@ function setup(callback) {
function teardown() { function teardown() {
gWalker = null; gWalker = null;
gClient = null;
gInspectee = null; gInspectee = null;
if (gCleanupConnection) { if (gCleanupConnection) {
gCleanupConnection(); gCleanupConnection();
@ -47,7 +44,7 @@ function teardown() {
} }
function assertOwnership() { function assertOwnership() {
let num = assertOwnershipTrees(gWalker); return assertOwnershipTrees(gWalker);
} }
function setParent(nodeSelector, newParentSelector) { function setParent(nodeSelector, newParentSelector) {
@ -83,7 +80,7 @@ function doMoves(moves) {
var gDummySerial = 0; var gDummySerial = 0;
function mutationTest(testSpec) { function mutationTest(testSpec) {
return function() { return function () {
setup(() => { setup(() => {
promiseDone(loadSelectors(testSpec.load || ["html"]).then(() => { promiseDone(loadSelectors(testSpec.load || ["html"]).then(() => {
gWalker.autoCleanup = !!testSpec.autoCleanup; gWalker.autoCleanup = !!testSpec.autoCleanup;
@ -99,6 +96,7 @@ function mutationTest(testSpec) {
gWalker.once("mutations", (mutations) => { gWalker.once("mutations", (mutations) => {
// Filter out our dummy mutation. // Filter out our dummy mutation.
// eslint-disable-next-line max-nested-callbacks
mutations = mutations.filter(change => { mutations = mutations.filter(change => {
if (change.type == "attributes" && if (change.type == "attributes" &&
change.attributeName == "data-dummy") { change.attributeName == "data-dummy") {
@ -114,14 +112,14 @@ function mutationTest(testSpec) {
runNextTest(); runNextTest();
}); });
})); }));
}) });
} };
} }
// Verify that our dummy mutation works. // Verify that our dummy mutation works.
addTest(mutationTest({ addTest(mutationTest({
autoCleanup: false, autoCleanup: false,
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 0, "Dummy mutation is filtered out."); is(mutations.length, 0, "Dummy mutation is filtered out.");
} }
})); }));
@ -134,17 +132,18 @@ addTest(mutationTest({
moves: [ moves: [
["#a", "#longlist"] ["#a", "#longlist"]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
let remove = mutations[0]; let remove = mutations[0];
is(remove.type, "childList", "First mutation should be a childList.") is(remove.type, "childList", "First mutation should be a childList.");
ok(remove.removed.length > 0, "First mutation should be a removal.") ok(remove.removed.length > 0, "First mutation should be a removal.");
let add = mutations[1]; let add = mutations[1];
is(add.type, "childList", "Second mutation should be a childList removal.") is(add.type, "childList", "Second mutation should be a childList removal.");
ok(add.added.length > 0, "Second mutation should be an addition.") ok(add.added.length > 0, "Second mutation should be an addition.");
let a = add.added[0]; let a = add.added[0];
is(a.id, "a", "Added node should be #a"); is(a.id, "a", "Added node should be #a");
is(a.parentNode(), remove.target, "Should still be a child of longlist."); 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: [ moves: [
["#a", "#longlist-sibling"] ["#a", "#longlist-sibling"]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
let remove = mutations[0]; let remove = mutations[0];
is(remove.type, "childList", "First mutation should be a childList.") is(remove.type, "childList", "First mutation should be a childList.");
ok(remove.removed.length > 0, "First mutation should be a removal.") ok(remove.removed.length > 0, "First mutation should be a removal.");
let add = mutations[1]; let add = mutations[1];
is(add.type, "childList", "Second mutation should be a childList removal.") is(add.type, "childList", "Second mutation should be a childList removal.");
ok(add.added.length > 0, "Second mutation should be an addition.") ok(add.added.length > 0, "Second mutation should be an addition.");
let a = add.added[0]; let a = add.added[0];
is(a.id, "a", "Added node should be #a"); is(a.id, "a", "Added node should be #a");
is(a.parentNode(), add.target, "Should still be a child of longlist."); is(a.parentNode(), add.target, "Should still be a child of longlist.");
@ -177,7 +176,7 @@ addTest(mutationTest({
moves: [ moves: [
["#longlist-sibling", "#longlist"] ["#longlist-sibling", "#longlist"]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 2, "Should generate two mutations"); is(mutations.length, 2, "Should generate two mutations");
is(mutations[0].type, "childList", "Should be childList mutations."); is(mutations[0].type, "childList", "Should be childList mutations.");
is(mutations[0].added.length, 0, "Should have no adds."); is(mutations[0].added.length, 0, "Should have no adds.");
@ -196,7 +195,7 @@ addTest(mutationTest({
moves: [ moves: [
["#longlist-sibling-firstchild", "#longlist"] ["#longlist-sibling-firstchild", "#longlist"]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 1, "Should generate two mutations"); is(mutations.length, 1, "Should generate two mutations");
is(mutations[0].type, "childList", "Should be childList mutations."); is(mutations[0].type, "childList", "Should be childList mutations.");
is(mutations[0].added.length, 0, "Should have no adds."); is(mutations[0].added.length, 0, "Should have no adds.");
@ -211,7 +210,7 @@ addTest(mutationTest({
moves: [ moves: [
["#longlist-sibling", "#longlist"] ["#longlist-sibling", "#longlist"]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 0, "Should generate no mutations."); is(mutations.length, 0, "Should generate no mutations.");
} }
})); }));
@ -223,14 +222,15 @@ addTest(mutationTest({
moves: [ moves: [
["#longlist", null] ["#longlist", null]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation."); is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0]; let change = mutations[0];
is(change.type, "childList", "Should be a childList."); is(change.type, "childList", "Should be a childList.");
is(change.removed.length, 1, "Should have removed a child."); is(change.removed.length, 1, "Should have removed a child.");
let ownership = clientOwnershipTree(gWalker); let ownership = clientOwnershipTree(gWalker);
is(ownership.orphaned.length, 1, "Should have one orphaned subtree."); 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: [ moves: [
["#longlist", null] ["#longlist", null]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation."); is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0]; let change = mutations[0];
is(change.type, "childList", "Should be a childList."); is(change.type, "childList", "Should be a childList.");
@ -258,25 +258,27 @@ addTest(mutationTest({
moves: [ moves: [
["#longlist", "#longlist-sibling"] ["#longlist", "#longlist-sibling"]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation."); is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0]; let change = mutations[0];
is(change.type, "childList", "Should be a childList."); is(change.type, "childList", "Should be a childList.");
is(change.removed.length, 1, "Should have removed a child."); is(change.removed.length, 1, "Should have removed a child.");
let ownership = clientOwnershipTree(gWalker); let ownership = clientOwnershipTree(gWalker);
is(ownership.orphaned.length, 1, "Should have one orphaned subtree."); 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({ addTest(mutationTest({
autoCleanup: true, autoCleanup: true,
load: ["#longlist div"], load: ["#longlist div"],
moves: [ moves: [
["#longlist", "#longlist-sibling"] ["#longlist", "#longlist-sibling"]
], ],
postCheck: function(mutations) { postCheck: function (mutations) {
is(mutations.length, 1, "Should generate one mutation."); is(mutations.length, 1, "Should generate one mutation.");
let change = mutations[0]; let change = mutations[0];
is(change.type, "childList", "Should be a childList."); is(change.type, "childList", "Should be a childList.");
@ -286,15 +288,11 @@ addTest(mutationTest({
} }
})); }));
addTest(function cleanup() { addTest(function cleanup() {
delete gInspectee; gInspectee = null;
delete gWalker; gWalker = null;
delete gClient;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
"use strict";
window.onload = function() { window.onload = function () {
const Cu = Components.utils; const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const {InspectorFront} = require("devtools/shared/fronts/inspector"); const {InspectorFront} = require("devtools/shared/fronts/inspector");
@ -30,11 +30,11 @@ window.onload = function() {
let eventFront2; let eventFront2;
addAsyncTest(function* setup() { addAsyncTest(function* setup() {
info ("Setting up inspector and walker actors."); info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
yield new Promise(resolve => { yield new Promise(resolve => {
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
inspectee = doc; inspectee = doc;
inspector = InspectorFront(client, tab); inspector = InspectorFront(client, tab);
resolve(); resolve();
@ -48,8 +48,8 @@ window.onload = function() {
}); });
addAsyncTest(function* setupEventTest() { addAsyncTest(function* setupEventTest() {
eventNode1 = inspectee.querySelector("#a") eventNode1 = inspectee.querySelector("#a");
eventNode2 = inspectee.querySelector("#b") eventNode2 = inspectee.querySelector("#b");
eventFront1 = yield walker.querySelector(walker.rootNode, "#a"); eventFront1 = yield walker.querySelector(walker.rootNode, "#a");
eventFront2 = yield walker.querySelector(walker.rootNode, "#b"); eventFront2 = yield walker.querySelector(walker.rootNode, "#b");
@ -67,7 +67,8 @@ window.onload = function() {
is(mutations.length, 1, "one mutation expected"); is(mutations.length, 1, "one mutation expected");
is(mutations[0].target, eventFront1, "mutation targets eventFront1"); is(mutations[0].target, eventFront1, "mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events"); 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"); is(eventFront1.hasEventListeners, true, "eventFront1 should have event listeners");
info("remove event listener on a single node"); info("remove event listener on a single node");
@ -77,10 +78,12 @@ window.onload = function() {
is(mutations.length, 1, "one mutation expected"); is(mutations.length, 1, "one mutation expected");
is(mutations[0].target, eventFront1, "mutation targets eventFront1"); is(mutations[0].target, eventFront1, "mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events"); is(mutations[0].type, "events", "mutation type is events");
is(mutations[0].hasEventListeners, false, "mutation target should have no event listeners"); is(mutations[0].hasEventListeners, false,
is(eventFront1.hasEventListeners, false, "eventFront1 should have no event listeners"); "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", eventListener1);
eventNode1.addEventListener("click", eventListener2); eventNode1.addEventListener("click", eventListener2);
eventNode1.removeEventListener("click", eventListener1); eventNode1.removeEventListener("click", eventListener1);
@ -90,7 +93,8 @@ window.onload = function() {
is(mutations.length, 1, "one mutation expected"); is(mutations.length, 1, "one mutation expected");
is(mutations[0].target, eventFront1, "mutation targets eventFront1"); is(mutations[0].target, eventFront1, "mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events"); 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"); is(eventFront1.hasEventListeners, false, "no event listener expected on node");
runNextTest(); runNextTest();
@ -108,12 +112,14 @@ window.onload = function() {
// first mutation // first mutation
is(mutations[0].target, eventFront1, "first mutation targets eventFront1"); is(mutations[0].target, eventFront1, "first mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events"); 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"); is(eventFront1.hasEventListeners, true, "eventFront1 should have event listeners");
// second mutation // second mutation
is(mutations[1].target, eventFront2, "second mutation targets eventFront2"); is(mutations[1].target, eventFront2, "second mutation targets eventFront2");
is(mutations[1].type, "events", "mutation type is events"); 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"); is(eventFront2.hasEventListeners, true, "eventFront1 should have event listeners");
info("remove event listeners on both nodes"); info("remove event listeners on both nodes");
@ -125,13 +131,17 @@ window.onload = function() {
// first mutation // first mutation
is(mutations[0].target, eventFront1, "first mutation targets eventFront1"); is(mutations[0].target, eventFront1, "first mutation targets eventFront1");
is(mutations[0].type, "events", "mutation type is events"); is(mutations[0].type, "events", "mutation type is events");
is(mutations[0].hasEventListeners, false, "mutation target should have no event listeners"); is(mutations[0].hasEventListeners, false,
is(eventFront1.hasEventListeners, false, "eventFront2 should have no event listeners"); "mutation target should have no event listeners");
is(eventFront1.hasEventListeners, false,
"eventFront2 should have no event listeners");
// second mutation // second mutation
is(mutations[1].target, eventFront2, "second mutation targets eventFront2"); is(mutations[1].target, eventFront2, "second mutation targets eventFront2");
is(mutations[1].type, "events", "mutation type is events"); is(mutations[1].type, "events", "mutation type is events");
is(mutations[1].hasEventListeners, false, "mutation target should have no event listeners"); is(mutations[1].hasEventListeners, false,
is(eventFront2.hasEventListeners, false, "eventFront2 should have no event listeners"); "mutation target should have no event listeners");
is(eventFront2.hasEventListeners, false,
"eventFront2 should have no event listeners");
runNextTest(); runNextTest();
}); });
@ -142,7 +152,7 @@ window.onload = function() {
info("try to remove an event listener not previously added"); info("try to remove an event listener not previously added");
eventNode1.removeEventListener("click", eventListener1); 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"); eventNode1.setAttribute("data-attr", "somevalue");
let mutations = yield waitForMutations(); let mutations = yield waitForMutations();
@ -153,9 +163,11 @@ window.onload = function() {
}); });
function checkNodesHaveNoEventListener() { function checkNodesHaveNoEventListener() {
is(eventFront1.hasEventListeners, false, "eventFront1 hasEventListeners should be false"); is(eventFront1.hasEventListeners, false,
is(eventFront2.hasEventListeners, false, "eventFront2 hasEventListeners should be false"); "eventFront1 hasEventListeners should be false");
}; is(eventFront2.hasEventListeners, false,
"eventFront2 hasEventListeners should be false");
}
function waitForMutations() { function waitForMutations() {
return new Promise(resolve => { return new Promise(resolve => {
@ -166,8 +178,7 @@ window.onload = function() {
} }
runNextTest(); runNextTest();
} };
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gWalker = null; let gWalker = null;
var gClient = null; let gClient = null;
var gChildFrame = null; let gCleanupConnection = null;
var gChildDocument = null;
var gCleanupConnection = null;
function setup(callback) { function setup(callback) {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
gCleanupConnection = attachURL(url, function(err, client, tab, doc) { gCleanupConnection = attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
@ -42,7 +40,6 @@ function teardown() {
gWalker = null; gWalker = null;
gClient = null; gClient = null;
gInspectee = null; gInspectee = null;
gChildFrame = null;
if (gCleanupConnection) { if (gCleanupConnection) {
gCleanupConnection(); gCleanupConnection();
gCleanupConnection = null; gCleanupConnection = null;
@ -55,8 +52,8 @@ function assertOwnership() {
function loadChildSelector(selector) { function loadChildSelector(selector) {
return gWalker.querySelector(gWalker.rootNode, "#childFrame").then(frame => { return gWalker.querySelector(gWalker.rootNode, "#childFrame").then(frame => {
ok(frame.numChildren > 0, "Child frame should consider its loaded document as a child."); ok(frame.numChildren > 0,
gChildFrame = frame; "Child frame should consider its loaded document as a child.");
return gWalker.children(frame); return gWalker.children(frame);
}).then(children => { }).then(children => {
return gWalker.querySelectorAll(children.nodes[0], selector); return gWalker.querySelectorAll(children.nodes[0], selector);
@ -76,7 +73,6 @@ function getUnloadedDoc(mutations) {
addTest(function loadNewChild() { addTest(function loadNewChild() {
setup(() => { setup(() => {
let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame. // Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => { promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame"); let childFrame = gInspectee.querySelector("#childFrame");
@ -102,7 +98,6 @@ addTest(function loadNewChild() {
addTest(function loadNewChildTwice() { addTest(function loadNewChildTwice() {
setup(() => { setup(() => {
let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame. // Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => { promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame"); let childFrame = gInspectee.querySelector("#childFrame");
@ -130,10 +125,8 @@ addTest(function loadNewChildTwice() {
}); });
}); });
addTest(function loadNewChildTwiceAndCareAboutIt() { addTest(function loadNewChildTwiceAndCareAboutIt() {
setup(() => { setup(() => {
let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame. // Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => { promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame"); let childFrame = gInspectee.querySelector("#childFrame");
@ -168,7 +161,6 @@ addTest(function loadNewChildTwiceAndCareAboutIt() {
addTest(function testBack() { addTest(function testBack() {
setup(() => { setup(() => {
let beforeUnloadSize = 0;
// Load a bunch of fronts for actors inside the child frame. // Load a bunch of fronts for actors inside the child frame.
promiseDone(loadChildSelector("#longlist div").then(() => { promiseDone(loadChildSelector("#longlist div").then(() => {
let childFrame = gInspectee.querySelector("#childFrame"); let childFrame = gInspectee.querySelector("#childFrame");
@ -178,7 +170,8 @@ addTest(function testBack() {
// Read the new child // Read the new child
return loadChildSelector("#longlist div"); return loadChildSelector("#longlist div");
}).then(() => { }).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"); let childFrame = gInspectee.querySelector("#childFrame");
childFrame.contentWindow.history.back(); childFrame.contentWindow.history.back();
return waitForMutation(gWalker, isChildList); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
"use strict";
const inspector = require("devtools/server/actors/inspector"); const inspector = require("devtools/server/actors/inspector");
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
const testSummaryLength = 10; const testSummaryLength = 10;
inspector.setValueSummaryLength(testSummaryLength); inspector.setValueSummaryLength(testSummaryLength);
SimpleTest.registerCleanupFunction(function() { SimpleTest.registerCleanupFunction(function () {
inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH); inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH);
}); });
var gInspectee = null; let gInspectee = null;
var gWalker = null; let gWalker = null;
var gClient = null; let valueNode;
var valueNode;
var valueFront; var valueFront;
var longStringFront; var longStringFront;
var longString = "stringstringstringstringstringstringstringstringstringstringstring"; var longString = "stringstringstringstringstringstringstringstringstringstringstring";
var truncatedLongString = longString.substring(0, testSummaryLength);
var shortString = "str"; var shortString = "str";
var shortString2 = "str2"; var shortString2 = "str2";
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspectorFront = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspectorFront.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -71,7 +70,7 @@ function setupValueTest() {
} }
function setupFrameValueTest() { function setupFrameValueTest() {
let frame = gInspectee.querySelector('#childFrame'); let frame = gInspectee.querySelector("#childFrame");
valueNode = frame.contentDocument.querySelector("#longstring").firstChild; valueNode = frame.contentDocument.querySelector("#longstring").firstChild;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => { promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
@ -94,7 +93,7 @@ function checkNodeFrontValue(front, expectedValue) {
return longstring.string(); return longstring.string();
}).then(str => { }).then(str => {
is(str, expectedValue, "Node value is as expected"); is(str, expectedValue, "Node value is as expected");
}) });
} }
function testKeepLongValue() { function testKeepLongValue() {
@ -147,9 +146,8 @@ function testSetLongValue() {
} }
addTest(function cleanup() { addTest(function cleanup() {
delete gInspectee; gInspectee = null;
delete gWalker; gWalker = null;
delete gClient;
runNextTest(); runNextTest();
}); });

Просмотреть файл

@ -1,101 +1,99 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<!-- <!--
Test that the inspector actor has the pickColorFromPage and cancelPickColorFromPage Test that the inspector actor has the pickColorFromPage and cancelPickColorFromPage
methods and that when a color is picked the color-picked event is emitted and that when methods and that when a color is picked the color-picked event is emitted and that when
the eyedropper is dimissed, the color-pick-canceled event is emitted. the eyedropper is dimissed, the color-pick-canceled event is emitted.
https://bugzilla.mozilla.org/show_bug.cgi?id=1262439 https://bugzilla.mozilla.org/show_bug.cgi?id=1262439
--> -->
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Test for Bug 1262439</title> <title>Test for Bug 1262439</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
const Cu = Components.utils;
Cu.import("resource://devtools/shared/Loader.jsm"); window.onload = function () {
const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); const {InspectorFront} = require("devtools/shared/fronts/inspector");
const {InspectorFront} = devtools.require("devtools/shared/fronts/inspector");
const {console} = Cu.import("resource://gre/modules/Console.jsm", {}); SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish(); let win = null;
let inspector = null;
let win = null;
let inspector = null; addAsyncTest(function* () {
info("Setting up inspector actor");
addAsyncTest(function*() {
info("Setting up inspector actor"); let url = document.getElementById("inspectorContent").href;
let url = document.getElementById("inspectorContent").href; yield new Promise(resolve => {
attachURL(url, function (err, client, tab, doc) {
yield new Promise(resolve => { win = doc.defaultView;
attachURL(url, function(err, client, tab, doc) { inspector = InspectorFront(client, tab);
win = doc.defaultView; resolve();
inspector = InspectorFront(client, tab); });
resolve(); });
});
}); runNextTest();
});
runNextTest();
}); addAsyncTest(function* () {
info("Start picking a color from the page");
addAsyncTest(function*() { yield inspector.pickColorFromPage();
info("Start picking a color from the page");
yield inspector.pickColorFromPage(); info("Click in the page and make sure a color-picked event is received");
let onColorPicked = waitForEvent("color-picked");
info("Click in the page and make sure a color-picked event is received"); win.document.body.click();
let onColorPicked = waitForEvent("color-picked"); let color = yield onColorPicked;
win.document.body.click();
let color = yield onColorPicked; is(color, "#000000", "The color-picked event was received with the right color");
is(color, "#000000", "The color-picked event was received with the right color"); runNextTest();
});
runNextTest();
}); addAsyncTest(function* () {
info("Start picking a color from the page");
addAsyncTest(function*() { yield inspector.pickColorFromPage();
info("Start picking a color from the page");
yield inspector.pickColorFromPage(); info("Use the escape key to dismiss the eyedropper");
let onPickCanceled = waitForEvent("color-pick-canceled");
info("Use the escape key to dismiss the eyedropper");
let onPickCanceled = waitForEvent("color-pick-canceled"); let keyboardEvent = win.document.createEvent("KeyboardEvent");
keyboardEvent.initKeyEvent("keydown", true, true, win, false, false,
let keyboardEvent = win.document.createEvent("KeyboardEvent"); false, false, 27, 0);
keyboardEvent.initKeyEvent("keydown", true, true, win, false, false, win.document.dispatchEvent(keyboardEvent);
false, false, 27, 0);
win.document.dispatchEvent(keyboardEvent); yield onPickCanceled;
ok(true, "The color-pick-canceled event was received");
yield onPickCanceled;
ok(true, "The color-pick-canceled event was received"); runNextTest();
});
runNextTest();
}); addAsyncTest(function* () {
info("Start picking a color from the page");
addAsyncTest(function*() { yield inspector.pickColorFromPage();
info("Start picking a color from the page");
yield inspector.pickColorFromPage(); info("And cancel the color picking");
yield inspector.cancelPickColorFromPage();
info("And cancel the color picking");
yield inspector.cancelPickColorFromPage(); runNextTest();
});
runNextTest();
}); function waitForEvent(name) {
return new Promise(resolve => inspector.once(name, resolve));
function waitForEvent(name) { }
return new Promise(resolve => inspector.once(name, resolve));
} runNextTest();
};
runNextTest(); </script>
}; </head>
</script> <body>
</head> <a id="inspectorContent" target="_blank" href="inspector-eyedropper.html">Test Document</a>
<body> <p id="display"></p>
<a id="inspectorContent" target="_blank" href="inspector-eyedropper.html">Test Document</a> <div id="content" style="display: none"></div>
<p id="display"></p> <pre id="test">
<div id="content" style="display: none"></div> </pre>
<pre id="test"> </body>
</pre> </html>
</body>
</html>

Просмотреть файл

@ -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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
const DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"].
getService(Components.interfaces.inIDOMUtils);
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(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gWalker = null; let gWalker = null;
var gClient = null; let gCleanupConnection = null;
var gCleanupConnection = null;
function setup(callback) { function setup(callback) {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
gCleanupConnection = attachURL(url, function(err, client, tab, doc) { gCleanupConnection = attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
gClient = client;
gWalker = walker; gWalker = walker;
}).then(callback)); }).then(callback));
}); });
@ -42,7 +41,6 @@ function setup(callback) {
function teardown() { function teardown() {
gWalker = null; gWalker = null;
gClient = null;
gInspectee = null; gInspectee = null;
if (gCleanupConnection) { if (gCleanupConnection) {
gCleanupConnection(); gCleanupConnection();
@ -53,10 +51,13 @@ function teardown() {
function checkChange(change, expectation) { function checkChange(change, expectation) {
is(change.type, "pseudoClassLock", "Expect a pseudoclass lock change."); is(change.type, "pseudoClassLock", "Expect a pseudoclass lock change.");
let target = change.target; let target = change.target;
if (expectation.id) if (expectation.id) {
is(target.id, expectation.id, "Expect a change on node id " + 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, is(target.pseudoClassLocks.length, expectation.pseudos.length,
"Expect " + expectation.pseudos.length + " pseudoclass locks."); "Expect " + expectation.pseudos.length + " pseudoclass locks.");
@ -74,7 +75,8 @@ function checkChange(change, expectation) {
for (let pseudo of KNOWN_PSEUDOCLASSES) { for (let pseudo of KNOWN_PSEUDOCLASSES) {
if (!expectation.pseudos.some(expected => pseudo === expected)) { if (!expectation.pseudos.some(expected => pseudo === expected)) {
ok(!target.hasPseudoClassLock(pseudo), "Don't expect lock: " + pseudo); 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) { function checkMutations(mutations, expectations) {
is(mutations.length, expectations.length, "Should get the right number of mutations."); is(mutations.length, expectations.length, "Should get the right number of mutations.");
for (let i = 0; i < mutations.length; i++) { 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 => { return promiseDone(gWalker.querySelector(gWalker.rootNode, "#b").then(front => {
nodeFront = front; nodeFront = front;
// Lock the pseudoclass alone, no parents. // Lock the pseudoclass alone, no parents.
gWalker.addPseudoClassLock(nodeFront, ':active'); gWalker.addPseudoClassLock(nodeFront, ":active");
// Expect a single pseudoClassLock mutation. // Expect a single pseudoClassLock mutation.
return promiseOnce(gWalker, "mutations"); return promiseOnce(gWalker, "mutations");
}).then(mutations => { }).then(mutations => {
@ -107,50 +109,50 @@ addTest(function testPseudoClassLock() {
}); });
}).then(() => { }).then(() => {
// Now add :hover, this time with parents. // Now add :hover, this time with parents.
gWalker.addPseudoClassLock(nodeFront, ':hover', {parents: true}); gWalker.addPseudoClassLock(nodeFront, ":hover", {parents: true});
return promiseOnce(gWalker, "mutations"); return promiseOnce(gWalker, "mutations");
}).then(mutations => { }).then(mutations => {
let expectedMutations = [{ let expectedMutations = [{
id: 'b', id: "b",
nodeName: 'DIV', nodeName: "DIV",
pseudos: [':hover', ':active'], pseudos: [":hover", ":active"],
}, },
{ {
id: 'longlist', id: "longlist",
nodeName: 'DIV', nodeName: "DIV",
pseudos: [':hover'] pseudos: [":hover"]
}, },
{ {
nodeName: 'BODY', nodeName: "BODY",
pseudos: [':hover'] pseudos: [":hover"]
}, },
{ {
nodeName: 'HTML', nodeName: "HTML",
pseudos: [':hover'] pseudos: [":hover"]
}]; }];
checkMutations(mutations, expectedMutations); checkMutations(mutations, expectedMutations);
}).then(() => { }).then(() => {
// Now remove the :hover on all parents // Now remove the :hover on all parents
gWalker.removePseudoClassLock(nodeFront, ':hover', {parents: true}); gWalker.removePseudoClassLock(nodeFront, ":hover", {parents: true});
return promiseOnce(gWalker, "mutations"); return promiseOnce(gWalker, "mutations");
}).then(mutations => { }).then(mutations => {
let expectedMutations = [{ let expectedMutations = [{
id: 'b', id: "b",
nodeName: 'DIV', nodeName: "DIV",
// Should still have :active on the original node. // Should still have :active on the original node.
pseudos: [':active'] pseudos: [":active"]
}, },
{ {
id: 'longlist', id: "longlist",
nodeName: 'DIV', nodeName: "DIV",
pseudos: [] pseudos: []
}, },
{ {
nodeName: 'BODY', nodeName: "BODY",
pseudos: [] pseudos: []
}, },
{ {
nodeName: 'HTML', nodeName: "HTML",
pseudos: [] pseudos: []
}]; }];
checkMutations(mutations, expectedMutations); checkMutations(mutations, expectedMutations);
@ -170,7 +172,8 @@ addTest(function testPseudoClassLock() {
// Now shut down the walker and make sure that clears up the remaining lock. // Now shut down the walker and make sure that clears up the remaining lock.
return gWalker.release(); return gWalker.release();
}).then(() => { }).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(); teardown();
}).then(runNextTest)); }).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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gWalker = null; let gWalker = null;
var gClient = null; let gClient = null;
function assertOwnership() { function assertOwnership() {
return assertOwnershipTrees(gWalker); return assertOwnershipTrees(gWalker);
@ -27,7 +27,7 @@ function assertOwnership() {
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; 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 {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
@ -45,7 +45,8 @@ addTest(function testReleaseSubtree() {
promiseDone(gWalker.querySelectorAll(gWalker.rootNode, "#longlist div").then(list => { promiseDone(gWalker.querySelectorAll(gWalker.rootNode, "#longlist div").then(list => {
// Make sure we have the 26 children of longlist in our ownership tree. // Make sure we have the 26 children of longlist in our ownership tree.
is(list.length, 26, "Expect 26 div children."); 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(); return list.items();
}).then((items)=> { }).then((items)=> {
originalOwnershipSize = assertOwnership(); originalOwnershipSize = assertOwnership();
@ -69,7 +70,8 @@ addTest(function testReleaseSubtree() {
longlist = node.actorID; longlist = node.actorID;
return gWalker.releaseNode(node); return gWalker.releaseNode(node);
}).then(() => { }).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(); let newOwnershipSize = assertOwnership();
is(newOwnershipSize, originalOwnershipSize - 53, is(newOwnershipSize, originalOwnershipSize - 53,
"Ownership tree should be lower"); "Ownership tree should be lower");
@ -81,12 +83,10 @@ addTest(function testReleaseSubtree() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gClient; gClient = null;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gClient = null; let gWalker = null;
var gWalker = null;
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
return inspector.getWalker(); return inspector.getWalker();
}).then(walker => { }).then(walker => {
@ -41,7 +39,6 @@ addTest(function setup() {
}); });
addTest(function testReload() { addTest(function testReload() {
let nodeFront;
let oldRootID = gWalker.rootNode.actorID; let oldRootID = gWalker.rootNode.actorID;
// Load a node to populate the tree a bit. // Load a node to populate the tree a bit.
promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(front => { promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(front => {
@ -58,13 +55,10 @@ addTest(function testReload() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gInspectee; gInspectee = null;
delete gClient;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gWalker = null; let gWalker = null;
var gClient = null; let gClient = null;
let gInspectee = null;
function assertOwnership() { function assertOwnership() {
return assertOwnershipTrees(gWalker); return assertOwnershipTrees(gWalker);
@ -33,7 +34,7 @@ function ignoreNode(node) {
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
@ -80,8 +81,10 @@ addTest(function testRemoveSubtree() {
is(originalOwnershipSize, 56, "Correct number of items in ownership tree"); is(originalOwnershipSize, 56, "Correct number of items in ownership tree");
return gWalker.removeNode(longlist); return gWalker.removeNode(longlist);
}).then(siblings => { }).then(siblings => {
is(siblings.previousSibling.rawNode(), previousSibling, "Should have returned the previous sibling."); is(siblings.previousSibling.rawNode(), previousSibling,
is(siblings.nextSibling.rawNode(), nextSibling, "Should have returned the next sibling."); "Should have returned the previous sibling.");
is(siblings.nextSibling.rawNode(), nextSibling,
"Should have returned the next sibling.");
return waitForMutation(gWalker, isChildList); return waitForMutation(gWalker, isChildList);
}).then(() => { }).then(() => {
// Our ownership size should now be 51 fewer (we forgot about #longlist + 26 // Our ownership size should now be 51 fewer (we forgot about #longlist + 26
@ -96,12 +99,11 @@ addTest(function testRemoveSubtree() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gClient; gClient = null;
gInspectee = null;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
window.onload = function () {
const Cu = Components.utils; const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const promise = require("promise"); const promise = require("promise");
const {InspectorFront} = require("devtools/shared/fronts/inspector"); const {InspectorFront} = require("devtools/shared/fronts/inspector");
const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
@ -24,12 +25,13 @@ window.onload = function() {
let inspector = null; let inspector = null;
addAsyncTest(function* setup() { addAsyncTest(function* setup() {
info ("Setting up inspector and walker actors."); info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
// eslint-disable-next-line new-cap
yield new promise(resolve => { yield new promise(resolve => {
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
win = doc.defaultView; win = doc.defaultView;
inspector = InspectorFront(client, tab); inspector = InspectorFront(client, tab);
resolve(); resolve();
@ -39,7 +41,7 @@ window.onload = function() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function*() { addAsyncTest(function* () {
let walker = yield inspector.getWalker(); let walker = yield inspector.getWalker();
// We can't receive events from the walker if we haven't first executed a // 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"); yield walker.querySelector(walker.rootNode, "img");
let {outerWidth, outerHeight} = win; let {outerWidth, outerHeight} = win;
// eslint-disable-next-line new-cap
let onResize = new promise(resolve => { let onResize = new promise(resolve => {
walker.once("resize", () => { walker.once("resize", () => {
resolve(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspector; let gInspector;
var gDoc; let gDoc;
addTest(function() { addTest(function () {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gDoc = doc; gDoc = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
gInspector = InspectorFront(client, tab); gInspector = InspectorFront(client, tab);
@ -31,7 +31,7 @@ addTest(function() {
}); });
}); });
addTest(function() { addTest(function () {
info("Resolve a relative URL without providing a context node"); info("Resolve a relative URL without providing a context node");
gInspector.resolveRelativeURL("test.png?id=4#wow").then(url => { gInspector.resolveRelativeURL("test.png?id=4#wow").then(url => {
is(url, "chrome://mochitests/content/chrome/devtools/server/tests/" + 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"); info("Resolve an absolute URL without providing a context node");
gInspector.resolveRelativeURL("chrome://mochitests/content/chrome/" + gInspector.resolveRelativeURL("chrome://mochitests/content/chrome/" +
"devtools/server/").then(url => { "devtools/server/").then(url => {
is(url, "chrome://mochitests/content/chrome/devtools/server/"); is(url, "chrome://mochitests/content/chrome/devtools/server/");
runNextTest(); runNextTest();
}); });
}); });
addTest(function() { addTest(function () {
info("Resolve a relative URL providing a context node"); info("Resolve a relative URL providing a context node");
let node = gDoc.querySelector(".big-horizontal"); let node = gDoc.querySelector(".big-horizontal");
gInspector.resolveRelativeURL("test.png?id=4#wow", node).then(url => { 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"); info("Resolve an absolute URL providing a context node");
let node = gDoc.querySelector(".big-horizontal"); let node = gDoc.querySelector(".big-horizontal");
gInspector.resolveRelativeURL("chrome://mochitests/content/chrome/" + gInspector.resolveRelativeURL("chrome://mochitests/content/chrome/" +
"devtools/server/", node).then(url => { "devtools/server/", node).then(url => {
is(url, "chrome://mochitests/content/chrome/devtools/server/"); is(url, "chrome://mochitests/content/chrome/devtools/server/");
runNextTest(); runNextTest();
}); });
}); });
addTest(function() { addTest(function () {
gInspector = gDoc = null; gInspector = null;
gDoc = null;
runNextTest(); runNextTest();
}); });
</script> </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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gWalker = null; let gWalker = null;
var gClient = null; let gInspectee = null;
var gInspectee = null;
function assertOwnership() { function assertOwnership() {
return assertOwnershipTrees(gWalker); return assertOwnershipTrees(gWalker);
@ -28,13 +27,12 @@ function assertOwnership() {
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -50,7 +48,6 @@ addTest(function setup() {
addTest(function testRetain() { addTest(function testRetain() {
let originalOwnershipSize = 0; let originalOwnershipSize = 0;
let bodyFront = null; let bodyFront = null;
let frameFront = null;
let childListFront = null; let childListFront = null;
// Get the toplevel body element and retain it. // Get the toplevel body element and retain it.
promiseDone(gWalker.querySelector(gWalker.rootNode, "body").then(front => { 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. // Get an element in the child frame and retain it.
return gWalker.querySelector(gWalker.rootNode, "#childFrame"); return gWalker.querySelector(gWalker.rootNode, "#childFrame");
}).then(frame => { }).then(frame => {
frameFront = frame;
return gWalker.children(frame, { maxNodes: 1 }).then(children => { return gWalker.children(frame, { maxNodes: 1 }).then(children => {
return children.nodes[0]; return children.nodes[0];
}); });
@ -75,7 +71,6 @@ addTest(function testRetain() {
// OK, try releasing the parent of the first retained. // OK, try releasing the parent of the first retained.
return gWalker.releaseNode(bodyFront.parentNode()); return gWalker.releaseNode(bodyFront.parentNode());
}).then(() => { }).then(() => {
let size = assertOwnership();
let clientTree = clientOwnershipTree(gWalker); let clientTree = clientOwnershipTree(gWalker);
// That request should have freed the parent of the first retained // That request should have freed the parent of the first retained
@ -84,26 +79,25 @@ addTest(function testRetain() {
originalOwnershipSize, originalOwnershipSize,
"Should have only lost one item overall."); "Should have only lost one item overall.");
is(gWalker._retainedOrphans.size, 1, "Should have retained one orphan"); 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(() => { }).then(() => {
// Unretain the body, which should promote the childListFront to a retained orphan. // Unretain the body, which should promote the childListFront to a retained orphan.
return gWalker.unretainNode(bodyFront); return gWalker.unretainNode(bodyFront);
}).then(() => { }).then(() => {
assertOwnership(); assertOwnership();
let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 1, "Should still only have one retained orphan."); 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(bodyFront), "Should have dropped the body node.");
ok(gWalker._retainedOrphans.has(childListFront), "Should have retained the child node.") ok(gWalker._retainedOrphans.has(childListFront),
"Should have retained the child node.");
}).then(() => { }).then(() => {
// Change the source of the iframe, which should kill the retained orphan. // Change the source of the iframe, which should kill the retained orphan.
gInspectee.querySelector("#childFrame").src = "data:text/html,<html>new child</html>"; gInspectee.querySelector("#childFrame").src = "data:text/html,<html>new child</html>";
return waitForMutation(gWalker, isUnretained); return waitForMutation(gWalker, isUnretained);
}).then(mutations => { }).then(mutations => {
assertOwnership(); assertOwnership();
let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans."); is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans.");
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -123,14 +117,12 @@ addTest(function testWinRace() {
]); ]);
}).then(() => { }).then(() => {
assertOwnership(); assertOwnership();
let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 1, "Should have a retained orphan."); is(gWalker._retainedOrphans.size, 1, "Should have a retained orphan.");
ok(gWalker._retainedOrphans.has(front), "Should have retained our expected node."); ok(gWalker._retainedOrphans.has(front), "Should have retained our expected node.");
return gWalker.unretainNode(front); return gWalker.unretainNode(front);
}).then(() => { }).then(() => {
// Make sure we're clear for the next test. // Make sure we're clear for the next test.
assertOwnership(); assertOwnership();
let clientTree = clientOwnershipTree(gWalker);
is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans."); is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans.");
}).then(runNextTest)); }).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 // 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). // getMutations request, but there's nothing else it would be).
is(gWalker._requests.length, 1, "Should have an outstanding request."); is(gWalker._requests.length, 1, "Should have an outstanding request.");
return gWalker.retainNode(front) return gWalker.retainNode(front);
}).then(() => { ok(false, "Request should not have succeeded!"); }, }).then(() => ok(false, "Request should not have succeeded!"),
(err) => { (err) => {
ok(err, "noSuchActor", "Should have lost the race."); ok(err, "noSuchActor", "Should have lost the race.");
let clientTree = clientOwnershipTree(gWalker); is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans.");
is(gWalker._retainedOrphans.size, 0, "Should have no more retained orphans."); // Don't re-throw the error.
// Don't re-throw the error. }).then(runNextTest));
}).then(runNextTest));
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gClient; gInspectee = null;
runNextTest(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gClient = null; let gWalker = null;
var gWalker = null;
function assertOwnership() {
assertOwnershipTrees(gWalker);
}
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
ok(walker, "getWalker() should return an actor."); ok(walker, "getWalker() should return an actor.");
gClient = client;
gWalker = walker; gWalker = walker;
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -67,9 +61,8 @@ addTest(Task.async(function* testScrollIntoView() {
})); }));
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gInspectee; gInspectee = null;
delete gClient;
runNextTest(); runNextTest();
}); });
</script> </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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
window.onload = function () {
const Cu = Components.utils; const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const promise = require("promise"); const promise = require("promise");
const {InspectorFront} = require("devtools/shared/fronts/inspector"); const {InspectorFront} = require("devtools/shared/fronts/inspector");
const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
let walkerFront = null; let walkerFront = null;
let inspectee = null;
let inspector = null; let inspector = null;
// WalkerFront specific tests. These aren't to excercise search // WalkerFront specific tests. These aren't to excercise search
@ -29,13 +29,13 @@ window.onload = function() {
// See also test_inspector-search.html // See also test_inspector-search.html
addAsyncTest(function* setup() { addAsyncTest(function* setup() {
info ("Setting up inspector and walker actors."); info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
// eslint-disable-next-line new-cap
yield new promise(resolve => { yield new promise(resolve => {
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
inspectee = doc;
inspector = InspectorFront(client, tab); inspector = InspectorFront(client, tab);
resolve(); resolve();
}); });
@ -48,7 +48,7 @@ window.onload = function() {
}); });
addAsyncTest(function* testWalkerFrontDefaults() { addAsyncTest(function* testWalkerFrontDefaults() {
info ("Testing search API using WalkerFront."); info("Testing search API using WalkerFront.");
let nodes = yield walkerFront.querySelectorAll(walkerFront.rootNode, "h2"); let nodes = yield walkerFront.querySelectorAll(walkerFront.rootNode, "h2");
let fronts = yield nodes.items(); let fronts = yield nodes.items();
@ -77,7 +77,7 @@ window.onload = function() {
}); });
addAsyncTest(function* testMultipleSearches() { 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 nodes = yield walkerFront.querySelectorAll(walkerFront.rootNode, "h2");
let fronts = yield nodes.items(); let fronts = yield nodes.items();
@ -119,7 +119,7 @@ window.onload = function() {
}); });
addAsyncTest(function* testMultipleSearchesReverse() { 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 nodes = yield walkerFront.querySelectorAll(walkerFront.rootNode, "h2");
let fronts = yield nodes.items(); let fronts = yield nodes.items();
@ -168,9 +168,8 @@ window.onload = function() {
runNextTest(); runNextTest();
}); });
addAsyncTest(function* testBackwardsCompat() { 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; walkerFront.traits.textSearch = false;
let front = yield walkerFront.querySelector(walkerFront.rootNode, "h1"); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
window.onload = function() { "use strict";
window.onload = function () {
const Cu = Components.utils; const Cu = Components.utils;
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
const promise = require("promise"); const promise = require("promise");
const {InspectorFront} = require("devtools/shared/fronts/inspector"); const {InspectorFront} = require("devtools/shared/fronts/inspector");
const {WalkerSearch, WalkerIndex} = const {WalkerSearch, WalkerIndex} =
require("devtools/server/actors/utils/walker-search"); require("devtools/server/actors/utils/walker-search");
const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
@ -31,12 +32,13 @@ window.onload = function() {
// See also test_inspector-search-front.html. // See also test_inspector-search-front.html.
addAsyncTest(function* setup() { addAsyncTest(function* setup() {
info ("Setting up inspector and walker actors."); info("Setting up inspector and walker actors.");
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
// eslint-disable-next-line new-cap
yield new promise(resolve => { yield new promise(resolve => {
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
inspectee = doc; inspectee = doc;
inspector = InspectorFront(client, tab); inspector = InspectorFront(client, tab);
resolve(); resolve();
@ -56,7 +58,7 @@ window.onload = function() {
}); });
addAsyncTest(function* testIndexExists() { addAsyncTest(function* testIndexExists() {
info ("Testing basic index APIs exist."); info("Testing basic index APIs exist.");
let index = new WalkerIndex(walkerActor); let index = new WalkerIndex(walkerActor);
ok(index.data.size > 0, "public index is filled after getting"); ok(index.data.size > 0, "public index is filled after getting");
@ -70,7 +72,7 @@ window.onload = function() {
}); });
addAsyncTest(function* testSearchExists() { 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, "walker search exists on the WalkerActor");
ok(walkerSearch.search, "walker search has `search` method"); ok(walkerSearch.search, "walker search has `search` method");
@ -88,8 +90,8 @@ window.onload = function() {
}); });
addAsyncTest(function* testEmptySearch() { addAsyncTest(function* testEmptySearch() {
info ("Testing search with an empty query."); info("Testing search with an empty query.");
results = walkerSearch.search(""); let results = walkerSearch.search("");
is(results.length, 0, "No results when searching for ''"); is(results.length, 0, "No results when searching for ''");
results = walkerSearch.search(null); results = walkerSearch.search(null);
@ -165,7 +167,7 @@ window.onload = function() {
{node: inspectee.querySelector("h1 + p > strong").childNodes[0], type: "text"}, {node: inspectee.querySelector("h1 + p > strong").childNodes[0], type: "text"},
] ]
}, },
] ];
for (let {desc, search, expected} of testData) { for (let {desc, search, expected} of testData) {
info("Running test: " + desc); info("Running test: " + desc);
@ -178,7 +180,7 @@ window.onload = function() {
}); });
addAsyncTest(function* testPseudoElements() { addAsyncTest(function* testPseudoElements() {
info ("Testing ::before and ::after element matching"); info("Testing ::before and ::after element matching");
let beforeElt = new _documentWalker(inspectee.querySelector("#pseudo"), let beforeElt = new _documentWalker(inspectee.querySelector("#pseudo"),
inspectee.defaultView).firstChild(); inspectee.defaultView).firstChild();
@ -218,7 +220,7 @@ window.onload = function() {
}); });
addAsyncTest(function* testSearchMutationChangeResults() { addAsyncTest(function* testSearchMutationChangeResults() {
info ("Testing search before and after a mutation."); info("Testing search before and after a mutation.");
let expected = [ let expected = [
{node: inspectee.querySelectorAll("h3")[0], type: "tag"}, {node: inspectee.querySelectorAll("h3")[0], type: "tag"},
{node: inspectee.querySelectorAll("h3")[1], type: "tag"}, {node: inspectee.querySelectorAll("h3")[1], type: "tag"},
@ -238,6 +240,7 @@ window.onload = function() {
expected[2] expected[2]
], "Results are updated after removal"); ], "Results are updated after removal");
// eslint-disable-next-line new-cap
yield new promise(resolve => { yield new promise(resolve => {
info("Waiting for a mutation to happen"); info("Waiting for a mutation to happen");
let observer = new inspectee.defaultView.MutationObserver(() => { let observer = new inspectee.defaultView.MutationObserver(() => {
@ -254,6 +257,7 @@ window.onload = function() {
expected[2] expected[2]
], "Results are updated after addition"); ], "Results are updated after addition");
// eslint-disable-next-line new-cap
yield new promise(resolve => { yield new promise(resolve => {
info("Waiting for a mutation to happen"); info("Waiting for a mutation to happen");
let observer = new inspectee.defaultView.MutationObserver(() => { let observer = new inspectee.defaultView.MutationObserver(() => {
@ -274,6 +278,7 @@ window.onload = function() {
runNextTest(); runNextTest();
function mutateDocumentAndWaitForMutation(mutationFn) { function mutateDocumentAndWaitForMutation(mutationFn) {
// eslint-disable-next-line new-cap
return new promise(resolve => { return new promise(resolve => {
info("Listening to markup mutation on the inspectee"); info("Listening to markup mutation on the inspectee");
let observer = new inspectee.defaultView.MutationObserver(resolve); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/server/actors/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspectee = null; let gInspectee = null;
var gClient = null; let gClient = null;
var gWalker = null; let gWalker = null;
var checkActorIDs = []; let checkActorIDs = [];
function assertOwnership() { function assertOwnership() {
assertOwnershipTrees(gWalker); assertOwnershipTrees(gWalker);
} }
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; let url = document.getElementById("inspectorContent").href;
attachURL(url, function(err, client, tab, doc) { attachURL(url, function (err, client, tab, doc) {
gInspectee = doc; gInspectee = doc;
let {InspectorFront} = require("devtools/shared/fronts/inspector"); let {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); 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 // Make sure that refetching the root document of the walker returns the same
// actor as the getWalker returned. // actor as the getWalker returned.
promiseDone(gWalker.document().then(root => { 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); checkActorIDs.push(root.actorID);
assertOwnership(); assertOwnership();
}).then(runNextTest)); }).then(runNextTest));
@ -121,11 +122,12 @@ addTest(function testQuerySelectors() {
is(nodes[0], firstNode, "First node should be reused."); is(nodes[0], firstNode, "First node should be reused.");
ok(nodes[0]._parent, "Parent node should be set."); ok(nodes[0]._parent, "Parent node should be set.");
ok(nodes[0]._next || nodes[0]._prev, "Siblings 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(); assertOwnership();
return nodeList.items(-1); return nodeList.items(-1);
}).then(nodes => { }).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."); is(nodes[0].id, "z", "Expect it to be the last node.");
checkActorIDs.push(nodes[0].actorID); checkActorIDs.push(nodes[0].actorID);
// Save the node list ID so we can ensure it was destroyed. // 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 // Helper to check the response of requests that return hasFirst/hasLast/nodes
// node lists (like `children` and `siblings`) // node lists (like `children` and `siblings`)
function nodeArrayChecker(first, last, ids) { function nodeArrayChecker(first, last, ids) {
return function(response) { return function (response) {
is(response.hasFirst, first, "Should " + (first ? "" : "not ") + " have the first node."); is(response.hasFirst, first,
"Should " + (first ? "" : "not ") + " have the first node.");
is(response.hasLast, last, "Should " + (last ? "" : "not ") + " have the last node."); is(response.hasLast, last, "Should " + (last ? "" : "not ") + " have the last node.");
is(response.nodes.length, ids.length, "Should have " + ids.length + " children listed."); is(response.nodes.length, ids.length,
let responseIds = ''; "Should have " + ids.length + " children listed.");
for (node of response.nodes) { let responseIds = "";
for (let node of response.nodes) {
responseIds += node.id; responseIds += node.id;
} }
is(responseIds, ids, "Correct nodes were returned."); is(responseIds, ids, "Correct nodes were returned.");
assertOwnership(); assertOwnership();
} };
} }
addTest(function testNoChildren() { addTest(function testNoChildren() {
@ -163,8 +167,8 @@ addTest(function testNoChildren() {
}); });
addTest(function testLongListTraversal() { addTest(function testLongListTraversal() {
var longList; let longList;
var allChildren; let allChildren;
promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(node => { promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(node => {
longList = node; longList = node;
// First call with no options, expect all children. // First call with no options, expect all children.
@ -177,36 +181,37 @@ addTest(function testLongListTraversal() {
}).then(() => { }).then(() => {
// maxNodes should limit us to the first 5 nodes. // maxNodes should limit us to the first 5 nodes.
assertOwnership(); assertOwnership();
return gWalker.children(longList, { maxNodes: 5 }).then(nodeArrayChecker(true, false, 'abcde')); return gWalker.children(longList, { maxNodes: 5 })
.then(nodeArrayChecker(true, false, "abcde"));
}).then(() => { }).then(() => {
assertOwnership(); assertOwnership();
// maxNodes with the second item centered should still give us the first 5 nodes. // maxNodes with the second item centered should still give us the first 5 nodes.
return gWalker.children(longList, { maxNodes: 5, center: allChildren[1] }).then( return gWalker.children(longList, { maxNodes: 5, center: allChildren[1] }).then(
nodeArrayChecker(true, false, 'abcde') nodeArrayChecker(true, false, "abcde")
); );
}).then(() => { }).then(() => {
// maxNodes with a center in the middle of the list should put that item in the middle // maxNodes with a center in the middle of the list should put that item in the middle
let center = allChildren[13]; 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( return gWalker.children(longList, { maxNodes: 5, center: center }).then(
nodeArrayChecker(false, false, 'lmnop') nodeArrayChecker(false, false, "lmnop")
); );
}).then(() => { }).then(() => {
// maxNodes with the second-to-last item centered should give us the last 5 nodes. // 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( return gWalker.children(longList, { maxNodes: 5, center: allChildren[24] }).then(
nodeArrayChecker(false, true, 'vwxyz') nodeArrayChecker(false, true, "vwxyz")
); );
}).then(() => { }).then(() => {
// maxNodes with a start in the middle should start at that node and fetch 5 // maxNodes with a start in the middle should start at that node and fetch 5
let start = allChildren[13]; 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( return gWalker.children(longList, { maxNodes: 5, start: start }).then(
nodeArrayChecker(false, false, 'nopqr') nodeArrayChecker(false, false, "nopqr")
); );
}).then(() => { }).then(() => {
// maxNodes near the end should only return what's left // maxNodes near the end should only return what's left
return gWalker.children(longList, { maxNodes: 5, start: allChildren[24] }).then( return gWalker.children(longList, { maxNodes: 5, start: allChildren[24] }).then(
nodeArrayChecker(false, true, 'yz') nodeArrayChecker(false, true, "yz")
); );
}).then(runNextTest)); }).then(runNextTest));
}); });
@ -221,7 +226,8 @@ addTest(function testObjectNodeChildren() {
addTest(function testSiblings() { addTest(function testSiblings() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(a => { 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(() => { }).then(() => {
return gWalker.siblings(gWalker.rootNode).then(response => { return gWalker.siblings(gWalker.rootNode).then(response => {
ok(response.hasFirst && response.hasLast, "Has first and last."); ok(response.hasFirst && response.hasLast, "Has first and last.");
@ -255,7 +261,6 @@ addTest(function testPreviousSibling() {
}).then(runNextTest)); }).then(runNextTest));
}); });
addTest(function testFrameTraversal() { addTest(function testFrameTraversal() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => { promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
return gWalker.children(childFrame); return gWalker.children(childFrame);
@ -268,7 +273,8 @@ addTest(function testFrameTraversal() {
return gWalker.parents(childDocumentZ); return gWalker.parents(childDocumentZ);
}).then(parents => { }).then(parents => {
// Expected set of parent tag names for this item: // 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) { for (let parent of parents) {
let expected = expectedParents.shift(); let expected = expectedParents.shift();
is(parent.nodeName, expected, "Got expected parent"); is(parent.nodeName, expected, "Got expected parent");
@ -278,8 +284,10 @@ addTest(function testFrameTraversal() {
addTest(function testLongValue() { addTest(function testLongValue() {
const testSummaryLength = 10; const testSummaryLength = 10;
const inspector = require("devtools/server/actors/inspector");
inspector.setValueSummaryLength(testSummaryLength); inspector.setValueSummaryLength(testSummaryLength);
SimpleTest.registerCleanupFunction(function() { SimpleTest.registerCleanupFunction(function () {
inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH); inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH);
}); });
@ -298,7 +306,8 @@ addTest(function testLongValue() {
}).then(value => { }).then(value => {
return value.string(); return value.string();
}).then(valueStr => { }).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)); }).then(runNextTest));
}); });
@ -318,7 +327,8 @@ addTest(function testShortValue() {
}).then(value => { }).then(value => {
return value.string(); return value.string();
}).then(valueStr => { }).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)); }).then(runNextTest));
}); });
@ -327,18 +337,16 @@ addTest(function testReleaseWalker() {
promiseDone(gWalker.release().then(() => { promiseDone(gWalker.release().then(() => {
let promises = Array.from(checkActorIDs, (id) => checkMissing(gClient, id)); let promises = Array.from(checkActorIDs, (id) => checkMissing(gClient, id));
return promise.all(promises) return promise.all(promises);
}).then(runNextTest)); }).then(runNextTest));
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
delete gInspectee; gInspectee = null;
delete gClient; gClient = null;
runNextTest(); runNextTest();
}); });
</script> </script>
</head> </head>
<body> <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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
"use strict";
const flags = require("devtools/shared/flags"); const flags = require("devtools/shared/flags");
const wasTesting = flags.testing; 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 PATH = "http://mochi.test:8888/chrome/devtools/server/tests/mochitest/";
const BASE_IMAGE = PATH + "inspector-delay-image-response.sjs"; 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 TIMEOUT_IMAGE = BASE_IMAGE + "?delay=50000";
const NONEXISTENT_IMAGE = PATH + "this-does-not-exist.png"; const NONEXISTENT_IMAGE = PATH + "this-does-not-exist.png";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gImg = null; let gImg = null;
var gNodeFront = null; let gNodeFront = null;
var gWalker = null; let gWalker = null;
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; 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 {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
promiseDone(inspector.getWalker().then(walker => { promiseDone(inspector.getWalker().then(walker => {
gWalker = walker; gWalker = walker;
// eslint-disable-next-line max-nested-callbacks
return walker.querySelector(gWalker.rootNode, "img.custom").then(img => { return walker.querySelector(gWalker.rootNode, "img.custom").then(img => {
gNodeFront = img; gNodeFront = img;
gImg = doc.querySelector("img.custom"); gImg = doc.querySelector("img.custom");
@ -93,9 +97,9 @@ addTest(function testDelayedImage() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gImg; gImg = null;
delete gNodeFront gNodeFront = null;
delete gWalker; gWalker = null;
runNextTest(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
const inspector = require("devtools/shared/fronts/inspector"); "use strict";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gWalker = null; let gWalker = null;
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; 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 {InspectorFront} = require("devtools/shared/fronts/inspector");
let inspector = InspectorFront(client, tab); let inspector = InspectorFront(client, tab);
@ -45,6 +45,7 @@ addTest(function testLargeImage() {
is(imageData.size.naturalHeight, 3000, "Natural width of the image correct"); is(imageData.size.naturalHeight, 3000, "Natural width of the image correct");
ok(imageData.size.resized, "Image was resized"); ok(imageData.size.resized, "Image was resized");
// eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => { imageData.data.string().then(str => {
ok(str, "We have an image data string!"); ok(str, "We have an image data string!");
testResizing(imageData, str); testResizing(imageData, str);
@ -66,6 +67,7 @@ addTest(function testLargeCanvas() {
is(imageData.size.naturalHeight, 2000, "Natural width of the image correct"); is(imageData.size.naturalHeight, 2000, "Natural width of the image correct");
ok(imageData.size.resized, "Image was resized"); ok(imageData.size.resized, "Image was resized");
// eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => { imageData.data.string().then(str => {
ok(str, "We have an image data string!"); ok(str, "We have an image data string!");
testResizing(imageData, str); testResizing(imageData, str);
@ -87,6 +89,7 @@ addTest(function testSmallImage() {
is(imageData.size.naturalHeight, 240, "Natural width of the image correct"); is(imageData.size.naturalHeight, 240, "Natural width of the image correct");
ok(!imageData.size.resized, "Image was NOT resized"); ok(!imageData.size.resized, "Image was NOT resized");
// eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => { imageData.data.string().then(str => {
ok(str, "We have an image data string!"); ok(str, "We have an image data string!");
testResizing(imageData, str); testResizing(imageData, str);
@ -108,6 +111,7 @@ addTest(function testDataImage() {
is(imageData.size.naturalHeight, 28, "Natural width of the image correct"); is(imageData.size.naturalHeight, 28, "Natural width of the image correct");
ok(imageData.size.resized, "Image was resized"); ok(imageData.size.resized, "Image was resized");
// eslint-disable-next-line max-nested-callbacks
imageData.data.string().then(str => { imageData.data.string().then(str => {
ok(str, "We have an image data string!"); ok(str, "We have an image data string!");
testResizing(imageData, str); testResizing(imageData, str);
@ -123,7 +127,7 @@ addTest(function testNonImgOrCanvasElements() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gWalker; gWalker = null;
runNextTest(); 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"> <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" src="inspector-helpers.js"></script>
<script type="application/javascript"> <script type="application/javascript">
"use strict";
const flags = require("devtools/shared/flags"); const flags = require("devtools/shared/flags");
const wasTesting = flags.testing; 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 PATH = "http://mochi.test:8888/chrome/devtools/server/tests/mochitest/";
const BASE_IMAGE = PATH + "inspector-delay-image-response.sjs"; 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 TIMEOUT_IMAGE = BASE_IMAGE + "?delay=50000";
const NONEXISTENT_IMAGE = PATH + "this-does-not-exist.png"; const NONEXISTENT_IMAGE = PATH + "this-does-not-exist.png";
window.onload = function() { window.onload = function () {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
runNextTest(); runNextTest();
} };
var gInspector = null; let gInspector = null;
addTest(function setup() { addTest(function setup() {
let url = document.getElementById("inspectorContent").href; 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 {InspectorFront} = require("devtools/shared/fronts/inspector");
gInspector = InspectorFront(client, tab); gInspector = InspectorFront(client, tab);
runNextTest(); runNextTest();
@ -73,7 +76,7 @@ addTest(function testNormalImage() {
}); });
addTest(function cleanup() { addTest(function cleanup() {
delete gInspector; gInspector = null;
runNextTest(); runNextTest();
}); });

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше