blob: 620a3592f27fc89eb5df88bc05a6e1df1d854975 (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var globalVar = 0;
class TestURLSelectionOperation {
async run(urls, data) {
if (data && data.hasOwnProperty('mockResult')) {
return data['mockResult'];
}
return -1;
}
}
class IncrementGlobalVariableAndReturnOriginalValueOperation {
async run(urls, data) {
return globalVar++;
}
}
class VerifyKeyValue {
async run(urls, data) {
if (data && data.hasOwnProperty('expectedKey') &&
data.hasOwnProperty('expectedValue')) {
const expectedValue = data['expectedValue'];
const value = await sharedStorage.get(data['expectedKey']);
if (value === expectedValue) {
return 1;
}
}
return -1;
}
}
class VerifyKeyNotFound {
async run(urls, data) {
if (data && data.hasOwnProperty('expectedKey')) {
const value = await sharedStorage.get(data['expectedKey']);
if (typeof value === 'undefined') {
return 1;
}
}
return -1;
}
}
register('test-url-selection-operation', TestURLSelectionOperation);
register('increment-global-variable-and-return-original-value-operation',
IncrementGlobalVariableAndReturnOriginalValueOperation);
register('verify-key-value', VerifyKeyValue);
register('verify-key-not-found', VerifyKeyNotFound);
|