summaryrefslogtreecommitdiffstats
path: root/dom/events/test/bug418986-3.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/events/test/bug418986-3.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/events/test/bug418986-3.js')
-rw-r--r--dom/events/test/bug418986-3.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/events/test/bug418986-3.js b/dom/events/test/bug418986-3.js
new file mode 100644
index 000000000..6bd2a6e69
--- /dev/null
+++ b/dom/events/test/bug418986-3.js
@@ -0,0 +1,69 @@
+SimpleTest.waitForExplicitFinish();
+
+// The main testing function.
+var test = function (isContent) {
+ // Each definition is [eventType, prefSetting]
+ // Where we are setting the "privacy.resistFingerprinting" pref.
+ let eventDefs = [["mousedown", true],
+ ["mouseup", true],
+ ["mousedown", false],
+ ["mouseup", false]];
+
+ let testCounter = 0;
+
+ // Declare ahead of time.
+ let setup;
+
+ // This function is called when the event handler fires.
+ let handleEvent = function (event, prefVal) {
+ let resisting = prefVal && isContent;
+ if (resisting) {
+ is(event.screenX, event.clientX, "event.screenX and event.clientX should be the same");
+ is(event.screenY, event.clientY, "event.screenY and event.clientY should be the same");
+ } else {
+ // We can't be sure about X coordinates not being equal, but we can test Y.
+ isnot(event.screenY, event.clientY, "event.screenY !== event.clientY");
+ }
+ ++testCounter;
+ if (testCounter < eventDefs.length) {
+ nextTest();
+ } else {
+ SimpleTest.finish();
+ }
+ };
+
+ // In this function, we set up the nth div and event handler,
+ // and then synthesize a mouse event in the div, to test
+ // whether the resulting events resist fingerprinting by
+ // suppressing absolute screen coordinates.
+ nextTest = function () {
+ let [eventType, prefVal] = eventDefs[testCounter];
+ SpecialPowers.pushPrefEnv({set:[["privacy.resistFingerprinting", prefVal]]},
+ function () {
+ // The following code creates a new div for each event in eventDefs,
+ // attaches a listener to listen for the event, and then generates
+ // a fake event at the center of the div.
+ let div = document.createElement("div");
+ div.style.width = "10px";
+ div.style.height = "10px";
+ div.style.backgroundColor = "red";
+ // Name the div after the event we're listening for.
+ div.id = eventType;
+ document.getElementById("body").appendChild(div);
+ // Seems we can't add an event listener in chrome unless we run
+ // it in a later task.
+ window.setTimeout(function() {
+ div.addEventListener(eventType, event => handleEvent(event, prefVal), false);
+ // For some reason, the following synthesizeMouseAtCenter call only seems to run if we
+ // wrap it in a window.setTimeout(..., 0).
+ window.setTimeout(function () {
+ synthesizeMouseAtCenter(div, {type : eventType});
+ }, 0);
+ }, 0);
+ });
+ };
+
+ // Now run by starting with the 0th event.
+ nextTest();
+
+};