Skip to content

Commit 2584d05

Browse files
committed
Remove support for file:// source of the RegressionRunner.html
Even Firefox has now clamped down on local access to other resources due to security concerns in general. Update README to call out that loading via server is required.
1 parent 7113150 commit 2584d05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+17
-384
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ For tests install Node.js and run
6969

7070
## Limitations
7171

72-
- Currently works in Firefox and Chrome only.
73-
- [Same-origin restrictions](https://developer.mozilla.org/en-US/docs/Same_origin_policy_for_JavaScript) apply when sourcing files. All files referenced need to be inside the same directory as the `RegressionRunner.html` or in ones below.
72+
- Needs to be run via a webserver, as `file://` is limited by browsers due to security concerns.
73+
- [Same-origin restrictions](https://developer.mozilla.org/en-US/docs/Same_origin_policy_for_JavaScript) apply when sourcing files.
7474
- Because of the way the HTML is rendered internally certain limitations apply, see [the documentation of the render backend](https://github.com/cburgmer/rasterizeHTML.js/wiki/Limitations).
7575

7676
For more information see the [FAQ](https://github.com/cburgmer/csscritic/wiki/FAQ) and [API](https://github.com/cburgmer/csscritic/wiki/API).

csscritic.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
var cssDependencies = ["src/reporter/niceReporter.css"],
1313
jsDependencies = [
1414
"src/scope.js",
15-
"src/reporter/pageNavigationHandlingFallback.js",
1615
"src/reporter/niceReporter.js",
1716
"src/reporter/urlQueryFilter.js",
18-
"src/reporter/fallbackFilter.js",
1917
"src/jobQueue.js",
2018
"src/browserRenderer.js",
2119
"src/indexedDbStorage.js",

src/init.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ var csscritic = (function () {
99
};
1010
};
1111

12-
var startsWith = function (str, prefix) {
13-
// PhantomJS has no startsWith
14-
return str.substr(0, prefix.length) === prefix;
15-
};
16-
17-
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1005634
18-
var needsFallback = function () {
19-
return startsWith(window.location.href, "file://");
20-
};
21-
2212
var packageVersion = csscriticLib.packageVersion || "dev",
2313
util = csscriticLib.util();
2414

@@ -35,29 +25,23 @@ var csscritic = (function () {
3525
util
3626
),
3727
regression = csscriticLib.regression(browserRenderer, util, imagediff),
38-
queryFilter = csscriticLib.urlQueryFilter(window.location),
39-
fallbackFilter = csscriticLib.fallbackFilter(window.location);
40-
41-
var filter = needsFallback() ? fallbackFilter : queryFilter;
28+
queryFilter = csscriticLib.urlQueryFilter(window.location);
4229

4330
var main = csscriticLib.main(
4431
regression,
4532
reporting,
4633
util,
4734
indexedDbStorage,
48-
filter
35+
queryFilter
4936
);
5037

51-
var pageNavigationHandlingFallback =
52-
csscriticLib.pageNavigationHandlingFallback(window.location),
53-
niceReporter = csscriticLib.niceReporter(
54-
window,
55-
util,
56-
filter,
57-
needsFallback() ? pageNavigationHandlingFallback : undefined,
58-
rasterizeHTML,
59-
packageVersion
60-
);
38+
var niceReporter = csscriticLib.niceReporter(
39+
window,
40+
util,
41+
queryFilter,
42+
rasterizeHTML,
43+
packageVersion
44+
);
6145

6246
var self = {};
6347

src/reporter/fallbackFilter.js

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/reporter/niceReporter.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ csscriticLib.niceReporter = function (
22
window,
33
util,
44
selectionFilter,
5-
pageNavigationHandlingFallback,
65
rasterizeHTML,
76
packageVersion
87
) {
@@ -244,10 +243,6 @@ csscriticLib.niceReporter = function (
244243
)
245244
);
246245

247-
if (pageNavigationHandlingFallback) {
248-
pageNavigationHandlingFallback.install(entry.querySelector("a"));
249-
}
250-
251246
toc.appendChild(entry);
252247
};
253248

@@ -722,10 +717,6 @@ csscriticLib.niceReporter = function (
722717
tick.classList.add(progressBarPendingClassName);
723718
progressBar.appendChild(tick);
724719

725-
if (pageNavigationHandlingFallback) {
726-
pageNavigationHandlingFallback.install(tick.querySelector("a"));
727-
}
728-
729720
return tick;
730721
};
731722

src/reporter/pageNavigationHandlingFallback.js

Lines changed: 0 additions & 63 deletions
This file was deleted.

test/SpecRunner.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<script src="specs/browserRendererSpec.js"></script>
3030
<script src="specs/reporter/niceReporterSpec.js"></script>
3131
<script src="specs/reporter/urlQueryFilterSpec.js"></script>
32-
<script src="specs/reporter/fallbackFilterSpec.js"></script>
3332
<script src="specs/integrationSpec.js"></script>
3433
<script src="specs/workaroundSpec.js"></script>
3534
</head>

test/smokeTest.js

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ var assertMatches = function (value, regex, name) {
123123
}
124124
};
125125

126-
const runTestAgainst = async (browser, pageUrl, options) => {
127-
const withNavigationFallback = options.withNavigationFallback;
128-
126+
const runTestAgainst = async (browser, pageUrl) => {
129127
console.log("Running test against " + pageUrl);
130128

131129
const page = await loadPage(browser, pageUrl);
@@ -142,11 +140,7 @@ const runTestAgainst = async (browser, pageUrl, options) => {
142140
let scrollY = await page.evaluate("window.scrollY");
143141
assertNotEquals(scrollY, 0, "scrollY");
144142

145-
if (withNavigationFallback) {
146-
assertEquals(page.url(), pageUrl, "page url");
147-
} else {
148-
assertMatches(page.url(), /#/, "page url");
149-
}
143+
assertMatches(page.url(), /#/, "page url");
150144

151145
// 3
152146
console.log("Jumping back");
@@ -165,11 +159,7 @@ const runTestAgainst = async (browser, pageUrl, options) => {
165159
let comparisonCount = await page.evaluate(getComparisonCount);
166160

167161
assertEquals(comparisonCount, 1, "number of comparisons");
168-
if (withNavigationFallback) {
169-
assertEquals(page.url(), pageUrl, "page url");
170-
} else {
171-
assertMatches(page.url(), /\?filter/, "page url");
172-
}
162+
assertMatches(page.url(), /\?filter/, "page url");
173163

174164
// 5
175165
console.log('Clicking "Run all"');
@@ -180,11 +170,7 @@ const runTestAgainst = async (browser, pageUrl, options) => {
180170
comparisonCount = await page.evaluate(getComparisonCount);
181171

182172
assertEquals(comparisonCount, 2, "number of comparisons");
183-
if (withNavigationFallback) {
184-
assertEquals(page.url(), pageUrl, "page url");
185-
} else {
186-
assertMatches(page.url(), /\?$/, "page url");
187-
}
173+
assertMatches(page.url(), /\?$/, "page url");
188174
};
189175

190176
(async () => {
@@ -195,19 +181,10 @@ const runTestAgainst = async (browser, pageUrl, options) => {
195181
headless: true,
196182
});
197183

198-
await runTestAgainst(
199-
browser,
200-
"file://" + path.resolve(csscriticLoadingPage),
201-
{
202-
withNavigationFallback: true,
203-
}
204-
);
205-
206184
startWebserver(webserverPort);
207185
await runTestAgainst(
208186
browser,
209-
"http://localhost:" + webserverPort + "/" + csscriticLoadingPage,
210-
{ withNavigationFallback: false }
187+
"http://localhost:" + webserverPort + "/" + csscriticLoadingPage
211188
);
212189

213190
browser.close();

test/specs/integrationSpec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ describe("Integration", function () {
3434
window,
3535
util,
3636
urlQueryFilter,
37-
csscriticLib.pageNavigationHandlingFallback(),
3837
rasterizeHTML,
3938
"dev"
4039
);

0 commit comments

Comments
 (0)