OLD | NEW |
(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 } |
OLD | NEW |