Only add Media Sessions Shim if we find a valid video object
AbandonedPublic

Authored by davidedmundson on Jun 19 2018, 7:08 PM.

Details

Reviewers
None
Summary

PBI has two modes for interacting with media + MPRIS, watching the DOM
tree from it's own JS context for normal controls and a massive
workaround for crossing contexts to shim the Media Sessions API for
getting metadata. We currently inject this on every page.

This patch moves that to only be when we find a valid audio/video
element, reducing work and risk of breakages on most sites.

Test Plan

Page that used to fail now works
Still get thumbnails on media sessions test page

Diff Detail

Repository
R856 Plasma Browser Integration
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 131
Build 131: arc lint + arc unit
davidedmundson created this revision.Jun 19 2018, 7:08 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJun 19 2018, 7:08 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson requested review of this revision.Jun 19 2018, 7:08 PM

An idea how to avoid adding a DOM node altogether

extension/content-script.js
419

Does element.dataset.mediaSessionTransfer work?

423

Would it work to dispatchEvent on document.documentElement or document.head?

484

Can we use document.documentElement or document.head here

491

And use the dataset from above here

davidedmundson added inline comments.Jun 19 2018, 8:19 PM
extension/content-script.js
419

even if it did, you still have DOM manipulation on the executeScript function

broulik added inline comments.Jun 20 2018, 8:53 AM
extension/content-script.js
419

Sure but one thing at a time

davidedmundson abandoned this revision.Jun 20 2018, 11:05 AM