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 470942 9de838c2b917be555599f17acd84736d683fff8f
parent 470941 2dc3d03deb7619061f0f27671941974ea9fd8865
child 470943 7b5624407225df2c1b32c67b350242c4e58fe5c5
push id112883
push userjames@hoppipolla.co.uk
push dateWed, 24 Apr 2019 10:45:08 +0000
treeherdermozilla-inbound@a9e8bb1d8a16 [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);
+});