Bug 1124091 - Try to make the CSP tests a bit more stable, r=Ms2ger
authorJames Graham <james@hoppipolla.co.uk>
Fri, 27 Mar 2015 17:32:36 +0000
changeset 266645 8183fed6b8a2da12231c6ad5e67c3b0c83a46944
parent 266644 c68a6ebe60838c61b84699e3314d99ca18a6ff2d
child 266646 e7db788bc37277caeb43434c1eaddd9607c3b616
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs1124091
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
testing/web-platform/meta/MANIFEST.json
testing/web-platform/meta/content-security-policy/media-src/media-src-7_1.html.ini
testing/web-platform/tests/content-security-policy/media-src/media-src-7_1.html
testing/web-platform/tests/content-security-policy/media-src/media-src-7_1_2.html
testing/web-platform/tests/content-security-policy/media-src/media-src-7_2.html
testing/web-platform/tests/content-security-policy/media-src/media-src-7_2_2.html
testing/web-platform/tests/content-security-policy/media-src/media-src-7_3.html
testing/web-platform/tests/content-security-policy/media-src/media-src-7_3_2.html
testing/web-platform/tests/content-security-policy/object-src/object-src-2_1.html
testing/web-platform/tests/content-security-policy/object-src/object-src-2_2.html
testing/web-platform/tests/content-security-policy/support/checkReport.sub.js
testing/web-platform/tests/content-security-policy/support/report.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -19494,17 +19494,76 @@
       },
       {
         "path": "webdriver/user_input/clear_test.py"
       }
     ]
   },
   "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": {
     "2dcontext/building-paths/canvas_complexshapes_arcto_001.htm": [
       {
         "path": "2dcontext/building-paths/canvas_complexshapes_arcto_001.htm",
         "references": [
           [
@@ -24566,9 +24625,9 @@
         ],
         "url": "/webvtt/rendering/cues-with-video/processing-model/too_many_cues_wrapped.html"
       }
     ]
   },
   "rev": "1defdd7213b52589e4b7a259e53f4fff359c301a",
   "url_base": "/",
   "version": 2
-}
\ No newline at end of file
+}
--- a/testing/web-platform/meta/content-security-policy/media-src/media-src-7_1.html.ini
+++ b/testing/web-platform/meta/content-security-policy/media-src/media-src-7_1.html.ini
@@ -1,10 +1,11 @@
 [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
 
   [In-policy async video source element]
     expected:
       if not debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): FAIL
 
--- a/testing/web-platform/tests/content-security-policy/media-src/media-src-7_1.html
+++ b/testing/web-platform/tests/content-security-policy/media-src/media-src-7_1.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body>
     <h1>Video element src attribute must match src list - positive test</h1>
     <div id='log'></div>
 
   <script>
--- a/testing/web-platform/tests/content-security-policy/media-src/media-src-7_1_2.html
+++ b/testing/web-platform/tests/content-security-policy/media-src/media-src-7_1_2.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body>
     <h1>Video element src attribute must match src list - negative test</h1>
     <div id='log'></div>
 
   <script>
--- a/testing/web-platform/tests/content-security-policy/media-src/media-src-7_2.html
+++ b/testing/web-platform/tests/content-security-policy/media-src/media-src-7_2.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body>
     <h1>Audio element src attribute must match src list - positive test</h1>
     <div id='log'></div>
 
   <script>
--- a/testing/web-platform/tests/content-security-policy/media-src/media-src-7_2_2.html
+++ b/testing/web-platform/tests/content-security-policy/media-src/media-src-7_2_2.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body>
     <h1>Audio element src attribute must match src list - negative test</h1>
     <div id='log'></div>
 
   <script>
--- a/testing/web-platform/tests/content-security-policy/media-src/media-src-7_3.html
+++ b/testing/web-platform/tests/content-security-policy/media-src/media-src-7_3.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body>
     <h1>Video track src attribute must match src list - positive test</h1>
     <div id='log'></div>
 
   <script>
--- a/testing/web-platform/tests/content-security-policy/media-src/media-src-7_3_2.html
+++ b/testing/web-platform/tests/content-security-policy/media-src/media-src-7_3_2.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body>
     <h1>Video track src attribute must match src list - negative test</h1>
     <div id='log'></div>
 
   <script>
--- a/testing/web-platform/tests/content-security-policy/object-src/object-src-2_1.html
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-2_1.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body onLoad="object_loaded()">
     <h1>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</h1>
     <div id="log"></div>
 
     <script>
@@ -29,28 +30,28 @@
 
       var hasMimeType = allTypes.indexOf(flashMimeType) != -1;
 
       <!-- The actual test. -->
       var test1 = async_test("Async SWF load test")
 
       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>
 
     <script async defer src="../support/checkReport.sub.js?reportField=violated-directive&reportValue=object-src%20%27self%27"></script>
 
 </body>
 </html>
--- a/testing/web-platform/tests/content-security-policy/object-src/object-src-2_2.html
+++ b/testing/web-platform/tests/content-security-policy/object-src/object-src-2_2.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 <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>
 <body onLoad="object_loaded()">
     <h1>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</h1>
     <div id="log"></div>
 
     <script>
@@ -29,28 +30,28 @@
 
       var hasMimeType = allTypes.indexOf(flashMimeType) != -1;
 
       <!-- The actual test. -->
       var test1 = async_test("Async SWF load test")
 
       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>
 
     <script async defer src="../support/checkReport.sub.js?reportField=violated-directive&reportValue=object-src%20%27self%27"></script>
 
 </body>
 </html>
--- a/testing/web-platform/tests/content-security-policy/support/checkReport.sub.js
+++ b/testing/web-platform/tests/content-security-policy/support/checkReport.sub.js
@@ -26,17 +26,18 @@
     if (cookieName == thisTestName) {
       reportID = cookieValue;
       var cookieToDelete = cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=" + document.location.pathname.substring(0, document.location.pathname.lastIndexOf('/') + 1);
       document.cookie = cookieToDelete;
       break;
     }
   }
 
-  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 () {
 
     var report = new XMLHttpRequest();
     report.onload = reportTest.step_func(function () {
 
         var data = JSON.parse(report.responseText);
--- a/testing/web-platform/tests/content-security-policy/support/report.py
+++ b/testing/web-platform/tests/content-security-policy/support/report.py
@@ -1,26 +1,23 @@
 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
\ No newline at end of file
+        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