<table><tr><td style="">broulik created this revision.<br />broulik added reviewers: Plasma, davidedmundson, fvogt, lbeltrame.<br />Restricted Application added a project: Plasma.<br />Restricted Application added a subscriber: plasma-devel.<br />broulik requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D14217">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Don't wait for <tt style="background: #ebebeb; font-size: 13px;">DOMContentLoaded</tt> as <tt style="background: #ebebeb; font-size: 13px;">document.documentElement</tt> is always there (at least as far as HTML is concerned) and a website might dynamically create objects before that</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>We intercept <tt style="background: #ebebeb; font-size: 13px;">document.createElement</tt> so that when a website dynamically creates <tt style="background: #ebebeb; font-size: 13px;">audio</tt> (or <tt style="background: #ebebeb; font-size: 13px;">video</tt>) tags, we know about this. However, the JS environment the website sees is different from the one the content script sees, so we cannot just pass the element around as variable. Instead, we add it to the DOM which is then picked up by the mutation observer. We remove the element immediately afterwards as to not confuse the website.<br />
When the website now dynamically creates an <tt style="background: #ebebeb; font-size: 13px;">audio</tt> element before <tt style="background: #ebebeb; font-size: 13px;">DOMContentLoaded</tt>, our mutation observer isn't installed yet and we miss this event.<br />
Tested the <a href="https://googlechrome.github.io/samples/media-session/audio.html" class="remarkup-link" target="_blank" rel="noreferrer">https://googlechrome.github.io/samples/media-session/audio.html</a> which works fine now</p>

<p>I didn't notice any slowdown caused by this but <a href="https://phabricator.kde.org/p/lbeltrame/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@lbeltrame</a> please test with that heavy website you always use to verify it doesn't cause any problems for you :)</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R856 Plasma Browser Integration</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D14217">https://phabricator.kde.org/D14217</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>extension/content-script.js</div></div></div><br /><div><strong>To: </strong>broulik, Plasma, davidedmundson, fvogt, lbeltrame<br /><strong>Cc: </strong>lbeltrame, plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br /></div>