Skip to content

Commit 772925b

Browse files
committed
Enable all unit tests on Chrome and Webkit, as they have since caught up
1 parent c075b31 commit 772925b

File tree

4 files changed

+86
-116
lines changed

4 files changed

+86
-116
lines changed

test/helpers.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
"use strict";
22

3-
var isWebkit = navigator.userAgent.indexOf("WebKit") >= 0;
4-
5-
window.ifNotInWebkitIt = function (text, functionHandle) {
6-
if (!isWebkit) {
7-
return it(text, functionHandle);
8-
} else {
9-
console.warn('Warning: "' + text + '" is disabled on this platform');
10-
return xit(text, functionHandle);
11-
}
12-
};
13-
143
window.imagediffForJasmine2 = {
154
// work around imagediff only supporting jasmine 1.x
165
toImageDiffEqual: function () {

test/specs/.jshintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"imagediff": true,
1818
"imagediffForJasmine2": true,
1919
"csscriticLib": true,
20-
"ifNotInWebkitIt": true,
2120
"csscriticTestPath": true,
2221
"testHelper": true,
2322
"loadStoragePluginSpecs": true,

test/specs/integrationSpec.js

Lines changed: 74 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,20 @@ describe("Integration", function () {
179179
});
180180
});
181181

182-
ifNotInWebkitIt(
183-
"should compare a page with its reference image and return true if similar",
184-
function (done) {
185-
var testPageUrl = testHelper.fixture("pageUnderTest.html");
186-
187-
storeReferenceImage(testPageUrl, {
188-
imageUri: theReferenceImageUri,
189-
}).then(function () {
190-
csscritic.add(testPageUrl);
191-
csscritic.execute().then(function (passed) {
192-
expect(passed).toBe(true);
182+
it("should compare a page with its reference image and return true if similar", function (done) {
183+
var testPageUrl = testHelper.fixture("pageUnderTest.html");
193184

194-
done();
195-
});
185+
storeReferenceImage(testPageUrl, {
186+
imageUri: theReferenceImageUri,
187+
}).then(function () {
188+
csscritic.add(testPageUrl);
189+
csscritic.execute().then(function (passed) {
190+
expect(passed).toBe(true);
191+
192+
done();
196193
});
197-
}
198-
);
194+
});
195+
});
199196

200197
// Disabled, as we cannot compare the serialized image across browsers. Same image has different serialisations
201198
xit("should store a reference when a result is accepted", function (done) {
@@ -231,84 +228,72 @@ describe("Integration", function () {
231228
});
232229
});
233230

234-
ifNotInWebkitIt(
235-
"should properly report a failing comparison",
236-
function (done) {
237-
var testPageUrl = testHelper.fixture("brokenPage.html");
238-
239-
storeReferenceImage(testPageUrl, {
240-
imageUri: theReferenceImageUri,
241-
}).then(function () {
242-
csscritic.addReporter(csscritic.NiceReporter());
243-
csscritic.add(testPageUrl);
244-
csscritic.execute().then(function () {
245-
expect(
246-
$(".cssCriticNiceReporter .failed.comparison")
247-
).toExist();
248-
expect(
249-
$(
250-
".cssCriticNiceReporter .comparison .titleLink"
251-
).text()
252-
).toEqual(testPageUrl);
253-
expect(
254-
$(".cssCriticNiceReporter .comparison .errorText")
255-
).toExist();
256-
expect(
257-
$(
258-
".cssCriticNiceReporter .comparison .errorText"
259-
).text()
260-
).toContain("background_image_does_not_exist.jpg");
261-
expect(
262-
$(
263-
".cssCriticNiceReporter .comparison .referenceImageContainer img"
264-
)
265-
).toExist();
266-
expect(
267-
$(
268-
".cssCriticNiceReporter .comparison .referenceImageContainer canvas"
269-
)
270-
).toExist();
271-
expect(
272-
$(
273-
".cssCriticNiceReporter .comparison .pageImageContainer canvas"
274-
)
275-
).toExist();
276-
277-
done();
278-
});
279-
});
280-
}
281-
);
282-
283-
ifNotInWebkitIt(
284-
"should correctly re-render a page overflowing the given viewport",
285-
function (done) {
286-
var testPageUrl = testHelper.fixture("overflowingPage.html"),
287-
reporter = jasmine.createSpyObj("Reporter", [
288-
"reportComparison",
289-
]),
290-
result;
291-
292-
csscritic.addReporter(reporter);
293-
294-
// Accept first rendering
295-
reporter.reportComparison.and.callFake(function (theResult) {
296-
result = theResult;
297-
});
231+
it("should properly report a failing comparison", function (done) {
232+
var testPageUrl = testHelper.fixture("brokenPage.html");
298233

234+
storeReferenceImage(testPageUrl, {
235+
imageUri: theReferenceImageUri,
236+
}).then(function () {
237+
csscritic.addReporter(csscritic.NiceReporter());
299238
csscritic.add(testPageUrl);
300239
csscritic.execute().then(function () {
301-
var anothercsscritic = aCssCriticInstance();
302-
result.acceptPage();
240+
expect(
241+
$(".cssCriticNiceReporter .failed.comparison")
242+
).toExist();
243+
expect(
244+
$(".cssCriticNiceReporter .comparison .titleLink").text()
245+
).toEqual(testPageUrl);
246+
expect(
247+
$(".cssCriticNiceReporter .comparison .errorText")
248+
).toExist();
249+
expect(
250+
$(".cssCriticNiceReporter .comparison .errorText").text()
251+
).toContain("background_image_does_not_exist.jpg");
252+
expect(
253+
$(
254+
".cssCriticNiceReporter .comparison .referenceImageContainer img"
255+
)
256+
).toExist();
257+
expect(
258+
$(
259+
".cssCriticNiceReporter .comparison .referenceImageContainer canvas"
260+
)
261+
).toExist();
262+
expect(
263+
$(
264+
".cssCriticNiceReporter .comparison .pageImageContainer canvas"
265+
)
266+
).toExist();
267+
268+
done();
269+
});
270+
});
271+
});
303272

304-
anothercsscritic.addReporter(reporter);
305-
anothercsscritic.add(testPageUrl);
306-
anothercsscritic.execute().then(function (status) {
307-
expect(status).toBe(true);
273+
it("should correctly re-render a page overflowing the given viewport", function (done) {
274+
var testPageUrl = testHelper.fixture("overflowingPage.html"),
275+
reporter = jasmine.createSpyObj("Reporter", ["reportComparison"]),
276+
result;
308277

309-
done();
310-
});
278+
csscritic.addReporter(reporter);
279+
280+
// Accept first rendering
281+
reporter.reportComparison.and.callFake(function (theResult) {
282+
result = theResult;
283+
});
284+
285+
csscritic.add(testPageUrl);
286+
csscritic.execute().then(function () {
287+
var anothercsscritic = aCssCriticInstance();
288+
result.acceptPage();
289+
290+
anothercsscritic.addReporter(reporter);
291+
anothercsscritic.add(testPageUrl);
292+
anothercsscritic.execute().then(function (status) {
293+
expect(status).toBe(true);
294+
295+
done();
311296
});
312-
}
313-
);
297+
});
298+
});
314299
});

test/specs/workaroundSpec.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,18 @@ describe("Workarounds", function () {
3838
localStorage.clear();
3939
});
4040

41-
ifNotInWebkitIt(
42-
"should work around transparency making pages non-comparable",
43-
function (done) {
44-
// Create reference image first
45-
reporting.addReporter(aOnceAutoAcceptingReporter());
41+
it("should work around transparency making pages non-comparable", function (done) {
42+
// Create reference image first
43+
reporting.addReporter(aOnceAutoAcceptingReporter());
44+
main.add({ url: testHelper.fixture("transparencyBug.html") });
45+
main.execute().then(function () {
46+
// Now test against the reference
4647
main.add({ url: testHelper.fixture("transparencyBug.html") });
47-
main.execute().then(function () {
48-
// Now test against the reference
49-
main.add({ url: testHelper.fixture("transparencyBug.html") });
50-
main.execute().then(function (passed) {
51-
expect(passed).toBe(true);
52-
53-
done();
54-
});
48+
main.execute().then(function (passed) {
49+
expect(passed).toBe(true);
50+
51+
done();
5552
});
56-
}
57-
);
53+
});
54+
});
5855
});

0 commit comments

Comments
 (0)