-
-
Notifications
You must be signed in to change notification settings - Fork 939
web: Polyfill document.embeds to return ruffle-embeds too #22449
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
Open
danielhjacobs
wants to merge
4
commits into
ruffle-rs:master
Choose a base branch
from
danielhjacobs:polyfill-document-embeds
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−0
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e407d3e
web: Polyfill document.embeds to return ruffle-embeds too
danielhjacobs 776d404
web: Add test for document.embeds
danielhjacobs 598d8f0
web: For document embeds test, use asserts instead of DOM appending
danielhjacobs 59263f6
web: Use Proxy instead of fake HTMLCollection for document.embeds
danielhjacobs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
web/packages/selfhosted/test/polyfill/document_embeds/expected.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <li>There are 3 embeds for document.embeds</li> | ||
| <li>There are 2 embeds for document.embeds</li> | ||
16 changes: 16 additions & 0 deletions
16
web/packages/selfhosted/test/polyfill/document_embeds/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>DOCUMENT EMBEDS</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="test-container"> | ||
| <embed id="emb1" name="fl" src="/test_assets/example.swf" width="200" height="200"></embed> | ||
| <embed id="emb2" name="fl" src="/test_assets/example.swf" width="200" height="200"></embed> | ||
| <embed id="emb3" name="fl" src="/test_assets/example.swf" width="200" height="200"></embed> | ||
| </div> | ||
| <ul id="output"></ul> | ||
| </body> | ||
| </html> |
55 changes: 55 additions & 0 deletions
55
web/packages/selfhosted/test/polyfill/document_embeds/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { injectRuffleAndWait, openTest, playAndMonitor } from "../../utils.js"; | ||
| import { use, expect } from "chai"; | ||
| import chaiHtml from "chai-html"; | ||
| import fs from "fs"; | ||
|
|
||
| use(chaiHtml); | ||
|
|
||
| describe("Document embeds", () => { | ||
| it("loads the test", async () => { | ||
| await openTest(browser, `polyfill/document_embeds`); | ||
| }); | ||
|
|
||
| it("Accesses the right number of elements with ruffle", async () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: other cases start with a lowercase letter |
||
| await injectRuffleAndWait(browser); | ||
| await playAndMonitor( | ||
| browser, | ||
| await browser.$("#test-container").$("ruffle-embed#emb1"), | ||
| ); | ||
| await playAndMonitor( | ||
| browser, | ||
| await browser.$("#test-container").$("ruffle-embed#emb2"), | ||
| ); | ||
| await playAndMonitor( | ||
| browser, | ||
| await browser.$("#test-container").$("ruffle-embed#emb3"), | ||
| ); | ||
|
Comment on lines
+30
to
+41
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are those needed? Even with autoplay disabled embeds should work, right? |
||
| await browser.execute(() => { | ||
| function countDocumentEmbeds() { | ||
| const output = document.getElementById("output"); | ||
| const els = document.embeds; | ||
| const len = document.createElement("li"); | ||
| if (els && "length" in els && els.length) { | ||
| len.textContent = `There are ${els.length} embeds for document.embeds`; | ||
| } | ||
|
|
||
| output?.appendChild(len); | ||
| } | ||
|
|
||
| countDocumentEmbeds(); | ||
| const emb1 = document.getElementById("emb1"); | ||
| if (emb1) { | ||
| emb1.remove(); | ||
| } | ||
| countDocumentEmbeds(); | ||
| }); | ||
| const actual = await browser | ||
| .$("#output") | ||
| .getHTML({ includeSelectorTag: false, pierceShadowRoot: false }); | ||
| const expected = fs.readFileSync( | ||
| `${import.meta.dirname}/expected.html`, | ||
| "utf8", | ||
| ); | ||
| expect(actual).html.to.equal(expected); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.