Skip to content

Commit dc2b49c

Browse files
committed
Remove workarounds for PhantomJS shortcommings now that we moved on
1 parent d60b0fe commit dc2b49c

File tree

13 files changed

+135
-182
lines changed

13 files changed

+135
-182
lines changed

.jshintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
src/cli/phantomjsBind.js
21
test/ui/src/**/*.js
32
test/fixtures/*.js
43
packageVersion.js

src/.jshintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"inlineresources": true,
66
"imagediff": true,
77
"ayepromise": true,
8-
"phantom": true,
98
"indexedDB": true,
109
"console": true,
1110
"require": true,

test/.jshintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../.jshintrc",
33
"globalstrict": true,
44
"globals": {
5-
"phantom": true,
65
"require": true,
76
"localserver": true,
87
"console": true,

test/helpers.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22

3-
var isWebkit = navigator.userAgent.indexOf("WebKit") >= 0,
4-
isPhantom = navigator.userAgent.indexOf("PhantomJS") >= 0;
3+
var isWebkit = navigator.userAgent.indexOf("WebKit") >= 0;
54

65
window.ifNotInWebkitIt = function (text, functionHandle) {
76
if (!isWebkit) {
@@ -12,15 +11,6 @@ window.ifNotInWebkitIt = function (text, functionHandle) {
1211
}
1312
};
1413

15-
window.ifNotInPhantomIt = function (text, functionHandle) {
16-
if (!isPhantom) {
17-
return it(text, functionHandle);
18-
} else {
19-
console.warn('Warning: "' + text + '" is disabled on this platform');
20-
return xit(text, functionHandle);
21-
}
22-
};
23-
2414
window.imagediffForJasmine2 = {
2515
// work around imagediff only supporting jasmine 1.x
2616
toImageDiffEqual: function () {

test/specs/.jshintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
"imagediffForJasmine2": true,
1818
"csscriticLib": true,
1919
"ifNotInWebkitIt": true,
20-
"ifNotInPhantomIt": true,
21-
"isPhantom": true,
2220
"csscriticTestPath": true,
2321
"testHelper": true,
2422
"loadStoragePluginSpecs": true,

test/specs/browserRendererSpec.js

Lines changed: 94 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("Browser renderer", function () {
1818
);
1919
});
2020

21-
ifNotInPhantomIt("should draw an image directly", function (done) {
21+
it("should draw an image directly", function (done) {
2222
spyOn(rasterizeHTML, "drawHTML");
2323

2424
browserRenderer
@@ -64,91 +64,82 @@ describe("Browser renderer", function () {
6464
);
6565
};
6666

67-
ifNotInPhantomIt(
68-
"should draw the html page if url is not an image, disable caching and execute JavaScript",
69-
function (done) {
70-
var theUrl = "the url",
71-
theHtml = "some html";
67+
it("should draw the html page if url is not an image, disable caching and execute JavaScript", function (done) {
68+
var theUrl = "the url",
69+
theHtml = "some html";
7270

73-
setUpRasterizeHtmlToBeSuccessful();
71+
setUpRasterizeHtmlToBeSuccessful();
72+
73+
spyOn(util, "loadAsBlob").and.callFake(function () {
74+
return testHelper.successfulPromise(
75+
new Blob([theHtml], { type: "text/html" })
76+
);
77+
});
7478

75-
spyOn(util, "loadAsBlob").and.callFake(function () {
76-
return testHelper.successfulPromise(
77-
new Blob([theHtml], { type: "text/html" })
79+
browserRenderer
80+
.render({
81+
url: theUrl,
82+
width: 42,
83+
height: 7,
84+
})
85+
.then(function (result) {
86+
expect(result.image).toBe("the image");
87+
expect(rasterizeHTML.drawHTML).toHaveBeenCalledWith(
88+
theHtml,
89+
{
90+
cache: "repeated",
91+
cacheBucket: jasmine.any(Object),
92+
width: 42,
93+
height: 7,
94+
executeJs: true,
95+
executeJsTimeout: 50,
96+
baseUrl: theUrl,
97+
}
7898
);
99+
100+
done();
79101
});
102+
});
80103

81-
browserRenderer
82-
.render({
83-
url: theUrl,
84-
width: 42,
85-
height: 7,
86-
})
87-
.then(function (result) {
88-
expect(result.image).toBe("the image");
89-
expect(rasterizeHTML.drawHTML).toHaveBeenCalledWith(
90-
theHtml,
91-
{
92-
cache: "repeated",
93-
cacheBucket: jasmine.any(Object),
94-
width: 42,
95-
height: 7,
96-
executeJs: true,
97-
executeJsTimeout: 50,
98-
baseUrl: theUrl,
99-
}
100-
);
101-
102-
done();
103-
});
104-
}
105-
);
104+
it("should call the error handler if a page could not be rendered", function (done) {
105+
setUpRasterizeHtmlToFail();
106106

107-
ifNotInPhantomIt(
108-
"should call the error handler if a page could not be rendered",
109-
function (done) {
110-
setUpRasterizeHtmlToFail();
111-
112-
browserRenderer
113-
.render({
114-
url: testHelper.fixture("pageUnderTest.html"),
115-
width: 42,
116-
height: 7,
117-
})
118-
.then(null, done);
119-
}
120-
);
107+
browserRenderer
108+
.render({
109+
url: testHelper.fixture("pageUnderTest.html"),
110+
width: 42,
111+
height: 7,
112+
})
113+
.then(null, done);
114+
});
121115

122-
ifNotInPhantomIt(
123-
"should report errors from rendering",
124-
function (done) {
125-
browserRenderer
126-
.render({
127-
url: testHelper.fixture("brokenPage.html"),
128-
width: 42,
129-
height: 7,
130-
})
131-
.then(function (result) {
132-
expect(result.errors).not.toBeNull();
133-
expect(result.errors.length).toBe(3);
134-
result.errors.sort();
135-
expect(result.errors).toEqual([
136-
"Unable to load background-image " +
137-
testHelper.fixture(
138-
"background_image_does_not_exist.jpg"
139-
),
140-
"Unable to load image " +
141-
testHelper.fixture("image_does_not_exist.png"),
142-
"Unable to load stylesheet " +
143-
testHelper.fixture("css_does_not_exist.css"),
144-
]);
145-
146-
done();
147-
});
148-
}
149-
);
116+
it("should report errors from rendering", function (done) {
117+
browserRenderer
118+
.render({
119+
url: testHelper.fixture("brokenPage.html"),
120+
width: 42,
121+
height: 7,
122+
})
123+
.then(function (result) {
124+
expect(result.errors).not.toBeNull();
125+
expect(result.errors.length).toBe(3);
126+
result.errors.sort();
127+
expect(result.errors).toEqual([
128+
"Unable to load background-image " +
129+
testHelper.fixture(
130+
"background_image_does_not_exist.jpg"
131+
),
132+
"Unable to load image " +
133+
testHelper.fixture("image_does_not_exist.png"),
134+
"Unable to load stylesheet " +
135+
testHelper.fixture("css_does_not_exist.css"),
136+
]);
137+
138+
done();
139+
});
140+
});
150141

151-
ifNotInPhantomIt("should render with hover effect", function (done) {
142+
it("should render with hover effect", function (done) {
152143
setUpRasterizeHtmlToBeSuccessful();
153144

154145
browserRenderer
@@ -167,35 +158,32 @@ describe("Browser renderer", function () {
167158
});
168159
});
169160

170-
ifNotInPhantomIt(
171-
"should render with active/focus/target effect",
172-
function (done) {
173-
setUpRasterizeHtmlToBeSuccessful();
174-
175-
browserRenderer
176-
.render({
177-
url: testHelper.fixture("pageUnderTest.html"),
178-
width: 42,
179-
height: 7,
180-
active: ".someSelector",
181-
focus: "#other",
182-
target: "img",
183-
})
184-
.then(function () {
185-
expect(rasterizeHTML.drawHTML).toHaveBeenCalledWith(
186-
jasmine.any(String),
187-
jasmine.objectContaining({
188-
active: ".someSelector",
189-
focus: "#other",
190-
target: "img",
191-
})
192-
);
193-
done();
194-
});
195-
}
196-
);
161+
it("should render with active/focus/target effect", function (done) {
162+
setUpRasterizeHtmlToBeSuccessful();
163+
164+
browserRenderer
165+
.render({
166+
url: testHelper.fixture("pageUnderTest.html"),
167+
width: 42,
168+
height: 7,
169+
active: ".someSelector",
170+
focus: "#other",
171+
target: "img",
172+
})
173+
.then(function () {
174+
expect(rasterizeHTML.drawHTML).toHaveBeenCalledWith(
175+
jasmine.any(String),
176+
jasmine.objectContaining({
177+
active: ".someSelector",
178+
focus: "#other",
179+
target: "img",
180+
})
181+
);
182+
done();
183+
});
184+
});
197185

198-
ifNotInPhantomIt("should properly render Unicode", function (done) {
186+
it("should properly render Unicode", function (done) {
199187
setUpRasterizeHtmlToBeSuccessful();
200188

201189
browserRenderer

test/specs/indexedDbStorageSpec.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,14 @@ describe("IndexedDB storage", function () {
8585
};
8686
});
8787

88-
if (!isPhantom) {
89-
loadStoragePluginSpecs(
90-
constructStorage,
91-
readStoredReferenceImage,
92-
storeReferenceImage
93-
);
94-
}
88+
loadStoragePluginSpecs(
89+
constructStorage,
90+
readStoredReferenceImage,
91+
storeReferenceImage
92+
);
9593
});
9694

97-
ifNotInPhantomIt("should initally create a database", function (done) {
95+
it("should initally create a database", function (done) {
9896
var storage = constructStorage(util);
9997
spyOn(util, "getDataURIForImage").and.returnValue("uri");
10098
storage

test/specs/integrationSpec.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe("Integration", function () {
143143
request.onsuccess = done;
144144
});
145145

146-
ifNotInPhantomIt("should complete in any browser", function (done) {
146+
it("should complete in any browser", function (done) {
147147
var testPageUrl = testHelper.fixture("pageUnderTest.html");
148148

149149
csscritic.addReporter(csscritic.NiceReporter());
@@ -158,29 +158,26 @@ describe("Integration", function () {
158158
});
159159
});
160160

161-
ifNotInPhantomIt(
162-
"should compare an image with its reference and return true if similar",
163-
function (done) {
164-
var testImageUrl = testHelper.fixture("redWithLetter.png");
161+
it("should compare an image with its reference and return true if similar", function (done) {
162+
var testImageUrl = testHelper.fixture("redWithLetter.png");
165163

166-
util.getImageForUrl(testImageUrl)
167-
.then(function (image) {
168-
var theReferenceImageUri = util.getDataURIForImage(image);
164+
util.getImageForUrl(testImageUrl)
165+
.then(function (image) {
166+
var theReferenceImageUri = util.getDataURIForImage(image);
169167

170-
return storeReferenceImage(testImageUrl, {
171-
imageUri: theReferenceImageUri,
172-
});
173-
})
174-
.then(function () {
175-
csscritic.add(testImageUrl);
176-
csscritic.execute().then(function (passed) {
177-
expect(passed).toBe(true);
168+
return storeReferenceImage(testImageUrl, {
169+
imageUri: theReferenceImageUri,
170+
});
171+
})
172+
.then(function () {
173+
csscritic.add(testImageUrl);
174+
csscritic.execute().then(function (passed) {
175+
expect(passed).toBe(true);
178176

179-
done();
180-
});
177+
done();
181178
});
182-
}
183-
);
179+
});
180+
});
184181

185182
ifNotInWebkitIt(
186183
"should compare a page with its reference image and return true if similar",

test/specs/reporter/niceReporterSpec.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -829,21 +829,18 @@ describe("Nice reporter", function () {
829829
});
830830
});
831831

832-
ifNotInPhantomIt(
833-
"should not show a warning if the browser is supported",
834-
function (done) {
835-
reporter.reportSelectedComparison(aPassedTest());
836-
837-
// Wait for the opposite until timeout
838-
testHelper
839-
.waitsFor(function () {
840-
return $(".browserWarning").length > 0;
841-
})
842-
.then(null, function () {
843-
expect($(".browserWarning")).not.toExist();
844-
done();
845-
});
846-
}
847-
);
832+
it("should not show a warning if the browser is supported", function (done) {
833+
reporter.reportSelectedComparison(aPassedTest());
834+
835+
// Wait for the opposite until timeout
836+
testHelper
837+
.waitsFor(function () {
838+
return $(".browserWarning").length > 0;
839+
})
840+
.then(null, function () {
841+
expect($(".browserWarning")).not.toExist();
842+
done();
843+
});
844+
});
848845
});
849846
});

0 commit comments

Comments
 (0)