Skip to content

Commit

Permalink
Add cross-origin annotatable iframe dev server scenario
Browse files Browse the repository at this point in the history
The current inter-frame communication doesn't work if an annotatable
(guest) iframe is from a different origin than the host frame (see
#3611 (comment)). This
will be fixed in a more comprehensive overhaul of the inter-face
communication (see #3533).

Meanwhile, I add a scenario into the local dev server where the
annotatable iframe is from an origin different than the host frame. For
this, I needed to spawn an additional dev server at port 3002):

```
[11:32:50] Dev web server started at http://localhost:3000/
[11:32:50] Dev web server started at http://localhost:3002/
```

Close #3629
  • Loading branch information
esanzgar committed Sep 7, 2021
1 parent c91cbf0 commit 939ade8
Show file tree
Hide file tree
Showing 4 changed files with 1,581 additions and 0 deletions.
35 changes: 35 additions & 0 deletions dev-server/documents/html/cross-origin-iframe.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Cross-origin guest iframe</title>
<style>
body {
font-family: sans-serif;
}
iframe {
width: 75%;
height: 300px;
resize: both;
overflow: auto;
}
</style>

</head>
<body>
<h1>Cross-origin guest iframe</h1>
<p>
The cross-origin iframe below should behave like a normal guest iframe. It should
be possible to select text and add annotations.
</p>
<iframe></iframe>
<script>
// Set a different port for the iframe `src` property to make it cross-origin.
let port = new URL(document.location).port === '3000' ? '3002' : '3000';
let url = '//localhost:' + port + '/document/doyle-embedded';
document.querySelector('iframe').setAttribute('src', url);
</script>
{{{hypothesisScript}}}
</body>
</html>
Loading

0 comments on commit 939ade8

Please sign in to comment.