[idle] Add a threshold minimum of 60 seconds in IdleDetector

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 <ayui@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#643965}
diff --git a/idle-detection/basics.tentative.https.any.js b/idle-detection/basics.tentative.https.any.js
index df54757..c31faff 100644
--- a/idle-detection/basics.tentative.https.any.js
+++ b/idle-detection/basics.tentative.https.any.js
@@ -24,7 +24,7 @@
   new IdleDetector({
     get threshold() {
       used = true;
-      return 1;
+      return 60;
     }
   });
 
@@ -34,7 +34,7 @@
 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');
   }
@@ -42,6 +42,23 @@
 
 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});
     assert_unreached('Threshold of null should reject');
   } catch (error) {
@@ -75,4 +92,3 @@
   new IdleDetector({threshold: undefined});
 }, 'constructor uses a default value for the threshold');
 
-
diff --git a/idle-detection/idlharness.https.any.js b/idle-detection/idlharness.https.any.js
index 482e2f4..e6aa2f9 100644
--- a/idle-detection/idlharness.https.any.js
+++ b/idle-detection/idlharness.https.any.js
@@ -19,7 +19,7 @@
   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"]);
 
diff --git a/idle-detection/interceptor.https.html b/idle-detection/interceptor.https.html
index 37922c8..f47a9e7 100644
--- a/idle-detection/interceptor.https.html
+++ b/idle-detection/interceptor.https.html
@@ -23,7 +23,7 @@
       });
   });
 
-  let detector = new IdleDetector({threshold: 10});
+  let detector = new IdleDetector({threshold: 60});
 
   let watcher = new EventWatcher(t, detector, ["change"]);
 
@@ -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"]);
 
@@ -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"]);
 
@@ -137,7 +137,7 @@
       });
     });
 
-  let detector = new IdleDetector({threshold: 10});
+  let detector = new IdleDetector({threshold: 60});
 
   let watcher = new EventWatcher(t, detector, ["change"]);
 
@@ -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;
@@ -188,7 +188,7 @@
       });
     });
 
-  let detector = new IdleDetector({threshold: 10});
+  let detector = new IdleDetector({threshold: 60});
 
   let watcher = new EventWatcher(t, detector, ["change"]);
 
@@ -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();
@@ -247,7 +247,7 @@
       });
     });
 
-  let detector = new IdleDetector({threshold: 10});
+  let detector = new IdleDetector({threshold: 60});
 
   let watcher = new EventWatcher(t, detector, ["change"]);