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
54
55
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource://gre/modules/FxAccountsOAuthClient.jsm");
function run_test() {
validationHelper(undefined,
"Error: Missing 'parameters' configuration option");
validationHelper({},
"Error: Missing 'parameters' configuration option");
validationHelper({ parameters: {} },
"Error: Missing 'parameters.oauth_uri' parameter");
validationHelper({ parameters: {
oauth_uri: "http://oauth.test/v1"
}},
"Error: Missing 'parameters.client_id' parameter");
validationHelper({ parameters: {
oauth_uri: "http://oauth.test/v1",
client_id: "client_id"
}},
"Error: Missing 'parameters.content_uri' parameter");
validationHelper({ parameters: {
oauth_uri: "http://oauth.test/v1",
client_id: "client_id",
content_uri: "http://content.test"
}},
"Error: Missing 'parameters.state' parameter");
validationHelper({ parameters: {
oauth_uri: "http://oauth.test/v1",
client_id: "client_id",
content_uri: "http://content.test",
state: "complete",
action: "force_auth"
}},
"Error: parameters.email is required for action 'force_auth'");
run_next_test();
}
function validationHelper(params, expected) {
try {
new FxAccountsOAuthClient(params);
} catch (e) {
return do_check_eq(e.toString(), expected);
}
throw new Error("Validation helper error");
}
|