Bug 1605854 - Remove uneval/toSource from devtools tests. r=jlast

For test browser_net_prefs-reload.js, I am not sure about this change firstValue/currentValue seems to be different types numbers, strings, objects.
toString is maybe not the best way to compare those values.

Differential Revision: https://phabricator.services.mozilla.com/D58313

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Schuster 2020-01-03 15:30:08 +00:00
Родитель 1d798d7582
Коммит 1596f1aa17
15 изменённых файлов: 59 добавлений и 59 удалений

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

@ -27,7 +27,7 @@ const setCensusDisplay = (exports.setCensusDisplay = function(display) {
display.breakdown &&
display.breakdown.by,
"Breakdowns must be an object with a `by` property, attempted to set: " +
uneval(display)
JSON.stringify(display)
);
return {

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

@ -31,7 +31,7 @@ const setLabelDisplay = (exports.setLabelDisplay = function(display) {
display.breakdown &&
display.breakdown.by,
"Breakdowns must be an object with a `by` property, attempted to set: " +
uneval(display)
JSON.stringify(display)
);
return {

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

@ -399,7 +399,7 @@ const fetchIndividuals = (exports.fetchIndividuals = function(
labelDisplay = getState().labelDisplay;
assert(
labelDisplay && labelDisplay.breakdown && labelDisplay.breakdown.by,
`Should have a breakdown to label nodes with, got: ${uneval(
`Should have a breakdown to label nodes with, got: ${JSON.stringify(
labelDisplay
)}`
);
@ -617,7 +617,7 @@ const fetchDominatorTree = (exports.fetchDominatorTree = TaskCache.declareCachea
display = getState().labelDisplay;
assert(
display && display.breakdown,
`Should have a breakdown to describe nodes with, got: ${uneval(
`Should have a breakdown to describe nodes with, got: ${JSON.stringify(
display
)}`
);

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

@ -30,7 +30,7 @@ const setTreeMap = (exports.setTreeMap = function(display) {
display.breakdown &&
display.breakdown.by,
"Breakdowns must be an object with a `by` property, attempted to set: " +
uneval(display)
JSON.stringify(display)
);
return {

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

@ -103,13 +103,13 @@ add_task(async function() {
const validateValue = prefsToCheck[name].validateValue;
is(
firstValue.toSource(),
currentValue.toSource(),
firstValue.toString(),
currentValue.toString(),
"Pref " + name + " should be equal to first value: " + currentValue
);
is(
validateValue().toSource(),
currentValue.toSource(),
validateValue().toString(),
currentValue.toString(),
"Pref " + name + " should validate: " + currentValue
);
}
@ -136,24 +136,24 @@ add_task(async function() {
info("Modified UI element affecting " + name + " to: " + newValue);
is(
firstValue.toSource(),
currentValue.toSource(),
firstValue.toString(),
currentValue.toString(),
"Pref " +
name +
" should still be equal to first value: " +
currentValue
);
isnot(
newValue.toSource(),
currentValue.toSource(),
newValue.toString(),
currentValue.toString(),
"Pref " +
name +
" should't yet be equal to second value: " +
currentValue
);
is(
validateValue().toSource(),
newValue.toSource(),
validateValue().toString(),
newValue.toString(),
"The UI element affecting " + name + " should validate: " + newValue
);
}
@ -176,18 +176,18 @@ add_task(async function() {
const validateValue = prefsToCheck[name].validateValue;
isnot(
firstValue.toSource(),
currentValue.toSource(),
firstValue.toString(),
currentValue.toString(),
"Pref " + name + " should't be equal to first value: " + currentValue
);
is(
newValue.toSource(),
currentValue.toSource(),
newValue.toString(),
currentValue.toString(),
"Pref " + name + " should now be equal to second value: " + currentValue
);
is(
validateValue().toSource(),
newValue.toSource(),
validateValue().toString(),
newValue.toString(),
"The UI element affecting " + name + " should validate: " + newValue
);
}
@ -214,24 +214,24 @@ add_task(async function() {
info("Modified UI element affecting " + name + " to: " + firstValue);
isnot(
firstValue.toSource(),
currentValue.toSource(),
firstValue.toString(),
currentValue.toString(),
"Pref " +
name +
" should't yet be equal to first value: " +
currentValue
);
is(
newValue.toSource(),
currentValue.toSource(),
newValue.toString(),
currentValue.toString(),
"Pref " +
name +
" should still be equal to second value: " +
currentValue
);
is(
validateValue().toSource(),
firstValue.toSource(),
validateValue().toString(),
firstValue.toString(),
"The UI element affecting " + name + " should validate: " + firstValue
);
}

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

@ -53,18 +53,18 @@ add_task(async function() {
await rangeSelected;
is(
markersOverview.getSelection().toSource(),
framerateGraph.getSelection().toSource(),
JSON.stringify(markersOverview.getSelection()),
JSON.stringify(framerateGraph.getSelection()),
"The markers overview has a correct selection."
);
is(
memoryGraph.getSelection().toSource(),
framerateGraph.getSelection().toSource(),
JSON.stringify(memoryGraph.getSelection()),
JSON.stringify(framerateGraph.getSelection()),
"The memory overview has a correct selection."
);
is(
framerateGraph.getSelection().toSource(),
"({start:0, end:" + width / 2 + "})",
JSON.stringify(framerateGraph.getSelection()),
JSON.stringify({ start: 0, end: width / 2 }),
"The framerate graph has a correct selection."
);
@ -78,18 +78,18 @@ add_task(async function() {
await rangeSelected;
is(
markersOverview.getSelection().toSource(),
framerateGraph.getSelection().toSource(),
JSON.stringify(markersOverview.getSelection()),
JSON.stringify(framerateGraph.getSelection()),
"The markers overview has a correct selection."
);
is(
memoryGraph.getSelection().toSource(),
framerateGraph.getSelection().toSource(),
JSON.stringify(memoryGraph.getSelection()),
JSON.stringify(framerateGraph.getSelection()),
"The memory overview has a correct selection."
);
is(
framerateGraph.getSelection().toSource(),
"({start:0, end:" + width / 4 + "})",
JSON.stringify(framerateGraph.getSelection()),
JSON.stringify({ start: 0, end: width / 4 }),
"The framerate graph has a correct selection."
);
@ -103,18 +103,18 @@ add_task(async function() {
await rangeSelected;
is(
markersOverview.getSelection().toSource(),
framerateGraph.getSelection().toSource(),
JSON.stringify(markersOverview.getSelection()),
JSON.stringify(framerateGraph.getSelection()),
"The markers overview has a correct selection."
);
is(
memoryGraph.getSelection().toSource(),
framerateGraph.getSelection().toSource(),
JSON.stringify(memoryGraph.getSelection()),
JSON.stringify(framerateGraph.getSelection()),
"The memory overview has a correct selection."
);
is(
framerateGraph.getSelection().toSource(),
"({start:0, end:" + width / 10 + "})",
JSON.stringify(framerateGraph.getSelection()),
JSON.stringify({ start: 0, end: width / 10 }),
"The framerate graph has a correct selection."
);

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

@ -14,8 +14,8 @@ add_task(function() {
} = require("devtools/shared/performance/recording-utils");
const output = getProfileThreadFromAllocations(TEST_DATA);
equal(
output.toSource(),
EXPECTED_OUTPUT.toSource(),
JSON.stringify(output),
JSON.stringify(EXPECTED_OUTPUT),
"The output is correct."
);
});

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

@ -104,7 +104,9 @@ function testColorMatch(name, hex, hsl, rgb, rgba, canvas) {
ok(!rgbFail, "color " + rgba + " matches target. Type: " + type);
if (rgbFail) {
info(
`target: ${target.toSource()}, color: [r: ${r}, g: ${g}, b: ${b}, a: ${a}]`
`target: ${JSON.stringify(
target
)}, color: [r: ${r}, g: ${g}, b: ${b}, a: ${a}]`
);
}

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

@ -23,7 +23,7 @@ function performTest() {
ok(out, "Some data was outputted properly");
is(out.length, PALLETTE_SIZE, "The outputted length is correct.");
info("Got flame graph data:\n" + out.toSource() + "\n");
info("Got flame graph data:\n" + JSON.stringify(out) + "\n");
for (let i = 0; i < out.length; i++) {
const found = out[i];

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

@ -24,7 +24,7 @@ function performTest() {
ok(out, "Some data was outputted properly");
is(out.length, PALLETTE_SIZE, "The outputted length is correct.");
info("Got flame graph data:\n" + out.toSource() + "\n");
info("Got flame graph data:\n" + JSON.stringify(out) + "\n");
for (let i = 0; i < out.length; i++) {
const found = out[i];

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

@ -24,7 +24,7 @@ function performTest() {
ok(out, "Some data was outputted properly");
is(out.length, PALLETTE_SIZE, "The outputted length is correct.");
info("Got flame graph data:\n" + out.toSource() + "\n");
info("Got flame graph data:\n" + JSON.stringify(out) + "\n");
for (let i = 0; i < out.length; i++) {
const found = out[i];

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

@ -26,7 +26,7 @@ function performTest() {
ok(out, "Some data was outputted properly");
is(out.length, PALLETTE_SIZE, "The outputted length is correct.");
info("Got flame graph data:\n" + out.toSource() + "\n");
info("Got flame graph data:\n" + JSON.stringify(out) + "\n");
for (let i = 0; i < out.length; i++) {
const found = out[i];

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

@ -27,7 +27,7 @@ function performTest() {
ok(out, "Some data was outputted properly");
is(out.length, PALLETTE_SIZE, "The outputted length is correct.");
info("Got flame graph data:\n" + out.toSource() + "\n");
info("Got flame graph data:\n" + JSON.stringify(out) + "\n");
for (let i = 0; i < out.length; i++) {
const found = out[i];

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

@ -15,8 +15,8 @@ add_task(function() {
} = require("devtools/shared/performance/recording-utils");
const output = getProfileThreadFromAllocations(TEST_DATA);
equal(
output.toSource(),
EXPECTED_OUTPUT.toSource(),
JSON.stringify(output),
JSON.stringify(EXPECTED_OUTPUT),
"The output is correct."
);
});

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

@ -4,8 +4,6 @@
"use strict";
/* global uneval */
const { CC } = require("chrome");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const { dumpn } = DevToolsUtils;
@ -47,9 +45,9 @@ LocalDebuggerTransport.prototype = {
if (flags.wantLogging) {
// Check 'from' first, as 'echo' packets have both.
if (packet.from) {
dumpn("Packet " + serial + " sent from " + uneval(packet.from));
dumpn("Packet " + serial + " sent from " + JSON.stringify(packet.from));
} else if (packet.to) {
dumpn("Packet " + serial + " sent to " + uneval(packet.to));
dumpn("Packet " + serial + " sent to " + JSON.stringify(packet.to));
}
}
this._deepFreeze(packet);