mozilla / popcorn-js

The HTML5 Media Framework. (Unmaintained. See https://github.com/menismu/popcorn-js for activity)
MIT License
2.14k stars 632 forks source link

Fixed event not triggered correctly. #457

Open benjah1 opened 9 years ago

benjah1 commented 9 years ago
  1. added logic ensure onFirstPlay -> onFirstPause -> onReady will be trigger.
  2. updated customEvent to latest syntax
  3. updated customEvent bubbles to true. Since some events may bind to different elements

This is for youtube stop working on Chrome on Jul 21. It is fine on Firefox, so a Chrome update may break it.

benjah1 commented 9 years ago

On popcorn.HTMLYouTubeVideoElement.unit.html Before update: 28 fail.

After update,

  1. 7 fail (9, 24, 26, 27, 35, 36, 42)
  2. 5 fail (8, 26, 35, 41, 32)
  3. 7 fail (24, 25, 26, 27, 35, 41, 42) Tested on Chrome 43.0.2357.134 x64
alidinani commented 9 years ago

This is great for fixing chrome However, CustomEvent doesn't exist in IE (well exists but doesnt work) :(

Edit: Fixed by adding a Polyfill for IE

azmenak commented 9 years ago

Which is here:

(function () {
      function CustomEvent ( event, params ) {
        params = params || { bubbles: false, cancelable: false, detail: undefined };
        var evt = document.createEvent( 'CustomEvent' );
        evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
        return evt;
      };

      CustomEvent.prototype = window.Event.prototype;
      window.CustomEvent = CustomEvent;
    })();
benjah1 commented 9 years ago

Added the polyfill. Tested on IE11.

Two concerns,

  1. It injects to global scope. But it is the same for MediaError as well.
  2. During the unit test, events fail to fire occasionally.