Bug 1124091 - Try to make the CSP tests a bit more stable, r=Ms2ger

Increase the test timeout for some problematic tests. Ensure that the
report check returns early when a report is detected as expected.
This commit is contained in:
James Graham 2015-03-27 17:32:36 +00:00
parent 7105742ac8
commit b3397efb33
12 changed files with 111 additions and 45 deletions

View File

@ -19499,7 +19499,66 @@
},
"local_changes": {
"deleted": [],
"items": {},
"items": {
"testharness": {
"content-security-policy/media-src/media-src-7_1.html": [
{
"path": "content-security-policy/media-src/media-src-7_1.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_1.html"
}
],
"content-security-policy/media-src/media-src-7_1_2.html": [
{
"path": "content-security-policy/media-src/media-src-7_1_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_1_2.html"
}
],
"content-security-policy/media-src/media-src-7_2.html": [
{
"path": "content-security-policy/media-src/media-src-7_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_2.html"
}
],
"content-security-policy/media-src/media-src-7_2_2.html": [
{
"path": "content-security-policy/media-src/media-src-7_2_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_2_2.html"
}
],
"content-security-policy/media-src/media-src-7_3.html": [
{
"path": "content-security-policy/media-src/media-src-7_3.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_3.html"
}
],
"content-security-policy/media-src/media-src-7_3_2.html": [
{
"path": "content-security-policy/media-src/media-src-7_3_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_3_2.html"
}
],
"content-security-policy/object-src/object-src-2_1.html": [
{
"path": "content-security-policy/object-src/object-src-2_1.html",
"timeout": "long",
"url": "/content-security-policy/object-src/object-src-2_1.html"
}
],
"content-security-policy/object-src/object-src-2_2.html": [
{
"path": "content-security-policy/object-src/object-src-2_2.html",
"timeout": "long",
"url": "/content-security-policy/object-src/object-src-2_2.html"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {
@ -24571,4 +24630,4 @@
"rev": "1defdd7213b52589e4b7a259e53f4fff359c301a",
"url_base": "/",
"version": 2
}
}

View File

@ -1,5 +1,6 @@
[media-src-7_1.html]
type: testharness
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1124091
[In-policy async video src]
expected:
if not debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): FAIL

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Video element src attribute must match src list - positive test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Video element src attribute must match src list - negative test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Audio element src attribute must match src list - positive test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Audio element src attribute must match src list - negative test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Video track src attribute must match src list - positive test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Video track src attribute must match src list - negative test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Objects loaded using data attribute of &lt;object&gt; tag are blocked unless their host is listed as an allowed source in the object-src directive</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
@ -34,19 +35,19 @@
function object_loaded() {
var elem = document.getElementById("flashObject");
var is_loaded = false;
try {
<!-- The Flash Player exposes values to JavaScript if a SWF has successfully been loaded. -->
var pct_loaded = elem.PercentLoaded();
is_loaded = true;
} catch (e) {}
var is_loaded = false;
try {
<!-- The Flash Player exposes values to JavaScript if a SWF has successfully been loaded. -->
var pct_loaded = elem.PercentLoaded();
is_loaded = true;
} catch (e) {}
if (hasMimeType) {
test1.step(function() {assert_false(is_loaded, "External object loaded.")});
} else {
test1.step(function() {assert_true(hasMimeType, "No Flash Player, cannot run test.")});
}
test1.done();
if (hasMimeType) {
test1.step(function() {assert_false(is_loaded, "External object loaded.")});
} else {
test1.step(function() {assert_true(hasMimeType, "No Flash Player, cannot run test.")});
}
test1.done();
}
</script>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Objects loaded using src attribute of &lt;embed&gt; tag are blocked unless their host is listed as an allowed source in the object-src directive</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
@ -34,19 +35,19 @@
function object_loaded() {
var elem = document.getElementById("flashObject");
var is_loaded = false;
try {
<!-- The Flash Player exposes values to JavaScript if a SWF has successfully been loaded. -->
var pct_loaded = elem.PercentLoaded();
is_loaded = true;
} catch (e) {}
var is_loaded = false;
try {
<!-- The Flash Player exposes values to JavaScript if a SWF has successfully been loaded. -->
var pct_loaded = elem.PercentLoaded();
is_loaded = true;
} catch (e) {}
if (hasMimeType) {
test1.step(function() {assert_false(is_loaded, "External object loaded.")});
} else {
test1.step(function() {assert_true(hasMimeType, "No Flash Player, cannot run test.")});
}
test1.done();
if (hasMimeType) {
test1.step(function() {assert_false(is_loaded, "External object loaded.")});
} else {
test1.step(function() {assert_true(hasMimeType, "No Flash Player, cannot run test.")});
}
test1.done();
}
</script>

View File

@ -31,7 +31,8 @@
}
}
var reportLocation = location.protocol + "//" + location.host + "/content-security-policy/support/report.py?op=take&timeout=5&reportID=" + reportID;
var timeout = document.querySelector("meta[name=timeout][content=long]") ? 50 : 5;
var reportLocation = location.protocol + "//" + location.host + "/content-security-policy/support/report.py?op=take&timeout=" + timeout + "&reportID=" + reportID;
var reportTest = async_test("Violation report status OK.");
reportTest.step(function () {

View File

@ -2,25 +2,22 @@ import time
import json
def main(request, response):
op = request.GET.first("op");
key = request.GET.first("reportID")
if op == "take":
timeout = float(request.GET.first("timeout"))
value = request.server.stash.take(key=key)
if value is not None:
return [("Content-Type", "application/json")], value
else:
time.sleep(timeout)
value = request.server.stash.take(key=key)
if value is not None:
return [("Content-Type", "application/json")], value
else:
return [("Content-Type", "application/json")], json.dumps({'error': 'No such report.' , 'guid' : key})
else:
report = request.body
report.rstrip()
request.server.stash.take(key=key)
request.server.stash.put(key=key, value=report)
return [("Content-Type", "text/plain")], "Recorded report " + report
timeout = float(request.GET.first("timeout"))
t0 = time.time()
while time.time() - t0 < timeout:
time.sleep(0.5)
value = request.server.stash.take(key=key)
if value is not None:
return [("Content-Type", "application/json")], value
return [("Content-Type", "application/json")], json.dumps({'error': 'No such report.' , 'guid' : key})
report = request.body
report.rstrip()
request.server.stash.take(key=key)
request.server.stash.put(key=key, value=report)
return [("Content-Type", "text/plain")], "Recorded report " + report