Bug 1416928 - Test content script debugging on the new debugger UI. r=jlast

MozReview-Commit-ID: Dt0eaKmp777

--HG--
extra : rebase_source : 14db83ec4fb21e3f01d9f7b8955b3e56ece7b4a1
This commit is contained in:
Luca Greco 2017-11-15 17:54:23 +01:00
Родитель f6c2f83ad4
Коммит aa1e1912b4
3 изменённых файлов: 101 добавлений и 0 удалений

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

@ -24,6 +24,7 @@ support-files =
examples/reload/doc_reload.html
examples/doc-async.html
examples/doc-asm.html
examples/doc-content-script-sources.html
examples/doc-scripts.html
examples/doc-script-mutate.html
examples/doc-script-switching.html
@ -74,6 +75,7 @@ skip-if = !e10s # This test is only valid in e10s
[browser_dbg-chrome-create.js]
[browser_dbg-chrome-debugging.js]
[browser_dbg-console.js]
[browser_dbg-content-script-sources.js]
[browser_dbg-debugger-buttons.js]
[browser_dbg-editor-gutter.js]
[browser_dbg-editor-select.js]

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

@ -0,0 +1,87 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* global ExtensionTestUtils, closeTab, openToolboxForTab, assertDebugLine,
waitForSelectedSource */
// Tests that the content scripts are listed in the source tree.
async function selectContentScriptSources(dbg) {
await waitForSources(dbg, "content_script.js");
// Select a source.
await selectSource(dbg, "content_script.js");
ok(
findElementWithSelector(dbg, ".sources-list .focused"),
"Source is focused"
);
}
async function installAndStartExtension() {
function contentScript() {
console.log("content script loads");
// This listener prevents the source from being garbage collected
// and be missing from the scripts returned by `dbg.findScripts()`
// in `ThreadActor._discoverSources`.
window.onload = () => {};
}
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"content_scripts": [
{
"js": ["content_script.js"],
"matches": ["http://example.com/*"],
"run_at": "document_start",
},
],
},
files: {
"content_script.js": contentScript,
},
});
await extension.startup();
return extension;
}
add_task(async function () {
const extension = await installAndStartExtension();
let dbg = await initDebugger("doc-content-script-sources.html");
await selectContentScriptSources(dbg);
await closeTab(dbg, "content_script.js");
// Destroy the toolbox and repeat the test in a new toolbox
// and ensures that the content script is still listed.
await dbg.toolbox.destroy();
const toolbox = await openToolboxForTab(gBrowser.selectedTab, "jsdebugger");
dbg = createDebuggerContext(toolbox);
await selectContentScriptSources(dbg);
await addBreakpoint(dbg, "content_script.js", 2);
for (let i = 1; i < 3; i++) {
info(`Reloading tab (${i} time)`);
gBrowser.reloadTab(gBrowser.selectedTab);
await waitForPaused(dbg);
await waitForSources(dbg, "content_script.js");
await waitForSelectedSource(dbg, "content_script.js");
ok(
findElementWithSelector(dbg, ".sources-list .focused"),
"Source is focused"
);
assertPausedLocation(dbg);
assertDebugLine(dbg, 2);
await resume(dbg);
}
await closeTab(dbg, "content_script.js");
await extension.unload();
});

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

@ -0,0 +1,12 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Debugger test page</title>
</head>
<body>
</body>
</html>