mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1234020: Part 2c - [webext] Return promises from the idle API. r=rpl
This commit is contained in:
parent
2d769cdaa7
commit
6500b66487
@ -3,8 +3,8 @@
|
||||
extensions.registerSchemaAPI("idle", "idle", (extension, context) => {
|
||||
return {
|
||||
idle: {
|
||||
queryState: function(detectionIntervalInSeconds, callback) {
|
||||
runSafe(context, callback, "active");
|
||||
queryState: function(detectionIntervalInSeconds) {
|
||||
return Promise.resolve("active");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
"name": "queryState",
|
||||
"type": "function",
|
||||
"description": "Returns \"locked\" if the system is locked, \"idle\" if the user has not generated any input for a specified number of seconds, or \"active\" otherwise.",
|
||||
"async": "callback",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "detectionIntervalInSeconds",
|
||||
|
@ -32,6 +32,7 @@ skip-if = buildapp == 'b2g' # runat != document_idle is not supported.
|
||||
[test_ext_contentscript_api_injection.html]
|
||||
[test_ext_i18n_css.html]
|
||||
[test_ext_generate.html]
|
||||
[test_ext_idle.html]
|
||||
[test_ext_localStorage.html]
|
||||
[test_ext_onmessage_removelistener.html]
|
||||
[test_ext_notifications.html]
|
||||
|
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>WebExtension idle API test</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
|
||||
add_task(function* testIdle() {
|
||||
function background() {
|
||||
browser.idle.queryState(15).then(status => {
|
||||
browser.test.assertEq("active", status, "Expected status");
|
||||
browser.test.notifyPass("idle");
|
||||
},
|
||||
e => {
|
||||
browser.test.fail(`Error: ${e} :: ${e.stack}`);
|
||||
browser.test.notifyFail("idle");
|
||||
});
|
||||
}
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
background: `(${background})()`,
|
||||
|
||||
manifest: {
|
||||
permissions: ["idle"],
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
|
||||
yield extension.awaitFinish("idle");
|
||||
|
||||
yield extension.unload();
|
||||
});
|
||||
</script>
|
||||
</body>
|
Loading…
Reference in New Issue
Block a user