Bug 1319049 - fix RegExp previewer for worker debugging;r=ochameau

MozReview-Commit-ID: D8hRGV0MWoZ

--HG--
extra : rebase_source : 7b24311401b9cf7241eead84ca8b3c0f95f6a0cd
This commit is contained in:
Julian Descottes 2016-12-19 10:58:08 +01:00
parent 52b4c327cc
commit 70997ce55a
5 changed files with 14 additions and 30 deletions

View File

@ -1,4 +1,4 @@
// Check that the date previewer works in the console of a worker debugger.
// Check that the date and regexp previewers work in the console of a worker debugger.
"use strict";
@ -15,6 +15,11 @@ add_task(function* testPausedByConsole() {
ok(executed.textContent.includes("1970-01-01T00:00:00.000Z"),
"Text for message appeared correct");
info("Check RegExp objects can be used in the console");
executed = yield jsterm.execute("new RegExp('.*')");
ok(executed.textContent.includes("/.*/"),
"Text for message appeared correct");
terminateWorkerInTab(tab, WORKER_URL);
yield waitForWorkerClose(workerClient);
yield gDevTools.closeToolbox(TargetFactory.forWorker(workerClient));

View File

@ -84,7 +84,6 @@ support-files =
test-console-output-04.html
test-console-output-dom-elements.html
test-console-output-events.html
test-console-output-regexp.html
test-console-column.html
test-consoleiframes.html
test-console-trace-async.html

View File

@ -3,19 +3,18 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test the webconsole output for various types of objects.
// Test the webconsole output for a regexp object.
"use strict";
const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
"test/test-console-output-regexp.html";
const TEST_URI = "data:text/html;charset=utf8,<p>test regexp output";
var inputTests = [
// 0
{
input: "/foo/igym",
output: "/foo/gimy",
printOutput: "Error: source called",
printOutput: "/foo/gimy",
inspectable: true,
},
];

View File

@ -1,23 +0,0 @@
<!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8">
<title>Test the web console output for RegExp</title>
<!--
- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/
-->
</head>
<body>
<p>hello world!</p>
<script type="text/javascript">
Object.defineProperty(RegExp.prototype, "flags", {
get: function() { throw Error("flags called"); }
})
Object.defineProperty(RegExp.prototype, "source", {
get: function() { throw Error("source called"); },
})
</script>
</body>
</html>

View File

@ -1158,7 +1158,11 @@ DebuggerServer.ObjectActorPreviewers = {
}],
RegExp: [function ({obj, hooks}, grip) {
let str = RegExp.prototype.toString.call(obj.unsafeDereference());
let str = DevToolsUtils.callPropertyOnObject(obj, "toString");
if (typeof str != "string") {
return false;
}
grip.displayString = hooks.createValueGrip(str);
return true;
}],