Skip to content

Commit

Permalink
attempt to fix to upstream tests - JH
Browse files Browse the repository at this point in the history
  • Loading branch information
hoekz-wwt committed Jul 23, 2022
1 parent 728e553 commit 7b66fb7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/jsdom/living/helpers/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ function hexToRGBA(color) {
}

function computedColor(color) {
if (!color) {
return "";
}

if (/^#[0-9A-Fa-f]{6}$/i.test(color) || /^#[0-9A-Fa-f]{3}$/i.test(color)) {
return hexToRGB(color.slice(1));
}
Expand Down
2 changes: 1 addition & 1 deletion test/api/from-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("API: JSDOM.fromFile()", { skipIfBrowser: true }, () => {
dom.window.onload = resolve;
});

assert.strictEqual(dom.window.getComputedStyle(dom.window.document.querySelector("p")).color, "red");
assert.strictEqual(dom.window.getComputedStyle(dom.window.document.querySelector("p")).color, "rgb(255, 0, 0)");
});

describe("contentType option defaulting", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe("API: resource loading configuration", { skipIfBrowser: true }, () => {

// I think this should actually be "rgb(0, 0, 255)" per spec. It's fine to change the test in the future if we
// fix that.
assert.strictEqual(dom.window.getComputedStyle(dom.window.document.body).color, "blue");
assert.strictEqual(dom.window.getComputedStyle(dom.window.document.body).color, "rgb(0, 0, 255)");
});

it("should download and run scripts, if runScripts: \"dangerously\" is also set", { slow: 500 }, async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/to-port-to-wpts/level2/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe("level2/style", { skipIfBrowser: true }, () => {
return delay(100); // HACK: style imports haven"t been processed yet, different bug
}).then(() => {
var style = window.getComputedStyle(window.document.body);
assert.equal(style.color, "red", "computed color of body is red");
assert.equal(style.color, "rgb(25, 0, 0)", "computed color of body is red");
s.close();
});
});
Expand Down Expand Up @@ -242,7 +242,7 @@ describe("level2/style", { skipIfBrowser: true }, () => {
window.onload = () => {
var div = window.document.getElementsByTagName("div")[0];
var style = window.getComputedStyle(div);
assert.equal(style.color, "red", "computed color of div is red");
assert.equal(style.color, "rgb(255, 0, 0)", "computed color of div is red");
s.close();
resolve();
};
Expand Down Expand Up @@ -270,7 +270,7 @@ describe("level2/style", { skipIfBrowser: true }, () => {
@media print { .citation { color: red; } }</style></head>
<body><p class=\"citation\">Hello</p></body></html>`);
var style = window.getComputedStyle(window.document.querySelector(".citation"));
assert.equal(style.color, "blue", "computed color of p is blue");
assert.equal(style.color, "rgb(0, 0, 255)", "computed color of p is blue");
});

specify("getComputedStyleWithKeyframeRules", () => {
Expand Down

0 comments on commit 7b66fb7

Please sign in to comment.