summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/test/doc_event-listeners-03.html
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/shared/test/doc_event-listeners-03.html')
-rw-r--r--devtools/client/shared/test/doc_event-listeners-03.html65
1 files changed, 65 insertions, 0 deletions
diff --git a/devtools/client/shared/test/doc_event-listeners-03.html b/devtools/client/shared/test/doc_event-listeners-03.html
new file mode 100644
index 0000000000..2660f9f141
--- /dev/null
+++ b/devtools/client/shared/test/doc_event-listeners-03.html
@@ -0,0 +1,65 @@
+<!-- Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <title>Bound event listeners test page</title>
+ </head>
+
+ <body>
+ <button id="initialSetup">initialSetup</button>
+ <button id="clicker">clicker</button>
+ <button id="handleEventClick">handleEventClick</button>
+ <button id="boundHandleEventClick">boundHandleEventClick</button>
+
+ <script type="text/javascript">
+ "use strict";
+
+ window.addEventListener("load", function() {
+ function initialSetup(event) {
+ const button = document.getElementById("initialSetup");
+ button.removeEventListener("click", initialSetup);
+ // eslint-disable-next-line no-debugger
+ debugger;
+ }
+
+ function clicker(event) {
+ window.foobar = "clicker";
+ }
+
+ function HandleEventClick() {
+ const button = document.getElementById("handleEventClick");
+ // Create a long prototype chain to test for weird edge cases.
+ button.addEventListener("click", Object.create(Object.create(this)));
+ }
+
+ HandleEventClick.prototype.handleEvent = function() {
+ window.foobar = "HandleEventClick";
+ };
+
+ function BoundHandleEventClick() {
+ const button = document.getElementById("boundHandleEventClick");
+ this.handleEvent = this.handleEvent.bind(this);
+ button.addEventListener("click", this);
+ }
+
+ BoundHandleEventClick.prototype.handleEvent = function() {
+ window.foobar = "BoundHandleEventClick";
+ };
+
+ const button = document.getElementById("clicker");
+ // Bind more than once to test for weird edge cases.
+ const boundClicker = clicker.bind(this).bind(this).bind(this);
+ button.addEventListener("click", boundClicker);
+
+ new HandleEventClick();
+ new BoundHandleEventClick();
+
+ const initButton = document.getElementById("initialSetup");
+ initButton.addEventListener("click", initialSetup);
+ }, {once: true});
+ </script>
+ </body>
+
+</html>