Skip to content

Commit

Permalink
Merge pull request #110 from ooyala/pbw-4424
Browse files Browse the repository at this point in the history
[PBW-4424] Supress error code 4 with null or empty string source
  • Loading branch information
aldigun committed Feb 18, 2016
2 parents 2682032 + 75cfcab commit 9f06e0e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/js/main_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,12 @@ require("../../../html5-common/js/utils/environment.js");
*/
var raiseErrorEvent = _.bind(function(event) {
stopUnderflowWatcher();

var code = event.target.error ? event.target.error.code : -1;
this.controller.notify(this.controller.EVENTS.ERROR, { errorcode: code });
// Suppress error code 4 when raised by a video element with a null or empty src
if (!(code === 4 && ($(event.target).attr("src") === "null" || $(event.target).attr("src") === ""))) {
this.controller.notify(this.controller.EVENTS.ERROR, { errorcode: code });
}
}, this);

/**
Expand Down
34 changes: 34 additions & 0 deletions tests/unit/main_html5/wrapper-event-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,40 @@ describe('main_html5 wrapper tests', function () {
expect(vtc.notifyParameters).to.eql([vtc.interface.EVENTS.ERROR, {errorcode: 0}]);
});

it('should not notify ERROR on video \'error\' event with code 4 and empty src', function(){
vtc.interface.EVENTS.ERROR = "error";
$(element).attr("src", "");
target = element;
target.error = { code: 4 };
$(element).triggerHandler({ type:"error", target: target });
expect(vtc.notifyParameters).to.eql([undefined]);
target.error = { code: 2 };
$(element).triggerHandler({ type:"error", target: target });
expect(vtc.notifyParameters).to.eql([vtc.interface.EVENTS.ERROR, {errorcode: 2}]);
$(element).attr("src", "url");
target = element;
target.error = { code: 4 };
$(element).triggerHandler({ type:"error", target: target });
expect(vtc.notifyParameters).to.eql([vtc.interface.EVENTS.ERROR, {errorcode: 4}]);
});

it('should not notify ERROR on video \'error\' event with code 4 and "null" src', function(){
vtc.interface.EVENTS.ERROR = "error";
$(element).attr("src", "null");
target = element;
target.error = { code: 4 };
$(element).triggerHandler({ type:"error", target: target });
expect(vtc.notifyParameters).to.eql([undefined]);
target.error = { code: 2 };
$(element).triggerHandler({ type:"error", target: target });
expect(vtc.notifyParameters).to.eql([vtc.interface.EVENTS.ERROR, {errorcode: 2}]);
$(element).attr("src", "url");
target = element;
target.error = { code: 4 };
$(element).triggerHandler({ type:"error", target: target });
expect(vtc.notifyParameters).to.eql([vtc.interface.EVENTS.ERROR, {errorcode: 4}]);
});

it('should notify STALLED on video \'stalled\' event', function(){
vtc.interface.EVENTS.STALLED = "stalled";
element.currentSrc = "url";
Expand Down

0 comments on commit 9f06e0e

Please sign in to comment.