Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ===/!== in assert_true/false #25086

Merged
merged 7 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<script>
async_test(function(t) {
assert_true(typeof crypto.subtle !== 'undefined');
assert_not_equals(typeof crypto.subtle, 'undefined');
t.done();
}, "Secure context window has access to crypto.subtle");
async_test(function(t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<script>
test(() => {
assert_true(typeof NodeFilter === "function");
assert_equals(typeof NodeFilter, "function");
}, "Must be a function according to typeof");

test(() => {
Expand Down
2 changes: 1 addition & 1 deletion annotation-protocol/server/server-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
return thePrefRequest
.then(function(res) {
var h = res.xhr.getResponseHeader('Prefer');
assert_true(h === null, "Reponse contains the `Prefer` header when it SHOULD NOT");
assert_equals(h, null, "Reponse contains the `Prefer` header when it SHOULD NOT");
});
}, 'SHOULD NOT [receive] the Prefer header when requesting the page');

Expand Down
4 changes: 2 additions & 2 deletions compat/webkit-text-fill-color-currentColor.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
var color = cs.getPropertyValue('color');
var webkiTextFillColor = cs.getPropertyValue('-webkit-text-fill-color');

assert_true(textDecorationColor == color);
assert_true(textDecorationColor != webkiTextFillColor);
assert_equals(textDecorationColor, color);
assert_not_equals(textDecorationColor, webkiTextFillColor);
});

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Uh, this assert isn't doing anything, right? 😆 (same for other content-security-policy test changes below)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goes all the way back to the original Blink import, too!

expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_log.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_log.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_log.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<!-- Programmatically converted from a WebKit Reftest, please forgive resulting idiosyncracies.-->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'nonce-abc' 'sha256-k7iO9DPkNQ7PcwPP+8XyYuRiCJ0p76Ofveol9g3mFNs=' 'sha256-EgE/bwVJ+ZLL9F5hNjDqD4C7nlFFrdDaKeNIJ2cUem4='; connect-src 'self';">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'nonce-abc' 'sha256-3iveTSiUbmzN7COYvdDwyaXXzJ3SrjKlTaOvQ/GdRpo=' 'sha256-EgE/bwVJ+ZLL9F5hNjDqD4C7nlFFrdDaKeNIJ2cUem4='; connect-src 'self';">
<title>scripthash-basic-blocked</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand All @@ -26,7 +26,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<!-- Programmatically converted from a WebKit Reftest, please forgive resulting idiosyncracies.-->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'sha256-k7iO9DPkNQ7PcwPP+8XyYuRiCJ0p76Ofveol9g3mFNs=' 'sha256-EgE/bwVJ+ZLL9F5hNjDqD4C7nlFFrdDaKeNIJ2cUem4=' 'sha256-lxHfHAe5I15v8qaArcZ5WiKmLU4CjV+3tJeQUqSIWBk='; connect-src 'self';">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'sha256-3iveTSiUbmzN7COYvdDwyaXXzJ3SrjKlTaOvQ/GdRpo=' 'sha256-EgE/bwVJ+ZLL9F5hNjDqD4C7nlFFrdDaKeNIJ2cUem4=' 'sha256-lxHfHAe5I15v8qaArcZ5WiKmLU4CjV+3tJeQUqSIWBk='; connect-src 'self';">

<title>scripthash-ignore-unsafeinline</title>
<script src="/resources/testharness.js"></script>
Expand All @@ -22,7 +22,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
function make_assert(contentId) {
var contentEl = document.getElementById(contentId);
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px")
assert_equals(marginLeftVal, "2px")
}
t.step(function() {
make_assert("content1");
Expand Down
4 changes: 2 additions & 2 deletions content-security-policy/style-src/style-src-hash-blocked.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
function make_assert(contentId, assertTrue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: rename assertTrue to assertEqual

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep this PR relatively minimal. From an API POV, it makes as much sense as it did before.

var contentEl = document.getElementById(contentId);
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
if (assertTrue) assert_true(marginLeftVal == "2px");
else assert_false(marginLeftVal == "2px");
if (assertTrue) assert_equals(marginLeftVal, "2px");
else assert_not_equals(marginLeftVal, "2px");
}

t1.step(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
function make_assert(contentId) {
var contentEl = document.getElementById(contentId);
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px")
assert_equals(marginLeftVal, "2px")
}
t.step(function() {
make_assert("content1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px")
assert_not_equals(marginLeftVal, "2px")
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
onload = t.step_func_done(function(e) {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px");
assert_equals(marginLeftVal, "2px");
var marginRightVal = getComputedStyle(contentEl).getPropertyValue('margin-right');
assert_true(marginRightVal == "2px");
assert_equals(marginRightVal, "2px");
});
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
// this is why in this test we check both to make sure neither way worked

var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
var marginRightVal = getComputedStyle(contentEl).getPropertyValue('margin-right');
assert_false(marginRightVal == "2px");
assert_not_equals(marginRightVal, "2px");
});
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
onload = t.step_func_done(function(e) {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px");
assert_equals(marginLeftVal, "2px");
});

head.appendChild(link);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
onload = t.step_func_done(function(e) {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
});

head.appendChild(link);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px");
assert_equals(marginLeftVal, "2px");
t.done();
}, "Inline style should not be applied");
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
onload = t.step_func_done(function(e) {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px");
assert_equals(marginLeftVal, "2px");
});
</script>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
onload = t.step_func_done(function(e) {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
});
</script>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px");
assert_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script>
function verifyStep1() {
var marginLeft = getComputedStyle(document.querySelector("#content")).getPropertyValue('margin-left');
assert_false(marginLeft == '2px', "Content still does not have a 2px margin-left after initial style.");
assert_not_equals(marginLeft, '2px', "Content still does not have a 2px margin-left after initial style.");
}

function setupStep2() {
Expand All @@ -39,7 +39,7 @@
}
function verifyStep2() {
var marginLeft = getComputedStyle(document.querySelector("#content")).getPropertyValue('margin-left');
assert_false(marginLeft == '2px', "Content still does not have a 2px margin-left after inserted style.");
assert_not_equals(marginLeft, '2px', "Content still does not have a 2px margin-left after inserted style.");
}

function setupStep3() {
Expand All @@ -48,7 +48,7 @@
}
function verifyStep3() {
var marginLeft = getComputedStyle(document.querySelector("#content")).getPropertyValue('margin-left');
assert_false(marginLeft == '2px', "Content still does not have a 2px margin-left after changing style.");
assert_not_equals(marginLeft, '2px', "Content still does not have a 2px margin-left after changing style.");
test.done();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px");
assert_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_true(marginLeftVal == "2px");
assert_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
t.step(function() {
var contentEl = document.getElementById("content");
var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
assert_false(marginLeftVal == "2px");
assert_not_equals(marginLeftVal, "2px");
t.done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
for (var i = 0; i < expected_alerts.length; i++) {
if (expected_alerts[i] == msg) {
assert_true(expected_alerts[i] == msg);
assert_equals(expected_alerts[i], msg);
expected_alerts.splice(i, 1);
if (expected_alerts.length == 0) {
t_alert.done();
Expand Down
Loading