Bug 1124091 - Try to make the CSP tests a bit more stable. r=Ms2ger, a=test-only
authorJames Graham <james@hoppipolla.co.uk>
Fri, 27 Mar 2015 17:32:36 +0000
changeset 259806 448587b993b41dc4c0609d4dfea66d91e57e47d0
parent 259805 41be09fe77e0268ce047337453fa84c8cdc4e839
child 259807 804fbc03972515ff4d5977cc616e98469e4eab11
push id721
push userjlund@mozilla.com
push dateTue, 21 Apr 2015 23:03:33 +0000
treeherdermozilla-release@d27c9211ebb3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger, test-only
bugs1124091
milestone38.0a2
Bug 1124091 - Try to make the CSP tests a bit more stable. r=Ms2ger, a=test-only 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
@@ -18159,13 +18159,72 @@
       },
       {
         "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"
+          }
+        ]
+      }
+    }
   },
   "rev": "06dfcf88301bcc02ed25830f0d87c75f041dad4e",
   "url_base": "/"
-}
\ 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