Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 385383c

Browse files
author
Nathan LaPre
committed
Bug 1794974: Part 7: Add caching granularity tests, r=Jamie
This revision implements the caching granularity tests. To do this, first it adds some infrastructure to the accessibleTask function that allows a user of addAccessibleTask to specify cache domains for the test. If they don't specify cache domains, all domains are enabled. This way, existing mochitests and browser tests can keep working with no modifications. This revision adds utility functions for verifying the absence and presence of a cache key, with a query function that pokes an accessible like an AT would in order to trigger caching some domain. Finally, this revision adds tests for every cache key in every cache domain. The structure of the tests are: verify the attribute isn't cached (if possible), then poke the acc like an AT to trigger caching, then verify the attribute has been cached. Differential Revision: https://phabricator.services.mozilla.com/D220041
1 parent 5057850 commit 385383c

23 files changed

+1300
-0
lines changed

accessible/moz.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ BROWSER_CHROME_MANIFESTS += [
3737
"tests/browser/atk/browser.toml",
3838
"tests/browser/bounds/browser.toml",
3939
"tests/browser/browser.toml",
40+
"tests/browser/caching_granularity/browser.toml",
4041
"tests/browser/e10s/browser.toml",
4142
"tests/browser/events/browser.toml",
4243
"tests/browser/fission/browser.toml",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[DEFAULT]
2+
subsuite = "a11y"
3+
support-files = [
4+
"head.js",
5+
"!/accessible/tests/browser/shared-head.js",
6+
"!/accessible/tests/mochitest/*.js",
7+
"!/accessible/tests/mochitest/letters.gif",
8+
]
9+
10+
["browser_actions_domain.js"]
11+
12+
["browser_aria_domain.js"]
13+
14+
["browser_bounds_domain.js"]
15+
16+
["browser_dom_node_id_and_class_domain.js"]
17+
18+
["browser_initial_caching.js"]
19+
20+
["browser_inner_html_caching.js"]
21+
skip-if = ["os != 'win'"]
22+
23+
["browser_name_and_description_domain.js"]
24+
25+
["browser_relations_domain_1.js"]
26+
27+
["browser_relations_domain_2.js"]
28+
29+
["browser_scroll_position_domain.js"]
30+
31+
["browser_text_offset_attributes_domain.js"]
32+
33+
["browser_state_domain.js"]
34+
35+
["browser_style_domain.js"]
36+
37+
["browser_table_domain.js"]
38+
39+
["browser_text_bounds_domain.js"]
40+
41+
["browser_text_domain.js"]
42+
43+
["browser_transform_matrix_domain.js"]
44+
45+
["browser_value_domain.js"]
46+
47+
["browser_viewport_domain.js"]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
"use strict";
6+
7+
// CacheKey::AccessKey, CacheDomain::Actions
8+
addAccessibleTask(
9+
`<div id="test" accesskey="x">test</div>`,
10+
async function (browser, docAcc) {
11+
let acc = findAccessibleChildByID(docAcc, "test");
12+
await testAttributeCachePresence(acc, "accesskey", () => {
13+
acc.accessKey;
14+
});
15+
},
16+
{
17+
topLevel: true,
18+
iframe: false, // AccessKey issues with iframe - See Bug 1796846
19+
remoteIframe: true,
20+
cacheDomains: CacheDomain.None,
21+
}
22+
);
23+
24+
// CacheKey::HasLongdesc, CacheDomain::Actions
25+
addAccessibleTask(
26+
`<img id="test" src="http://example.com/a11y/accessible/tests/mochitest/moz.png" longdesc="http://example.com">`,
27+
async function (browser, docAcc) {
28+
let acc = findAccessibleChildByID(docAcc, "test");
29+
await testAttributeCachePresence(acc, "longdesc", () => {
30+
acc.actionCount;
31+
});
32+
},
33+
{
34+
topLevel: true,
35+
iframe: true,
36+
remoteIframe: true,
37+
cacheDomains: CacheDomain.None,
38+
}
39+
);
40+
41+
// CacheKey::PrimaryAction, CacheDomain::Actions
42+
addAccessibleTask(
43+
`<button id="test" onclick="console.log('test');">test</button>`,
44+
async function (browser, docAcc) {
45+
let acc = findAccessibleChildByID(docAcc, "test");
46+
await testAttributeCachePresence(acc, "action", () => {
47+
acc.actionCount;
48+
});
49+
},
50+
{
51+
topLevel: true,
52+
iframe: true,
53+
remoteIframe: true,
54+
cacheDomains: CacheDomain.None,
55+
}
56+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
"use strict";
6+
7+
// CacheKey::ARIAAttributes, CacheDomain::ARIA
8+
addAccessibleTask(
9+
`<div id="test" aria-live="polite">test</div>`,
10+
async function (browser, docAcc) {
11+
let acc = findAccessibleChildByID(docAcc, "test");
12+
await testAttributeCachePresence(acc, "aria", () => {
13+
acc.attributes;
14+
});
15+
},
16+
{
17+
topLevel: true,
18+
iframe: true,
19+
remoteIframe: true,
20+
cacheDomains: CacheDomain.None,
21+
}
22+
);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
"use strict";
6+
7+
// CacheDomain::Bounds, CacheKey::CrossDocOffset
8+
addAccessibleTask(
9+
`<div id="test">test</div>`,
10+
async function (browser, _, docAcc) {
11+
// Translate the iframe, which should modify cross-process offset.
12+
info("Setting the transform on the iframe");
13+
await SpecialPowers.spawn(browser, [DEFAULT_IFRAME_ID], iframeID => {
14+
let elm = content.document.getElementById(iframeID);
15+
elm.style.transform = "translate(100px,100px)";
16+
});
17+
await waitForContentPaint(browser);
18+
19+
let acc = findAccessibleChildByID(docAcc, DEFAULT_IFRAME_ID);
20+
await testAttributeCachePresence(acc, "crossorigin", () => {
21+
// Querying bounds queries the CrossDocOffset info.
22+
acc.getBounds({}, {}, {}, {});
23+
});
24+
},
25+
{
26+
topLevel: false,
27+
iframe: true,
28+
remoteIframe: true,
29+
cacheDomains: CacheDomain.None,
30+
}
31+
);
32+
33+
// CacheKey::IsClipped, CacheDomain::Bounds
34+
addAccessibleTask(
35+
`<div id="generic"><span aria-hidden="true" id="visible">Mozilla</span><span id="invisible" style="display: block !important;border: 0 !important;clip: rect(0 0 0 0) !important;height: 1px !important;margin: -1px !important;overflow: hidden !important;padding: 0 !important;position: absolute !important;white-space: nowrap !important;width: 1px !important;">Mozilla</span><br>I am some other text</div>`,
36+
async function (browser, docAcc) {
37+
let acc = findAccessibleChildByID(docAcc, "invisible");
38+
await testAttributeCachePresence(acc, "clip-rule", () => {
39+
// Querying bounds queries the IsClipped info.
40+
acc.getBounds({}, {}, {}, {});
41+
});
42+
},
43+
{
44+
topLevel: true,
45+
iframe: true,
46+
remoteIframe: true,
47+
cacheDomains: CacheDomain.None,
48+
}
49+
);
50+
51+
// CacheKey::ParentRelativeBounds, CacheDomain::Bounds
52+
addAccessibleTask(
53+
`<br><div id="test">test</div>`,
54+
async function (browser, docAcc) {
55+
let acc = findAccessibleChildByID(docAcc, "test");
56+
await testAttributeCachePresence(acc, "relative-bounds", () => {
57+
// Querying bounds queries the ParentRelativeBounds info.
58+
acc.getBounds({}, {}, {}, {});
59+
});
60+
},
61+
{
62+
topLevel: true,
63+
iframe: true,
64+
remoteIframe: true,
65+
cacheDomains: CacheDomain.None,
66+
}
67+
);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
"use strict";
6+
7+
// NOTE: These aren't testable easily because the DOMNodeIDAndClass domain is
8+
// required in order to instantiate an accessible task. So, we test only that
9+
// the attributes are present in the cache as expected.
10+
11+
// CacheKey::DOMNodeClass, CacheDomain::DOMNodeIDAndClass
12+
addAccessibleTask(
13+
`<div id="test" class="test">test</div>`,
14+
async function (browser, docAcc) {
15+
let acc = findAccessibleChildByID(docAcc, "test");
16+
verifyAttributeCachedNoRetry(acc, "class");
17+
},
18+
{
19+
topLevel: true,
20+
iframe: true,
21+
remoteIframe: true,
22+
cacheDomains: CacheDomain.DOMNodeIDAndClass,
23+
}
24+
);
25+
26+
// CacheKey::DOMNodeID, CacheDomain::DOMNodeIDAndClass
27+
addAccessibleTask(
28+
`<div id="test" class="test">test</div>`,
29+
async function (browser, docAcc) {
30+
let acc = findAccessibleChildByID(docAcc, "test");
31+
verifyAttributeCachedNoRetry(acc, "id");
32+
},
33+
{
34+
topLevel: true,
35+
iframe: true,
36+
remoteIframe: true,
37+
cacheDomains: CacheDomain.DOMNodeIDAndClass,
38+
}
39+
);
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
"use strict";
6+
7+
// CacheKey::InputType, no cache domain
8+
addAccessibleTask(
9+
`<input id="test" type="search"/>`,
10+
async function (browser, docAcc) {
11+
let acc = findAccessibleChildByID(docAcc, "test");
12+
await verifyAttributeCachedNoRetry(acc, "text-input-type");
13+
},
14+
{
15+
topLevel: true,
16+
iframe: true,
17+
remoteIframe: true,
18+
cacheDomains: CacheDomain.None,
19+
}
20+
);
21+
22+
// CacheKey::MimeType, no cache domain
23+
addAccessibleTask(
24+
``,
25+
async function (browser, docAcc) {
26+
await verifyAttributeCachedNoRetry(docAcc, "content-type");
27+
},
28+
{
29+
topLevel: true,
30+
iframe: true,
31+
remoteIframe: true,
32+
cacheDomains: CacheDomain.None,
33+
}
34+
);
35+
36+
// CacheKey::PopupType, no cache domain
37+
addAccessibleTask(
38+
`<div popover id="test">test</div>`,
39+
async function (browser, _) {
40+
info("Showing popover");
41+
let shown = waitForEvent(EVENT_SHOW, "test");
42+
await invokeContentTask(browser, [], () => {
43+
content.document.getElementById("test").showPopover();
44+
});
45+
let popover = (await shown).accessible;
46+
await verifyAttributeCachedNoRetry(popover, "ispopup");
47+
},
48+
{
49+
topLevel: true,
50+
iframe: true,
51+
remoteIframe: true,
52+
cacheDomains: CacheDomain.None,
53+
}
54+
);
55+
56+
// CacheKey::TagName, no cache domain
57+
addAccessibleTask(
58+
``,
59+
async function (browser, docAcc) {
60+
await verifyAttributeCachedNoRetry(docAcc, "tag");
61+
},
62+
{
63+
topLevel: true,
64+
iframe: true,
65+
remoteIframe: true,
66+
cacheDomains: CacheDomain.None,
67+
}
68+
);
69+
70+
// CacheKey::ARIARole, no cache domain
71+
addAccessibleTask(
72+
`<div id="test" role="invalid-role">test</div>`,
73+
async function (browser, docAcc) {
74+
let acc = findAccessibleChildByID(docAcc, "test");
75+
await verifyAttributeCachedNoRetry(acc, "role");
76+
},
77+
{
78+
topLevel: true,
79+
iframe: true,
80+
remoteIframe: true,
81+
cacheDomains: CacheDomain.None,
82+
}
83+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
"use strict";
6+
7+
// CacheKey::InnerHTML, CacheDomain::InnerHTML
8+
addAccessibleTask(
9+
`<math id="test"><mfrac><mi>x</mi><mi>y</mi></mfrac></math>`,
10+
async function (browser, docAcc) {
11+
let acc = findAccessibleChildByID(docAcc, "test");
12+
await verifyAttributeCachedNoRetry(acc, "html");
13+
},
14+
{
15+
topLevel: true,
16+
iframe: true,
17+
remoteIframe: true,
18+
// Entire test runs with domain already active because there's no XPC method
19+
// to trigger caching of InnerHTML.
20+
cacheDomains: CacheDomain.InnerHTML,
21+
}
22+
);

0 commit comments

Comments
 (0)