Bug 1273725 - Don't show 'No supported source' message in video controls if there's no sources. r?jaws
We're flashing a warning message "NO video with supported format and MIME type
found." when we're loading a YouTube page in Fennec. This is because YouTube
are calling load() on a video element with no src attribute or source children
in a click handler in order to defeat the "requires user interaction to play"
restrictions on mobile Chrome and Safari in that video element.
We're showing the warning message to help developers diagnose why loads are
unintentionally failing. However, the behaviour that YouTube are doing is
intentional, and YouTube are likely to not be the only ones doing this. So we
should change our video controls to not display the warning message in this
case. We should be compatible with other browsers.
We'll still log a debug message to the browser console as to why the load
is failing, to help developers who hit this unintentionally.
MozReview-Commit-ID: IpugbMOloJt
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -654,17 +654,41 @@
}
delete this.controlListeners;
this.log("--- videocontrols terminated ---");
},
hasError : function () {
- return (this.video.error != null || this.video.networkState == this.video.NETWORK_NO_SOURCE);
+ // We either have an explicit error, or the resource selection
+ // algorithm is running and we've tried to load something and failed.
+ // Note: we don't consider the case where we've tried to load but
+ // there's no sources to load as an error condition, as sites may
+ // do this intentionally to work around requires-user-interaction to
+ // play restrictions, and we don't want to display a debug message
+ // if that's the case.
+ return this.video.error != null ||
+ (this.video.networkState == this.video.NETWORK_NO_SOURCE &&
+ this.hasSources());
+ },
+
+ hasSources : function() {
+ if (this.video.hasAttribute('src') &&
+ this.video.getAttribute('src') !== "") {
+ return true;
+ }
+ for (var child = this.video.firstChild;
+ child !== null;
+ child = child.nextElementSibling) {
+ if (child instanceof HTMLSourceElement) {
+ return true;
+ }
+ }
+ return false;
},
updateErrorText : function () {
let error;
let v = this.video;
// It is possible to have both v.networkState == NETWORK_NO_SOURCE
// as well as v.error being non-null. In this case, we will show
// the v.error.code instead of the v.networkState error.