OLD | NEW |
(Empty) | |
| 1 // The SanityChecker is used in debug mode to identify problems with the |
| 2 // structure of the testsuite. In release mode it is mocked out to do nothing. |
| 3 |
| 4 function SanityChecker() {} |
| 5 |
| 6 SanityChecker.prototype.checkScenario = function(scenario) { |
| 7 // Check if scenario is valid. |
| 8 // TODO(kristijanburnik): Move to a sanity-checks.js for debug mode only. |
| 9 test(function() { |
| 10 |
| 11 // We extend the exsiting test_expansion_schema not to kill performance by |
| 12 // copying. |
| 13 var expectedFields = SPEC_JSON["test_expansion_schema"]; |
| 14 expectedFields["referrer_policy"] = SPEC_JSON["referrer_policy_schema"]; |
| 15 |
| 16 assert_own_property(scenario, "subresource_path", |
| 17 "Scenario has the path to the subresource."); |
| 18 |
| 19 for (var field in expectedFields) { |
| 20 assert_own_property(scenario, field, |
| 21 "The scenario contains field " + field) |
| 22 assert_in_array(scenario[field], expectedFields[field], |
| 23 "Scenario's " + field + " is one of: " + |
| 24 expectedFields[field].join(", ")) + "." |
| 25 } |
| 26 |
| 27 // Check if the protocol is matched. |
| 28 assert_equals(scenario["source_protocol"] + ":", location.protocol, |
| 29 "Protocol of the test page should match the scenario.") |
| 30 |
| 31 }, "[ReferrerPolicyTestCase] The test scenario is valid."); |
| 32 } |
| 33 |
| 34 SanityChecker.prototype.checkSubresourceResult = function(test, |
| 35 scenario, |
| 36 subresourceUrl, |
| 37 result) { |
| 38 test.step(function() { |
| 39 assert_equals(Object.keys(result).length, 3); |
| 40 assert_own_property(result, "location"); |
| 41 assert_own_property(result, "referrer"); |
| 42 assert_own_property(result, "headers"); |
| 43 |
| 44 // Skip location check for scripts. |
| 45 if (scenario.subresource == "script-tag") |
| 46 return; |
| 47 |
| 48 // Sanity check: location of sub-resource matches reported location. |
| 49 assert_equals(result.location, subresourceUrl, |
| 50 "Subresource reported location."); |
| 51 }, "Running a valid test scenario."); |
| 52 }; |
OLD | NEW |