Skip to content

Commit

Permalink
[idle] Add a threshold minimum of 60 seconds in IdleDetector
Browse files Browse the repository at this point in the history
This change adds a minimum threshold of 60 seconds to prevent sites from
observing user signals such as typing cadence, or identifying users
with physical or cognitive imparments that may require more time to
interact with user agents and content.

Bug: 939883
Change-Id: I3ab19b2f7d6711c14356575d338819f501eafb9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1535286
Commit-Queue: Ayu Ishii <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/master@{#643965}
  • Loading branch information
ayuishii authored and chromium-wpt-export-bot committed Mar 25, 2019
1 parent 69e5802 commit ea7981d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
22 changes: 19 additions & 3 deletions idle-detection/basics.tentative.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ promise_test(async t => {
new IdleDetector({
get threshold() {
used = true;
return 1;
return 60;
}
});

Expand All @@ -34,12 +34,29 @@ promise_test(async t => {
promise_test(async t => {
try {
new IdleDetector({threshold: 0});
assert_unreached('Threshold of 0 should reject');
assert_unreached('Threshold under 60 should reject');
} catch (error) {
assert_equals(error.name, 'TypeError');
}
}, 'constructor throws with invalid threshold (0)');

promise_test(async t => {
try {
new IdleDetector({threshold: 59});
assert_unreached('Threshold under 60 should reject');
} catch (error) {
assert_equals(error.name, 'TypeError');
}
}, 'constructor throws with threshold below minimum (59)');

promise_test(async t => {
new IdleDetector({threshold: 60});
}, 'constructor allows threshold (60)');

promise_test(async t => {
new IdleDetector({threshold: 61});
}, 'constructor allows threshold (61)');

promise_test(async t => {
try {
new IdleDetector({threshold: null});
Expand Down Expand Up @@ -75,4 +92,3 @@ promise_test(async t => {
new IdleDetector({threshold: undefined});
}, 'constructor uses a default value for the threshold');


2 changes: 1 addition & 1 deletion idle-detection/idlharness.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ promise_test(async (t) => {
idl_array.add_dependency_idls(dom);
idl_array.add_dependency_idls(html);

self.idle = new IdleDetector({threshold: 1});
self.idle = new IdleDetector({threshold: 60});

let watcher = new EventWatcher(t, self.idle, ["change"]);

Expand Down
16 changes: 8 additions & 8 deletions idle-detection/interceptor.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
});
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

let watcher = new EventWatcher(t, detector, ["change"]);

Expand Down Expand Up @@ -59,7 +59,7 @@
return first;
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

let watcher = new EventWatcher(t, detector, ["change"]);

Expand Down Expand Up @@ -106,7 +106,7 @@
return first;
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

let watcher = new EventWatcher(t, detector, ["change"]);

Expand Down Expand Up @@ -137,7 +137,7 @@
});
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

let watcher = new EventWatcher(t, detector, ["change"]);

Expand All @@ -161,7 +161,7 @@
});
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

let event = new Promise((resolve, reject) => {
detector.onchange = resolve;
Expand All @@ -188,7 +188,7 @@
});
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

let watcher = new EventWatcher(t, detector, ["change"]);

Expand Down Expand Up @@ -220,7 +220,7 @@
});
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

// Calling stop() before start() is a no-op.
detector.stop();
Expand All @@ -247,7 +247,7 @@
});
});

let detector = new IdleDetector({threshold: 10});
let detector = new IdleDetector({threshold: 60});

let watcher = new EventWatcher(t, detector, ["change"]);

Expand Down

0 comments on commit ea7981d

Please sign in to comment.