Bug 1624964: Add visited attribute to links, state caching for TRAVERSED. r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D70095

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Morgan Reschenberg 2020-04-10 15:54:15 +00:00
Родитель a503c44fe7
Коммит 2e7598ddac
4 изменённых файлов: 49 добавлений и 1 удалений

Просмотреть файл

@ -246,7 +246,8 @@ static inline NSMutableArray* ConvertToNSArray(nsTArray<ProxyAccessible*>& aArra
}
static const uint64_t kCachedStates = states::CHECKED | states::PRESSED | states::MIXED |
states::EXPANDED | states::CURRENT | states::SELECTED;
states::EXPANDED | states::CURRENT | states::SELECTED |
states::TRAVERSED;
static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
- (uint64_t)state {

Просмотреть файл

@ -56,6 +56,7 @@
if (!attributes) {
attributes = [[super accessibilityAttributeNames] mutableCopy];
[attributes addObject:NSAccessibilityURLAttribute];
[attributes addObject:@"AXVisited"];
}
return attributes;
@ -63,6 +64,9 @@
- (id)accessibilityAttributeValue:(NSString*)attribute {
if ([attribute isEqualToString:NSAccessibilityURLAttribute]) return [self url];
if ([attribute isEqualToString:@"AXVisited"]) {
return [NSNumber numberWithBool:[self stateWithMask:states::TRAVERSED] != 0];
}
return [super accessibilityAttributeValue:attribute];
}

Просмотреть файл

@ -17,3 +17,4 @@ support-files =
[browser_table.js]
[browser_selectables.js]
[browser_toggle_radio_check.js]
[browser_link_visited.js]

Просмотреть файл

@ -0,0 +1,42 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* import-globals-from ../../mochitest/role.js */
/* import-globals-from ../../mochitest/states.js */
loadScripts(
{ name: "role.js", dir: MOCHITESTS_DIR },
{ name: "states.js", dir: MOCHITESTS_DIR }
);
ChromeUtils.defineModuleGetter(
this,
"BrowserTestUtils",
"resource://testing-common/BrowserTestUtils.jsm"
);
/**
* Test visited link properties.
*/
addAccessibleTask(
`
<a id="link" href="http://www.example.com/">I am a non-visited link</a><br>
`,
async (browser, accDoc) => {
let link = getNativeInterface(accDoc, "link");
let stateChanged = waitForEvent(EVENT_STATE_CHANGE, "link");
is(link.getAttributeValue("AXVisited"), 0, "Link has not been visited");
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"http://www.example.com/"
);
await BrowserTestUtils.removeTab(tab);
await stateChanged;
is(link.getAttributeValue("AXVisited"), 1, "Link has been visited");
}
);