-
Notifications
You must be signed in to change notification settings - Fork 779
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
Conversation
doc/frame-messenger.md
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing end of sentence?
doc/frame-messenger.md
Outdated
@@ -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 |
There was a problem hiding this comment.
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
doc/frame-messenger.md
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: frames
-> frame's
doc/frame-messenger.md
Outdated
|
||
open(topicHandler) { | ||
function subscriber(frameWin, data, response) { | ||
const { channelId, message, messageId } = data; |
There was a problem hiding this comment.
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
doc/frame-messenger.md
Outdated
}, | ||
|
||
open(topicHandler) { | ||
function subscriber(frameWin, data, response) { |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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?
There was a problem hiding this 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
#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]>
There was a problem hiding this 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
|
||
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Thanks for the update! It looks like there's still one unaddressed comment (the inconsistency between typings and usage on |
Co-authored-by: Steven Lambert <[email protected]>
Co-authored-by: Dan Bjorge <[email protected]>
* 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]>
* 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]>
Processing some feedback from @dbjorge. Thanks for the thorough review.