blob: 2e3854735538dd2e60b90ec8d177b32d648f8ace (
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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { lazyLoadFront } = require("resource://devtools/shared/specs/index.js");
const Types = require("resource://devtools/shared/specs/index.js")
.__TypesForTests;
const { getType } = require("resource://devtools/shared/protocol.js").types;
function run_test() {
test_index_is_alphabetically_sorted();
test_specs();
test_fronts();
}
// Check alphabetic order of specs defined in devtools/shared/specs/index.js,
// in order to ease its maintenance and readability.
function test_index_is_alphabetically_sorted() {
let lastSpec = "";
for (const type of Types) {
const spec = type.spec;
if (lastSpec && spec < lastSpec) {
ok(false, `Spec definition for "${spec}" should be before "${lastSpec}"`);
}
lastSpec = spec;
}
ok(true, "Specs index is alphabetically sorted");
}
function test_specs() {
for (const type of Types) {
for (const typeName of type.types) {
ok(!!getType(typeName), `${typeName} spec is defined`);
}
}
ok(true, "Specs are all accessible");
}
function test_fronts() {
for (const item of Types) {
if (!item.front) {
continue;
}
for (const typeName of item.types) {
lazyLoadFront(typeName);
const type = getType(typeName);
ok(!!type, `Front for ${typeName} has a spec`);
ok(type.frontClass, `${typeName} has a front correctly defined`);
}
}
ok(true, "Front are all accessible");
}
|