Skip to content

Commit

Permalink
Add tests that <a>/<area> can be downloaded without user interaction
Browse files Browse the repository at this point in the history
That is, that calling .click() does not throw at least, as it used to
per-spec. Matches the HTML change at
whatwg/html#2136 per the HTML bug report at
whatwg/html#2116.
  • Loading branch information
domenic committed Dec 5, 2016
1 parent b8a93c2 commit 5c12cd9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Clicking on an &lt;area> element with a download attribute must not throw an exception</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-area-element:activation-behaviour">
<link rel="help" href="https://github.com/whatwg/html/issues/2116">

<img src="/images/threecolors.png" usemap="#x" id="img" width="300" height="300">
<map name="x">
<area id="blob-url" download="foo.html" coords="0,0,300,300">
</map>

<script>
"use strict";

const string = "test";
const blob = new Blob([string], { type: "text/html" });

const link = document.querySelector("#blob-url");
link.href = URL.createObjectURL(blob);

link.click();
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Clicking on an &lt;a> element with a download attribute must not throw an exception</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-a-element:activation-behaviour">
<link rel="help" href="https://github.com/whatwg/html/issues/2116">

<a id="blob-url" download="foo.html">Click me</a>

<script>
"use strict";

const string = "test";
const blob = new Blob([string], { type: "text/html" });

const link = document.querySelector("#blob-url");
link.href = URL.createObjectURL(blob);

link.click();
</script>

0 comments on commit 5c12cd9

Please sign in to comment.