-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeyringDbusTest.js
38 lines (30 loc) · 1.08 KB
/
keyringDbusTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
imports.searchPath.push('dist');
const KeyringConnection = imports.keyringDbus.KeyringConnection;
let con = new KeyringConnection();
// let paths = con.getAllItemPaths();
// for (var i in paths) {
// print(paths[i]);
// }
// let test_item_path = "/org/freedesktop/secrets/collection/test/1";
// con.getSecretFromPath(test_item_path, function(label, secret) {
// print("Label : " + label);
// print("Secret: " + secret);
// con.close();
// });
// Test caching (should be really fast in the second run and just a bit slower in the third)
let t1 = Date.now();
let items = con.getItems(['github']);
print('Item count: ' + items.length);
print('First run: ' + (Date.now() - t1));
t1 = Date.now();
items = con.getItems(['github']);
print('Item count: ' + items.length);
print('Second run: ' + (Date.now() - t1));
con.unlockObject('/org/freedesktop/secrets/collection/test', function() {
t1 = Date.now();
items = con.getItems(['github']);
print('Item count: ' + items.length);
print('Third run: ' + (Date.now() - t1));
imports.mainloop.quit();
});
imports.mainloop.run();