-
Notifications
You must be signed in to change notification settings - Fork 17
feat(coil-extension): add iframes impl #415
Conversation
@@ -31,5 +31,5 @@ | |||
"run_at": "document_start" | |||
} | |||
], | |||
"permissions": [ "activeTab", "storage", "notifications", "tabs", "<all_urls>" ] | |||
"permissions": [ "webNavigation", "activeTab", "storage", "notifications", "tabs", "<all_urls>" ] |
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 is going to require extra permissions
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.
Nothing more revealing (in terms of privacy) than what we already require but it could be off-putting to some users.
packages/coil-extension/src/background/services/BackgroundScript.ts
Outdated
Show resolved
Hide resolved
a83c0b2
to
07757e4
Compare
4632882
to
9daaacb
Compare
d493a34
to
3f74682
Compare
this.runtime.sendMessage(message, resolve) | ||
}) | ||
if (!allowed) { | ||
console.error( |
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.
It might be nicer to log the actual element from the parent frame content script
b9cc3e6
to
dc408a9
Compare
packages/coil-extension/src/background/services/BackgroundFramesService.ts
Outdated
Show resolved
Hide resolved
@@ -4,7 +4,7 @@ jobs: | |||
# Run Linting | |||
lint-all: | |||
docker: | |||
- image: circleci/node:12.14.1-buster-browsers | |||
- image: circleci/node:12.16.1-buster-browsers |
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.
Just hail Mary attempts at fixing some tests that fail on CI and not locally on my dev machine.
This reverts commit 6da1a6a.
4aa5fc6
to
2dcd3ac
Compare
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.
Have tried it out and it looks good! I think we should merge this and roll out a v47 with this and the tipping beta. The one issue I noticed is that mutating the allow attribute of an iframe doesn't get picked up by the extension, but we can always fix that at a later time if we decide that's supported
This pull request implements Web Monetization inside <iframe> elements. Only iframes that are direct children of the top frame, with monetization in their
allow
feature set policy will be monetized.It does this by changing the 1:1 mapping of WM streams to browser tabs to M:1, with the 1:1 mapping now of WM streams to iframes.
To do so, it takes advantage of:
frameChanged
event where using chrome.tabs.onUpdated before (which was problematic)Messages sent using
chrome.runtime.sendMessage
api from content scriptswill be recieved in the background script onMessage listener with
tabId/frameId implied (i.e. not inside the message payload).
Whenever a monetization request occurs inside an iframe (that is only one level deep), a request will be sent to the background page to check if that iframe is allowed.
The request handler in the background page consults the BackgroundFramesService to determine the parent frame of the sender (currently always 0) then sends a message to the associated content script via
tabs.sendMessage(tabId, msg, {frameId: parentId})
. Themsg
contains the{tabId, frameId}
monetization is requested from.Promise<{tabId, frameId}>
is maintained as well as a promise queue via a Map of correlationId to promise resolver.await
ing each promise in turn. The promise result frame is checked against the search element frame.<iframe>
s in the page that have no promise queued already are sent a correlationId viaframe.contentWindow!.postMessage
message
eventQuestions:
Should we limit the amount of concurrently monetized frames ?
Do we need to do anything special client side to adjust bandwidth? Or will the server do it all ?
Should we allow arbitrarily nested iframes to monetize as long as long as all iframes in the iframe hierarchy have specified allow="monetization" ?
What does the text in the popup mean now that 'content' could refer to inner frames as well as the top page ?
Should there be some kind of 'in-page' indication that an iframe is being monetized ? (@fruehle offhand suggested maybe some kind of WM logo watermark)
MacOS Chrome 80.0.3987.132 (Official Build) (64-bit)
Build for prod with release settings
yarn build-prod chrome -p --run-prod --devtool=none
Import unpacked/temporary extension/add-on
about:debugging
chrome://extensions
(oredge://extensions
) andLoad Unpacked
Ensure that you are logged in with a user with valid subscription
example.com should say "This website is not supported"
xrpcommunity.blog should monetize
twitch.tv works
monetized youtube video
Coil welcome and welcome to explore pages
Start Exploring
with a rocket-ship graphicCheck the monetization animation works properly
tab loses focus so can use something like this in terminal:
sudo sleep 10 && sudo ifconfig en0 down && sleep 10 && sudo ifconfig en0 up
Check monetization works consistently
Will route to $coildomain.com/login rather than open popup if logged out
Popup icon should show if page is monetized even when logged out
Run the puppeteer tests (look at the circle jobs)
Go to a youtube video,
manually skip to near end of video, and when autoplay of a video from
another channel starts, check that monetization has stopped.
Go to xrpcommunity.blog and as page
is loading very quickly open the popup.
It should show "This page is Web-Monetized" even before streaming
starts. Should show 'setting up payment' then 'coil is paying creator'
#120
Open the reloading-every-15s.html file:
python -m http.server 4000
)Reloading page
logging#144
Open the event-logger.html file:
Use a localhost server so WM works (e.g. with
python -m http.server 4000
)Look for unusual timings, check that pending state is emitted nearly
immediately after page load or meta tag added
Issue: #63
Fix PR: #69
Check started event fires when quickly switching between tabs
Check stopped event fires with correct requestId
Run a local web server (e.g. with
python -m http.server 4000
) servingthe dist folder, then open static/popup.html in a
normal tab and check the popup rendering in various states.
On MacOS Chromium browsers (Chrome/Edge) check that the monetized animation is working
on non primary monitors.
Check that popup closes when another window is focused
Open two Browser windows, open the popup in one window
Focus on second window
Ensure that popup is closed
Issue: #313
Fix PR: #332
Check SPA apps keep streaming when url changed, meta stays
Go to e.g. https://www.wevolver.com/
Change other pages which uses HTML5 history.pushState
Check that streaming is maintained throughout
document.head.querySelector('meta[name="monetization"]')
Issue: #507
Fix PR: #508