Remove unused code calling WebMediaPlayerClient::requestFullscreen()
[chromium-blink-merge.git] / content / test / data / media / webui / player_info_test.html
blob1833453148dc07dd7f9a8c6c570e02ed2111d093
1 <!--
2 Copyright 2013 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <!DOCTYPE html>
7 <html>
8 <body>
9 <script>
10 window.chrome = {};
12 window.setUp = function() {
13 window.pi = new PlayerInfo('example_id');
16 window.tearDown = function() {
17 window.pi = null;
20 // Test that an ID is set correctly.
21 window.testConstructorStringID = function() {
22 assertEquals('example_id', window.pi.id);
25 // Test that numerical IDs are valid.
26 window.testConstructorNumberId = function() {
27 var pi = new PlayerInfo(5);
28 assertEquals(5, pi.id);
31 // Make sure that a new PlayerInfo has no events.
32 window.testEmptyEvents = function() {
33 assertEquals(0, window.pi.allEvents.length);
36 // Check that the most recent property gets updated.
37 window.testAddProperty = function() {
38 var key = 'key',
39 value = 'value',
40 value2 = 'value2';
42 window.pi.addProperty(0, key, value);
43 assertEquals(value, window.pi.properties[key]);
45 window.pi.addProperty(0, key, value2);
46 assertEquals(value2, window.pi.properties[key]);
50 // Make sure that the first timestamp that gets sent
51 // is recorded as the base timestamp.
52 window.testFirstTimestamp = function() {
53 var pi = new PlayerInfo('example_ID');
54 var timestamp = 5000;
55 pi.addProperty(timestamp, 'key', 'value');
57 assertEquals(timestamp, pi.firstTimestamp_);
60 // Adding a property with a non-string key should
61 // throw an exception.
62 window.testWrongKeyType = function() {
63 var pi = new PlayerInfo('example_ID');
64 assertThrows(function() {
65 pi.addProperty(0, 5, 'some value');
66 });
69 // Subsequent events should have their log offset based
70 // on the first timestamp added.
71 window.testAddPropertyTimestampOffset = function() {
72 var firstTimestamp = 500,
73 secondTimestamp = 550,
74 deltaT = secondTimestamp - firstTimestamp,
75 key = 'key',
76 value = 'value';
78 var pi = new PlayerInfo('example_ID');
79 pi.addProperty(firstTimestamp, key, value);
80 pi.addProperty(secondTimestamp, key, value);
82 assertEquals(firstTimestamp, pi.firstTimestamp_);
83 assertEquals(0, pi.allEvents[0].time);
84 assertEquals(deltaT, pi.allEvents[1].time);
86 assertTrue(undefined !== pi.pastValues[key]);
88 console.log(pi.pastValues);
90 assertEquals(0, pi.pastValues[key][0].time);
91 assertEquals(deltaT, pi.pastValues[key][1].time);
94 // Check to make sure that properties are correctly
95 // added to the relevant pastValues array.
96 window.testAddPropertyPastValues = function() {
97 var pi = new PlayerInfo('example_ID'),
98 timestamp = 50,
99 key = 'key',
100 value = 'value';
102 pi.addProperty(timestamp, key, value);
104 assertEquals(value, pi.pastValues[key][0].value);
105 assertEquals(key, pi.pastValues[key][0].key);
106 assertEquals(0, pi.pastValues[key][0].time);
109 // The list of all events should be recorded in correctly.
110 window.testAllEvents = function() {
111 var pi = new PlayerInfo('example_ID'),
112 timestamp = 50,
113 key = 'key',
114 value = 'value',
115 key2 = 'key2',
116 value2 = 'value2';
118 pi.addProperty(timestamp, key, value);
119 assertEquals(value, pi.allEvents[0].value);
120 assertEquals(key, pi.allEvents[0].key);
122 pi.addProperty(timestamp, key2, value2);
123 assertEquals(value2, pi.allEvents[1].value);
124 assertEquals(key2, pi.allEvents[1].key);
127 // Using noRecord should make it not show up in allEvents,
128 // but it should still show up in pastValues[key].
129 window.testNoRecord = function() {
130 var pi = new PlayerInfo('example_ID'),
131 timestamp = 50,
132 key = 'key',
133 value = 'value';
134 pi.addPropertyNoRecord(timestamp, key, value);
136 assertEquals(value, pi.properties[key]);
137 assertEquals(0, pi.allEvents.length);
138 assertEquals(1, pi.pastValues[key].length);
140 </script>
141 </body>
142 </html>