summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/permissions-policy/resources/permissions-policy-idle-detection-worker.js
blob: 0d348c72ae7136268da5414a963dee6e83315911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict';

// Dedicated worker
if (typeof postMessage === 'function') {
  onmessage = event => {
    switch(event.data.type) {
      case 'ready':
        new IdleDetector().start().then(() => {
          postMessage({ type: 'availability-result', enabled: true });
        }, error => {
          postMessage ({ type: 'availability-result', enabled: false });
        });
        break;
    }
  };
}