Bug 1645988 [wpt PR 24165] - Python 3: port tests in document-metadata & embedded-content in html/…, a=testonly
authorZiran Sun <zsun@igalia.com>
Mon, 22 Jun 2020 10:40:56 +0000
changeset 536808 b652ecc3478ae04bd6a3f76128b5f5f239fd7853
parent 536807 4d3d34985ebcd9259fcf1e3323f774d0b079d375
child 536809 d5c7bacfde62813c8a4fb2b52669caea8ca50c35
push id37533
push userdluca@mozilla.com
push dateTue, 23 Jun 2020 21:38:40 +0000
treeherdermozilla-central@d48aa0f0aa0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1645988, 24165
milestone79.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 1645988 [wpt PR 24165] - Python 3: port tests in document-metadata & embedded-content in html/…, a=testonly Automatic update from web-platform-tests Python 3: port tests in document-metadata & embedded-content in html/semantics -- wpt-commits: aec6139dc296e26757011885238d69c77e17b804 wpt-pr: 24165
testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/stylesheet.py
testing/web-platform/tests/html/semantics/document-metadata/the-link-element/resources/css.py
testing/web-platform/tests/html/semantics/document-metadata/the-link-element/stylesheet.py
testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.py
testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resources/delayed-broken-video.py
testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/stash.py
testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/download_stash.py
testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/referrer-checker-img.py
--- a/testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/stylesheet.py
+++ b/testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/stylesheet.py
@@ -1,10 +1,10 @@
 from time import sleep
 def main(request, response):
-  if "delay" in request.GET:
-    delay = int(request.GET["delay"])
+  if b"delay" in request.GET:
+    delay = int(request.GET[b"delay"])
     sleep(delay)
 
-  if "stylesNotMatchingEnvironment" in request.GET:
-    return 'h1 {color: brown;}'
+  if b"stylesNotMatchingEnvironment" in request.GET:
+    return u'h1 {color: brown;}'
   else:
-    return 'h1 {color: purple;}'
+    return u'h1 {color: purple;}'
--- a/testing/web-platform/tests/html/semantics/document-metadata/the-link-element/resources/css.py
+++ b/testing/web-platform/tests/html/semantics/document-metadata/the-link-element/resources/css.py
@@ -1,7 +1,7 @@
 def main(request, response):
   response.add_required_headers = False
-  if "content_type" in request.GET:
-    response.writer.write_header("Content-Type", request.GET.first("content_type"))
-  if "nosniff" in request.GET:
-  	response.writer.write_header("x-content-type-options", "nosniff")
-  response.writer.write_content("body { background:red }")
+  if b"content_type" in request.GET:
+    response.writer.write_header(b"Content-Type", request.GET.first(b"content_type"))
+  if b"nosniff" in request.GET:
+  	response.writer.write_header(b"x-content-type-options", b"nosniff")
+  response.writer.write_content(u"body { background:red }")
--- a/testing/web-platform/tests/html/semantics/document-metadata/the-link-element/stylesheet.py
+++ b/testing/web-platform/tests/html/semantics/document-metadata/the-link-element/stylesheet.py
@@ -1,9 +1,9 @@
 def main(request, response):
     try:
-        count = int(request.server.stash.take(request.GET["id"]))
+        count = int(request.server.stash.take(request.GET[b"id"]))
     except:
         count = 0
-    if "count" in request.GET:
+    if b"count" in request.GET:
         return str(count)
-    request.server.stash.put(request.GET["id"], str(count + 1))
-    return 'body { color: red }'
+    request.server.stash.put(request.GET[b"id"], str(count + 1))
+    return u'body { color: red }'
--- a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.py
+++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.py
@@ -1,4 +1,4 @@
 def main(request, response):
-    response.headers.set("Content-Type", "text/html")
-    response.headers.set("Refresh", request.GET.first("input"))
-    response.content = "<!doctype html>refresh.py\n"
+    response.headers.set(b"Content-Type", b"text/html")
+    response.headers.set(b"Refresh", request.GET.first(b"input"))
+    response.content = u"<!doctype html>refresh.py\n"
--- a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resources/delayed-broken-video.py
+++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resources/delayed-broken-video.py
@@ -1,5 +1,5 @@
 import time
 
 def main(request, response):
   time.sleep(0.1)
-  return [("Content-Type", "text/plain")], "FAIL"
+  return [(b"Content-Type", b"text/plain")], u"FAIL"
--- a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/stash.py
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/stash.py
@@ -1,10 +1,10 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
 def main(request, response):
-    if request.method == 'POST':
-        request.server.stash.put(request.GET["id"], request.body)
-        return ''
-    return request.server.stash.take(request.GET["id"])
+    if request.method == u'POST':
+        request.server.stash.put(request.GET[b"id"], request.body)
+        return u''
+    return request.server.stash.take(request.GET[b"id"])
--- a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/download_stash.py
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/download_stash.py
@@ -1,28 +1,28 @@
 import time
 
 def main(request, response):
-    token = request.GET["token"]
+    token = request.GET[b"token"]
     response.status = 200
-    response.headers.append("Content-Type", "text/html")
-    if "verify-token" in request.GET:
+    response.headers.append(b"Content-Type", b"text/html")
+    if b"verify-token" in request.GET:
       if request.server.stash.take(token):
-        return 'TOKEN_SET'
-      return 'TOKEN_NOT_SET'
+        return u'TOKEN_SET'
+      return u'TOKEN_NOT_SET'
 
-    if "finish-delay" not in request.GET:
+    if b"finish-delay" not in request.GET:
       # <a download>
       request.server.stash.put(token, True)
       return
 
     # navigation to download
-    response.headers.append("Content-Disposition", "attachment")
+    response.headers.append(b"Content-Disposition", b"attachment")
     response.write_status_headers()
-    finish_delay = float(request.GET["finish-delay"]) / 1E3
+    finish_delay = float(request.GET[b"finish-delay"]) / 1E3
     count = 10
     single_delay = finish_delay / count
     for i in range(count): # pylint: disable=unused-variable
         time.sleep(single_delay)
-        response.writer.write_content("\n")
+        response.writer.write_content(u"\n")
         if not response.writer.flush():
           return
     request.server.stash.put(token, True)
--- a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/referrer-checker-img.py
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/referrer-checker-img.py
@@ -1,12 +1,14 @@
 import os
 
+from wptserve.utils import isomorphic_decode
+
 # Returns a valid image response when request's |referrer| matches
 # |expected_referrer|.
 def main(request, response):
-  referrer = request.headers.get("referer", "")
-  expected_referrer = request.GET.first("expected_referrer", "")
-  response_headers = [("Content-Type", "image/png")]
+  referrer = request.headers.get(b"referer", b"")
+  expected_referrer = request.GET.first(b"expected_referrer", b"")
+  response_headers = [(b"Content-Type", b"image/png")]
   if referrer == expected_referrer:
-    image_path = os.path.join(os.path.dirname(__file__), "image.png")
+    image_path = os.path.join(os.path.dirname(isomorphic_decode(__file__)), u"image.png")
     return (200, response_headers, open(image_path, mode='rb').read())
-  return (404, response_headers, "Not found")
+  return (404, response_headers, u"Not found")