Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(frameMessenger): clarify advanced use cases #2885

Merged
merged 4 commits into from
Jun 17, 2021

Conversation

WilcoFiers
Copy link
Contributor

Processing some feedback from @dbjorge. Thanks for the thorough review.

@WilcoFiers WilcoFiers requested a review from a team as a code owner April 23, 2021 12:34
dylanb
dylanb previously approved these changes Apr 23, 2021
@@ -8,10 +8,13 @@ Tools like browser extensions and testing environments often have different chan
axe.frameMessenger({
// Called to initialize message handling
open(topicHandler) {
// Map data from the bridge to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing end of sentence?

@@ -8,10 +8,13 @@ Tools like browser extensions and testing environments often have different chan
axe.frameMessenger({
// Called to initialize message handling
open(topicHandler) {
// Map data from the bridge to
function subscriber(frameWin, data, response) {
// Data serializations / validation / etc. here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this would probably be where an implementer would be deserializing data, not serializing it

@@ -38,6 +41,65 @@ The `open` function can `return` an optional cleanup function, which is called w

## axe.frameMessenger({ post })

`post` is a function that dictates how axe-core communicates with frames. It is passed three arguments: `frameWindow`, which is the frames `contentWindow`, the `data` object, and a `replyHandler` that must be called when responses are received.
`post` is a function that dictates how axe-core communicates with frames. It is passed three arguments: `frameWindow`, which is the frames `contentWindow`, the `data` object, and a `replyHandler` that must be called when responses are received. To inform axe-core that no message was sent, return `false`. This informs axe-core not to await for the ping to time out.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: frames -> frame's


open(topicHandler) {
function subscriber(frameWin, data, response) {
const { channelId, message, messageId } = data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

messageId isn't used, it can probably be omitted to simplify the example

},

open(topicHandler) {
function subscriber(frameWin, data, response) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response isn't used, it can probably be omitted to simplify the example

axe.d.ts Outdated
replyHandler: ReplyHandler
message: any | Error,
keepalive?: boolean,
replyHandler?: ReplyHandler
) => void;
type TopicData = { topic: String } & ReplyData;
type ReplyData = { channelId: String; message: any; keepAlive: Boolean };
Copy link
Contributor

@dbjorge dbjorge Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses a keepAlive property (uppercase A); based on the rest of the docs, L330 of the typings, and L29 of respondable.js, I think it should probably be lowercase A

axe.d.ts Outdated
replyHandler: ReplyHandler
message: any | Error,
keepalive?: boolean,
replyHandler?: ReplyHandler
) => void;
type TopicData = { topic: String } & ReplyData;
type ReplyData = { channelId: String; message: any; keepAlive: Boolean };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should keepAlive be using the primitive boolean type here, or is Boolean really intended?

Copy link
Contributor

@dbjorge dbjorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a substantial improvement! A few more comments inline

axe.d.ts Outdated Show resolved Hide resolved
dbjorge added a commit to microsoft/accessibility-insights-web that referenced this pull request Apr 29, 2021
#4155)

#### Details

This PR updates `axe-core` to the recently-released v4.2.0.

The bulk of the code changes here are an implementation of a custom `axe.frameMessenger` based on `browser.runtime.sendMessage` (`axe-frame-messenger.ts`), which allows us to avoid issues with target pages that intercept `window.postMessage` messages.

Other notable changes include:
* `test-status-choice-group.ts`: moved an `aria-label` which was violating a new `aria-allowed-attrs` rule variant (ARIA 1.2 disallows this attribute on `<span>` elements. Verified this change visually and under NVDA (the component is used both for radio buttons within assisted assessment instance tables and for the initial "pass/fail" radio buttons in manual requirements).
* `webpack.config.js` required a change to work around dequelabs/axe-core#2873
* `get-rule-inclusions.test.ts.snap` enumerates the rule delta with the new version (@iamrafan is putting together fuller change notes that we'll be including with release notes when we release this)

##### Motivation

See 1810733

##### Context

There are a few comments/typing workarounds in `axe-frame-messenger.ts` due to dequelabs/axe-core#2885 not quite making it in time for 4.2.0; we'll need to update to account for that when we pick up [email protected]

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox -->
- [x] Addresses an existing issue: 1810733
- [x] Ran `yarn fastpass`
- [x] Added/updated relevant unit test(s) (and ran `yarn test`)
- [x] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage`
- [x] PR title *AND* final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See `CONTRIBUTING.md`.
- [n/a] (UI changes only) Added screenshots/GIFs to description above
- [x] (UI changes only) Verified usability with NVDA/JAWS

#### Co-authors

Co-authored-by: JGibson2019 <[email protected]>
Co-authored-by: lisli1 <[email protected]>
Co-authored-by: Madalyn <[email protected]>
Copy link
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbjorge should probably also give an approval this before it's merged

doc/frame-messenger.md Outdated Show resolved Hide resolved

If for some reason the frameMessenger fails to open, post, or close you should not throw an error. Axe-core will handle missing results by reporting on them in the `frame-tested` rule. It should not be possible for the `topicHandler` and `replyHandler` callbacks to throw an error. If this happens, please file an issue.

Axe-core has a timeout mechanism built in, which pings frames to see if they respond before instructing them to run. There is no retry behavior in axe-core, which assumes that whatever channel is used is stable. If this isn't the case, this will need to be built into frameMessenger.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timeout is only applicable when using respondable for the messaging and not in frame messenger itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. It's axe-core's engine that does the ping. Respondable doesn't have that. I think I'm going to leave this as is.

@dbjorge
Copy link
Contributor

dbjorge commented Jun 15, 2021

Thanks for the update! It looks like there's still one unaddressed comment (the inconsistency between typings and usage on ReplyHandler), otherwise the updates look good to me

WilcoFiers and others added 2 commits June 16, 2021 10:20
Co-authored-by: Steven Lambert <[email protected]>
Co-authored-by: Dan Bjorge <[email protected]>
@WilcoFiers WilcoFiers requested a review from straker June 16, 2021 08:55
@WilcoFiers WilcoFiers dismissed straker’s stale review June 16, 2021 08:56

I think that's it

@WilcoFiers WilcoFiers merged commit d171583 into develop Jun 17, 2021
@WilcoFiers WilcoFiers deleted the frame-messenger-docs branch June 17, 2021 08:33
WilcoFiers added a commit that referenced this pull request Jun 17, 2021
* docs(frameMessenger): clarify advanced use cases

* chore: address feedback

* Update doc/frame-messenger.md

Co-authored-by: Steven Lambert <[email protected]>

* Update axe.d.ts

Co-authored-by: Dan Bjorge <[email protected]>

Co-authored-by: Steven Lambert <[email protected]>
Co-authored-by: Dan Bjorge <[email protected]>
straker added a commit that referenced this pull request Jun 22, 2021
* docs(frameMessenger): clarify advanced use cases

* chore: address feedback

* Update doc/frame-messenger.md

Co-authored-by: Steven Lambert <[email protected]>

* Update axe.d.ts

Co-authored-by: Dan Bjorge <[email protected]>

Co-authored-by: Steven Lambert <[email protected]>
Co-authored-by: Dan Bjorge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants