Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
71476ef9
Commit
71476ef9
authored
Jan 27, 2022
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test to check that annotations are only sent to expected frame
parent
0a1077b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
frame-sync-test.js
src/sidebar/services/test/frame-sync-test.js
+63
-0
No files found.
src/sidebar/services/test/frame-sync-test.js
View file @
71476ef9
...
...
@@ -219,6 +219,69 @@ describe('FrameSyncService', () => {
);
});
it
(
'sends annotations only to matching frame'
,
async
()
=>
{
// Annotation whose URI exactly matches the main frame.
const
mainFrameAnn
=
{
id
:
'abc'
,
uri
:
'https://example.com'
,
};
// Annotation whose URI exactly matches the iframe.
const
iframeAnn
=
{
id
:
'def'
,
uri
:
'https://example.com/iframe'
,
};
// Annotation whose URI doesn't match either frame exactly.
//
// The search API can return such annotations if the annotation's URI
// is deemed equivalent to one of the searched-for URIs.
const
unknownFrameAnn
=
{
id
:
'ghi'
,
uri
:
'https://example.org'
,
};
// Connect two guests, one representing the main frame and one representing
// an iframe.
await
connectGuest
();
await
connectGuest
();
const
mainGuestRPC
=
fakePortRPCs
[
1
];
const
iframeGuestRPC
=
fakePortRPCs
[
2
];
const
frames
=
[];
fakeStore
.
connectFrame
.
callsFake
(
frame
=>
{
frames
.
push
({
id
:
frame
.
id
,
uri
:
frame
.
uri
});
});
fakeStore
.
frames
.
returns
(
frames
);
mainGuestRPC
.
emit
(
'documentInfoChanged'
,
{
frameIdentifier
:
null
,
uri
:
mainFrameAnn
.
uri
,
});
iframeGuestRPC
.
emit
(
'documentInfoChanged'
,
{
frameIdentifier
:
'iframe'
,
uri
:
iframeAnn
.
uri
,
});
fakeStore
.
setState
({
annotations
:
[
mainFrameAnn
,
iframeAnn
,
unknownFrameAnn
],
});
// Check that expected annotations were sent to each frame.
assert
.
calledWithMatch
(
mainGuestRPC
.
call
,
'loadAnnotations'
,
sinon
.
match
([
formatAnnot
(
mainFrameAnn
),
formatAnnot
(
unknownFrameAnn
)])
);
assert
.
calledWithMatch
(
iframeGuestRPC
.
call
,
'loadAnnotations'
,
sinon
.
match
([
formatAnnot
(
iframeAnn
)])
);
});
it
(
'sends a "loadAnnotations" message only for new annotations'
,
async
()
=>
{
const
frameInfo
=
fixtures
.
htmlDocumentInfo
;
await
connectGuest
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment