diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/mixed-content/generic/sanity-checker.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/mixed-content/generic/sanity-checker.js')
-rw-r--r-- | testing/web-platform/tests/mixed-content/generic/sanity-checker.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mixed-content/generic/sanity-checker.js b/testing/web-platform/tests/mixed-content/generic/sanity-checker.js new file mode 100644 index 000000000..55a103adf --- /dev/null +++ b/testing/web-platform/tests/mixed-content/generic/sanity-checker.js @@ -0,0 +1,53 @@ +// The SanityChecker is used in debug mode to identify problems with the +// structure of the testsuite and to force early test failures. +// In release mode it is mocked out to do nothing. +function SanityChecker() {} + +SanityChecker.prototype.checkScenario = function(scenario, resourceInvoker) { + // Check if scenario is valid. + test(function() { + var expectedFields = SPEC_JSON["test_expansion_schema"]; + + for (var field in expectedFields) { + if (field == "expansion") + continue + + assert_own_property(scenario, field, + "The scenario should contain field '" + field + "'.") + + var expectedFieldList = expectedFields[field]; + if (!expectedFieldList.hasOwnProperty('length')) { + var expectedFieldList = []; + for (var key in expectedFields[field]) { + expectedFieldList = expectedFieldList.concat(expectedFields[field][key]) + } + } + assert_in_array(scenario[field], expectedFieldList, + "Scenario's " + field + " is one of: " + + expectedFieldList.join(", ")) + "." + } + + // Check if the protocol is matched. + assert_equals(scenario["source_scheme"] + ":", location.protocol, + "Protocol of the test page should match the scenario.") + + assert_own_property(resourceInvoker, scenario.subresource, + "Subresource should be supported"); + + }, "[MixedContentTestCase] The test scenario should be valid."); +} + +// For easier debugging runs, we can fail a test earlier. +SanityChecker.prototype.setFailTimeout = function(test, timeout) { + // Due to missing implementations, tests time out, so we fail them early. + // TODO(kristijanburnik): Once WPT rolled in: + // https://github.com/w3c/testharness.js/pull/127 + // Refactor to make use of step_timeout. + setTimeout(function() { + test.step(function() { + assert_equals(test.phase, test.phases.COMPLETE, + "Expected test to complete."); + test.done(); + }) + }, timeout || 1000); +} |