Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/mixed-content/generic/sanity-checker.js

Issue 2697453005: Import wpt@758b3b4cfa805067f36121333ba031e583d3a62c (Closed)
Patch Set: Add -expected.txt files. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // The SanityChecker is used in debug mode to identify problems with the
2 // structure of the testsuite and to force early test failures.
3 // In release mode it is mocked out to do nothing.
4 function SanityChecker() {}
5
6 SanityChecker.prototype.checkScenario = function(scenario, resourceInvoker) {
7 // Check if scenario is valid.
8 test(function() {
9 var expectedFields = SPEC_JSON["test_expansion_schema"];
10
11 for (var field in expectedFields) {
12 if (field == "expansion")
13 continue
14
15 assert_own_property(scenario, field,
16 "The scenario should contain field '" + field + "'.")
17
18 var expectedFieldList = expectedFields[field];
19 if (!expectedFieldList.hasOwnProperty('length')) {
20 var expectedFieldList = [];
21 for (var key in expectedFields[field]) {
22 expectedFieldList = expectedFieldList.concat(expectedFields[field][key ])
23 }
24 }
25 assert_in_array(scenario[field], expectedFieldList,
26 "Scenario's " + field + " is one of: " +
27 expectedFieldList.join(", ")) + "."
28 }
29
30 // Check if the protocol is matched.
31 assert_equals(scenario["source_scheme"] + ":", location.protocol,
32 "Protocol of the test page should match the scenario.")
33
34 assert_own_property(resourceInvoker, scenario.subresource,
35 "Subresource should be supported");
36
37 }, "[MixedContentTestCase] The test scenario should be valid.");
38 }
39
40 // For easier debugging runs, we can fail a test earlier.
41 SanityChecker.prototype.setFailTimeout = function(test, timeout) {
42 // Due to missing implementations, tests time out, so we fail them early.
43 // TODO(kristijanburnik): Once WPT rolled in:
44 // https://github.com/w3c/testharness.js/pull/127
45 // Refactor to make use of step_timeout.
46 setTimeout(function() {
47 test.step(function() {
48 assert_equals(test.phase, test.phases.COMPLETE,
49 "Expected test to complete.");
50 test.done();
51 })
52 }, timeout || 1000);
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698