Skip to content

Commit 1950bc8

Browse files
committed
Stabilize unit test in Firefox. Test image wasn't always loaded in time
1 parent 631bae8 commit 1950bc8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/specs/Svg2ImageSpec.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ describe("Svg to Image", function () {
3030
'</svg>'
3131
);
3232

33-
svg2image.renderSvg(twoColorSvg, null).then(function (image) {
34-
// This fails in Chrome & Safari, possibly due to a bug with same origin policy stuff
35-
try {
36-
expect(image).toImageDiffEqual(referenceImg);
37-
} catch (err) {
38-
expect(err.message).toBeNull();
39-
}
33+
referenceImg.onload = function () {
34+
svg2image.renderSvg(twoColorSvg, null).then(function (image) {
35+
// This fails in Chrome & Safari, possibly due to a bug with same origin policy stuff
36+
try {
37+
expect(image).toImageDiffEqual(referenceImg);
38+
} catch (err) {
39+
expect(err.message).toBeNull();
40+
}
4041

41-
done();
42-
});
42+
done();
43+
});
44+
};
4345
});
4446

4547
ifNotInWebkitIt("should render an SVG with inline image", function (done) {

0 commit comments

Comments
 (0)