зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533202
Part 3 - Add test for previewing in workers.
--HG-- extra : rebase_source : bfcd3d9c43f3e51b3dd956b01eb32a80d6a427eb
This commit is contained in:
Родитель
87d3e60af3
Коммит
bda8d7ed6b
|
@ -661,6 +661,8 @@ support-files =
|
|||
examples/doc-windowless-workers.html
|
||||
examples/doc-windowless-workers-early-breakpoint.html
|
||||
examples/simple-worker.js
|
||||
examples/doc-worker-scopes.html
|
||||
examples/scopes-worker.js
|
||||
examples/doc-event-handler.html
|
||||
examples/doc-eval-throw.html
|
||||
examples/doc-sourceURL-breakpoint.html
|
||||
|
@ -786,6 +788,7 @@ skip-if = os == "win"
|
|||
skip-if = true
|
||||
[browser_dbg-windowless-workers.js]
|
||||
[browser_dbg-windowless-workers-early-breakpoint.js]
|
||||
[browser_dbg-worker-scopes.js]
|
||||
[browser_dbg-event-handler.js]
|
||||
[browser_dbg-eval-throw.js]
|
||||
[browser_dbg-sourceURL-breakpoint.js]
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function findNode(dbg, text) {
|
||||
for (let index = 0;; index++) {
|
||||
var elem = findElement(dbg, "scopeNode", index);
|
||||
if (elem && elem.innerText == text) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleNode(dbg, text) {
|
||||
return toggleObjectInspectorNode(findNode(dbg, text));
|
||||
}
|
||||
|
||||
function findNodeValue(dbg, text) {
|
||||
for (let index = 0;; index++) {
|
||||
var elem = findElement(dbg, "scopeNode", index);
|
||||
if (elem && elem.innerText == text) {
|
||||
return findElement(dbg, "scopeValue", index).innerText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test that unusual objects have their contents shown in worker thread scopes.
|
||||
add_task(async function() {
|
||||
const dbg = await initDebugger("doc-worker-scopes.html", "scopes-worker.js");
|
||||
const workerSource = findSource(dbg, "scopes-worker.js");
|
||||
|
||||
await addBreakpoint(dbg, workerSource, 11);
|
||||
invokeInTab("startWorker");
|
||||
await waitForPaused(dbg, "scopes-worker.js");
|
||||
await removeBreakpoint(dbg, workerSource.id, 11);
|
||||
|
||||
// We should be paused at the first line of simple-worker.js
|
||||
assertPausedAtSourceAndLine(dbg, workerSource.id, 11);
|
||||
|
||||
await toggleNode(dbg, "var_array");
|
||||
ok(findNodeValue(dbg, "0") == "\"mango\"", "array elem0");
|
||||
ok(findNodeValue(dbg, "1") == "\"pamplemousse\"", "array elem1");
|
||||
ok(findNodeValue(dbg, "2") == "\"pineapple\"", "array elem2");
|
||||
await toggleNode(dbg, "var_array");
|
||||
|
||||
await toggleNode(dbg, "var_tarray");
|
||||
ok(findNodeValue(dbg, "0") == "42", "tarray elem0");
|
||||
ok(findNodeValue(dbg, "1") == "43", "tarray elem1");
|
||||
ok(findNodeValue(dbg, "2") == "44", "tarray elem2");
|
||||
await toggleNode(dbg, "var_tarray");
|
||||
|
||||
await toggleNode(dbg, "var_set");
|
||||
await toggleNode(dbg, "<entries>");
|
||||
|
||||
ok(findNodeValue(dbg, "0") == "\"papaya\"", "set elem0");
|
||||
ok(findNodeValue(dbg, "1") == "\"banana\"", "set elem1");
|
||||
await toggleNode(dbg, "var_set");
|
||||
|
||||
await toggleNode(dbg, "var_map");
|
||||
await toggleNode(dbg, "<entries>");
|
||||
await toggleNode(dbg, "0");
|
||||
ok(findNodeValue(dbg, "<key>"), "1");
|
||||
ok(findNodeValue(dbg, "<value>"), "\"one\"");
|
||||
await toggleNode(dbg, "0");
|
||||
await toggleNode(dbg, "1");
|
||||
ok(findNodeValue(dbg, "<key>"), "2");
|
||||
ok(findNodeValue(dbg, "<value>"), "\"two\"");
|
||||
await toggleNode(dbg, "var_map");
|
||||
|
||||
await toggleNode(dbg, "var_weakmap");
|
||||
await toggleNode(dbg, "<entries>");
|
||||
await toggleNode(dbg, "0");
|
||||
await toggleNode(dbg, "<key>");
|
||||
ok(findNodeValue(dbg, "foo"), "foo");
|
||||
await toggleNode(dbg, "<value>");
|
||||
ok(findNodeValue(dbg, "bar"), "bar");
|
||||
await toggleNode(dbg, "var_weakmap");
|
||||
|
||||
await toggleNode(dbg, "var_weakset");
|
||||
await toggleNode(dbg, "<entries>");
|
||||
await toggleNode(dbg, "0");
|
||||
ok(findNodeValue(dbg, "foo"), "foo");
|
||||
await toggleNode(dbg, "var_weakset");
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<script>
|
||||
startWorker();
|
||||
|
||||
function startWorker() {
|
||||
w = new Worker("scopes-worker.js");
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
Hello World!
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
function f() {
|
||||
var var_array = ["mango","pamplemousse","pineapple"];
|
||||
var var_tarray = new Uint8Array([42,43,44]);
|
||||
var var_set = new Set(["papaya","banana"]);
|
||||
var var_map = new Map([[1,"one"],[2,"two"]]);
|
||||
var var_weakmap = new WeakMap();
|
||||
var key = { foo: "foo" }, value = { bar: "bar" };
|
||||
var_weakmap.set(key, value);
|
||||
var var_weakset = new WeakSet();
|
||||
var_weakset.add(key);
|
||||
return 0;
|
||||
}
|
||||
f();
|
Загрузка…
Ссылка в новой задаче