Bug 1527661 [wpt PR 15356] - HTML: <form rel>, a=testonly
authorAnne van Kesteren <annevk@annevk.nl>
Tue, 05 Mar 2019 12:17:07 +0000
changeset 522183 16b6e709d409e86ea85e951e25ac4752fd4c9aba
parent 522182 e23c3c3fe9cd08271ca6b289631c975bdbc62e71
child 522184 58ff2725e6a596e2a99cef687cccae88aada7f47
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1527661, 15356
milestone67.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 1527661 [wpt PR 15356] - HTML: <form rel>, a=testonly Automatic update from web-platform-tests HTML: <form rel> (#15356) For https://github.com/whatwg/html/pull/4332. -- wpt-commits: b44dacf7a939fd93f3afb0c46f8f89d71ea20409 wpt-pr: 15356
testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-base-target.html
testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-button-target.html
testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-form-target.html
testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-input-target.html
testing/web-platform/tests/html/semantics/forms/form-submission-target/resources/endpoint.html
testing/web-platform/tests/html/semantics/forms/form-submission-target/resources/reltester.js
testing/web-platform/tests/html/semantics/rellist-feature-detection.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-base-target.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title>&lt;form rel> with &lt;base target></title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src=resources/reltester.js></script>
+<base target=_blank>
+<div id=log></div>
+<form action=resources/endpoint.html><input type=hidden name=channelname></form>
+<script>
+const submitter = document.querySelector("form"),
+      channelInput = document.querySelector("input");
+relTester(submitter, channelInput, "<base target>");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-button-target.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<title>&lt;form rel> with &lt;button formtarget></title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src=resources/reltester.js></script>
+<div id=log></div>
+<form action=resources/endpoint.html><input type=hidden name=channelname><button type=submit formtarget=_blank></form>
+<script>
+const submitter = document.querySelector("button"),
+      channelInput = document.querySelector("input");
+relTester(submitter, channelInput, "<button formtarget>");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-form-target.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<title>&lt;form rel target></title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src=resources/reltester.js></script>
+<div id=log></div>
+<form action=resources/endpoint.html target=_blank><input type=hidden name=channelname></form>
+<script>
+const submitter = document.querySelector("form"),
+      channelInput = document.querySelector("input");
+relTester(submitter, channelInput, "<form target>");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/form-submission-target/rel-input-target.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title>&lt;form rel> with &lt;input formtarget></title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src=resources/reltester.js></script>
+<base target=_blank>
+<div id=log></div>
+<form action=resources/endpoint.html><input type=hidden name=channelname><input type=submit formtarget=_blank></form>
+<script>
+const submitter = document.querySelector("input[type=submit]"),
+      channelInput = document.querySelector("input");
+relTester(submitter, channelInput, "<input formtarget>");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/form-submission-target/resources/endpoint.html
@@ -0,0 +1,11 @@
+<script>
+  const channelName = new URL(location).searchParams.get("channelname"),
+        channel = new BroadcastChannel(channelName);
+  channel.postMessage({ haveOpener: window.opener !== null,
+                        referrer: document.referrer });
+  // Because messages are not delivered synchronously and because closing a
+  // browsing context prompts the eventual clearing of all task sources, this
+  // document should not be closed until the opener document has confirmed
+  // receipt.
+  channel.onmessage = () => window.close();
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/form-submission-target/resources/reltester.js
@@ -0,0 +1,65 @@
+function relTester(submitter, channelInput, title) {
+  [
+    {
+      rel: "",
+      exposed: "all"
+    },
+    {
+      rel: "noopener",
+      exposed: "noopener"
+    },
+    {
+      rel: "noreferrer",
+      exposed: "noreferrer"
+    },
+    {
+      rel: "opener",
+      exposed: "all"
+    },
+    {
+      rel: "noopener noreferrer",
+      exposed: "noreferrer"
+    },
+    {
+      rel: "noreferrer opener",
+      exposed: "noreferrer"
+    },
+    {
+      rel: "opener noopener",
+      exposed: "noopener"
+    }
+  ].forEach(relTest => {
+    // Use promise_test to submit only after one test concluded
+    promise_test(t => {
+      return new Promise(resolve => {
+        const channelName = Date.now() + relTest.rel,
+              channel = new BroadcastChannel(channelName);
+        let form = submitter;
+        if (submitter.localName !== "form") {
+          form = submitter.form;
+        }
+        form.rel = relTest.rel;
+        channelInput.value = channelName;
+        if (submitter.localName !== "form") {
+          submitter.click();
+        } else {
+          submitter.submit();
+        }
+        channel.onmessage = t.step_func(e => {
+          if (relTest.exposed === "all" || relTest.exposed === "noopener") {
+            assert_equals(e.data.referrer, window.location.href, "referrer");
+          } else {
+            assert_equals(e.data.referrer, "", "referrer");
+          }
+          if (relTest.exposed === "all") {
+            assert_true(e.data.haveOpener, "opener");
+          } else {
+            assert_false(e.data.haveOpener, "opener");
+          }
+          resolve();
+        });
+        t.add_cleanup(() => channel.postMessage(null));
+      });
+    }, `<form rel="${relTest.rel}"> with ${title}`);
+  });
+}
--- a/testing/web-platform/tests/html/semantics/rellist-feature-detection.html
+++ b/testing/web-platform/tests/html/semantics/rellist-feature-detection.html
@@ -10,25 +10,26 @@ link_support_table['link'] = {
                'stylesheet', 'import', 'icon', 'alternate', 'prefetch',
                'prerender', 'next', 'manifest', 'apple-touch-icon',
                'apple-touch-icon-precomposed', 'canonical'],
   unsupported : ['author', 'bookmark', 'external', 'help', 'license',
                  'nofollow', 'pingback', 'prev', 'search', 'tag',
                  'noreferrer', 'noopener']
 };
 link_support_table['a'] =  {
-  supported : ['noreferrer', 'noopener'],
+  supported : ['noreferrer', 'noopener', 'opener'],
   unsupported : ['author', 'bookmark', 'external', 'help', 'license',
                  'nofollow', 'pingback', 'prev', 'search', 'tag',
                  'modulepreload', 'preload', 'preconnect', 'dns-prefetch',
                  'stylesheet', 'import', 'icon', 'alternate', 'prefetch',
                  'prerender', 'next', 'manifest', 'apple-touch-icon',
                  'apple-touch-icon-precomposed', 'canonical']
 };
 link_support_table['area'] = link_support_table['a'];
+link_support_table['form'] = link_support_table['form'];
 
 function test_rellist(tag_name, rel_table) {
   let element = document.createElement(tag_name);
   let tag = element.tagName;
   // Test that setting rel is also setting relList, for both
   // valid and invalid values.
   element.rel = 'whatever';
   assert_true(element.relList.contains('whatever'), 'tag = ' + tag + ', setting rel must work');
@@ -72,10 +73,11 @@ function test_rellist(tag_name, rel_tabl
     assert_false(element.relList.supports(unsupported[link_type]), 'tag = ' + tag + ', link type = ' + unsupported[link_type] + ' must be unsupported');
   }
 }
 
 test(function() {
   test_rellist('LINK', link_support_table['link']);
   test_rellist('A', link_support_table['a']);
   test_rellist('AREA', link_support_table['area']);
+  test_rellist('FORM', link_support_table['form']);
 }, 'Make sure that relList based feature detection is working');
 </script>