Bug 1507899 [wpt PR 14095] - EventSource: test U+0000 in ID better, a=testonly
authorAnne van Kesteren <annevk@annevk.nl>
Thu, 18 Apr 2019 10:13:41 +0000
changeset 470548 dbec48269d69acdaa6059139c37a6754239e4f5e
parent 470547 c6e213739d9a022ec1bebff45e624986264d5a0c
child 470549 1267e59b64193a4ee3607d22c1d7b9213b39a061
push id112872
push userjames@hoppipolla.co.uk
push dateTue, 23 Apr 2019 14:15:53 +0000
treeherdermozilla-inbound@fc657d55eb97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1507899, 14095, 1387355
milestone68.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 1507899 [wpt PR 14095] - EventSource: test U+0000 in ID better, a=testonly Automatic update from web-platform-tests EventSource: test U+0000 in ID better See https://bugzilla.mozilla.org/show_bug.cgi?id=1387355 for context. -- wpt-commits: 63f4985fa372b914a2e5f89085d089fcef01285b wpt-pr: 14095
testing/web-platform/tests/eventsource/format-field-id-null.htm
testing/web-platform/tests/eventsource/format-field-id-null.window.js
deleted file mode 100644
--- a/testing/web-platform/tests/eventsource/format-field-id-null.htm
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="utf-8">
-    <title>EventSource: U+0000 in id field</title>
-    <script src="/resources/testharness.js"></script>
-    <script src="/resources/testharnessreport.js"></script>
-  </head>
-  <body>
-    <div id="log"></div>
-    <script>
-      var test = async_test()
-      test.step(function() {
-        var source = new EventSource("resources/last-event-id.py?idvalue=%00%00"),
-            seenhello = false
-        source.onmessage = function(e) {
-          test.step(function() {
-            if(e.data == "hello" && !seenhello) {
-              seenhello = true
-              assert_equals(e.lastEventId, "")
-            } else if(seenhello) {
-              assert_equals(e.data, "hello")
-              assert_equals(e.lastEventId, "")
-              source.close()
-              test.done()
-            } else
-              assert_unreached()
-          })
-        }
-      })
-    </script>
-  </body>
-</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/eventsource/format-field-id-null.window.js
@@ -0,0 +1,25 @@
+[
+  "\u0000\u0000",
+  "x\u0000",
+  "\u0000x",
+  "x\u0000x",
+  " \u0000"
+].forEach(idValue => {
+  const encodedIdValue = encodeURIComponent(idValue);
+  async_test(t => {
+    const source = new EventSource("resources/last-event-id.py?idvalue=" + encodedIdValue);
+    t.add_cleanup(() => source.close());
+    let seenhello = false;
+    source.onmessage = t.step_func(e => {
+      if (e.data == "hello" && !seenhello) {
+        seenhello = true;
+        assert_equals(e.lastEventId, "");
+      } else if(seenhello) {
+        assert_equals(e.data, "hello");
+        assert_equals(e.lastEventId, "");
+        t.done();
+      } else
+        assert_unreached();
+    });
+  }, "EventSource: id field set to " + encodedIdValue);
+});