summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/mediaelement/test/Spec-CreateRemove.js
blob: 8735efa45ee202afab7bab2a724afb4a976c0a0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
describe("HTMLMediaElement", function() {
  var player;
  var element;
  var domElem;
  var NETWORK_EMPTY = 0, NETWORK_IDLE = 1, NETWORK_LOADING = 2, NETWORK_NO_SOURCE = 3;
  var HAVE_NOTHING = 0, HAVE_METADATA = 1, HAVE_CURRENT_DATA = 2, HAVE_FUTURE_DATA = 3, HAVE_ENOUGH_DATA = 4;
  var METADATA_TIMEOUT = 500, ENOUGH_DATA_TIMEOUT = 1000;

  beforeEach(function() {
  });
  
  afterEach(function() {
  });

  it("should be able to create and remove a player and clean up everything", function() {
    runs(function() {
        $('body').prepend('<video width="640" height="360" id="player1" poster="../media/echo-hereweare.jpg">' +
          '<source type="video/mp4" src="../media/echo-hereweare.mp4" ></source>' +
          '<source type="video/webm" src="../media/echo-hereweare.webm" ></source>' +
            '</video>');
        player = new MediaElementPlayer('#player1', {
          enableAutosize: false,
            success: function(mediaElement, domObject) {
                element = mediaElement;
                domElem = domObject;
            }
        });
    });
    waitsFor(function() {
      return element !== null;
    }, "MediaElement should have loaded", 5000);
    runs(function() {
        expect(element.pluginType).toEqual('native');
        player.remove();
        player = null;
        element = null;
        domElem.parentNode.removeChild(domElem);
        domElem = null;
        // Issue #670: https://github.com/johndyer/mediaelement/issues/670
        expect(mejs.players.length).toEqual(0);

    });
  });

});