forked from w3c/encrypted-media
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencrypted-media.js
496 lines (419 loc) · 28.5 KB
/
encrypted-media.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
(function() {
var EME_spec_url = "http://www.w3.org/TR/encrypted-media/";
var HTML_spec_url = "http://www.w3.org/TR/html5/embedded-content-0.html";
var DOM_spec_url = "https://dom.spec.whatwg.org/";
var IDL_spec_url = "https://heycam.github.io/webidl/";
function url_helper(doc, url) {
if (url[0] == "#" && doc.emeDefGroupName != window.respecConfig.emeDefGroupName) {
return groupBaseURLs[doc.emeDefGroupName] + url;
}
return url;
}
function eventdfn_helper(doc, df, id, text) {
df.appendChild($("<dfn/>").attr({id: 'dom-evt-' + text.toLowerCase()}).wrapInner($("<code/>").text(text))[0]);
}
function idlref_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: url_helper(doc, "#" + id)}).text(text))[0]);
}
function eventref_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: url_helper(doc, "#dom-evt-" + id)}).text(text))[0]);
}
function videoref_helper(doc, df, id, text) {
link_helper(doc, df, HTML_spec_url + '#' + id, text);
}
function code_videoref_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: HTML_spec_url + "#" + id}).text(text))[0]);
}
function encodingapi_helper(doc, df, id, text) {
link_helper(doc, df, 'http://www.w3.org/TR/encoding/#' + id, text);
}
function webappapis_helper(doc, df, id, text) {
link_helper(doc, df, 'http://www.w3.org/TR/html5/webappapis.html#' + id, text);
}
function infrastructure_helper(doc, df, id, text) {
link_helper(doc, df, 'http://www.w3.org/TR/html5/infrastructure.html#' + id, text);
}
function browsers_helper(doc, df, id, text) {
link_helper(doc, df, 'http://www.w3.org/TR/html5/browsers.html#' + id, text);
}
function mixedcontent_helper(doc, df, id, text) {
link_helper(doc, df, 'http://www.w3.org/TR/mixed-content/#' + id, text);
}
function term_helper(doc, df, id, text) {
link_helper(doc, df, url_helper(doc, '#' + id), text);
}
function var_helper(doc, df, id, text) {
df.appendChild($("<var/>").wrapInner($("<a/>").attr({href: url_helper(doc, id)}).text(text))[0]);
}
function link_helper(doc, df, id, text) {
df.appendChild($("<a/>").attr({href: url_helper(doc, id)}).text(text)[0]);
}
function dom_helper(doc, df, id, text) {
link_helper(doc, df, DOM_spec_url + '#' + id, text);
}
function code_dom_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: DOM_spec_url + "#" + id}).text(text))[0]);
}
function webidl_helper(doc, df, id, text) {
link_helper(doc, df, IDL_spec_url + '#' + id, text);
}
function code_webidl_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: IDL_spec_url + "#" + id}).text(text))[0]);
}
function domexception_helper(doc, df, id) {
code_webidl_helper(doc, df, 'dfn-DOMException', "DOMException");
}
function new_domexception_helper(doc, df, id) {
df.appendChild(doc.createTextNode('a new '));
domexception_helper(doc, df, id)
df.appendChild(doc.createTextNode(' whose name is'));
}
function exception_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: DOM_spec_url + '#dom-domexception-' + id}).text(text))[0]);
}
function local_exception_helper(doc, df, id, text) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: url_helper(doc, "#dfn-" + text)}).text(text))[0]);
}
function appropriate_error_name_helper(doc, df, id, text) {
df.appendChild(doc.createTextNode('the appropriate '));
term_helper(doc, df, 'error-names', 'error name');
}
function webmref_helper(doc, df, id, text) {
link_helper(doc, df, 'http://www.webmproject.org/code/specs/container/#' + id, text);
}
function queue_and_fire_helper(doc, df, id, text) {
webappapis_helper(doc, df, 'queue-a-task', text);
df.appendChild(doc.createTextNode(' to '));
webappapis_helper(doc, df, 'fire-a-simple-event', 'fire a simple event');
df.appendChild(doc.createTextNode(' named'));
}
function queue_and_fire_track_event_helper(doc, df, id, text) {
webappapis_helper(doc, df, 'queue-a-task', 'Queue a task');
df.appendChild(doc.createTextNode(' to fire a '));
infrastructure_helper(doc, df, 'concept-events-trusted', 'trusted event');
df.appendChild(doc.createTextNode(' named '));
code_videoref_helper(doc, df, 'handler-tracklist-on' + text, text);
df.appendChild(doc.createTextNode(', that does not bubble and is not cancelable, and that uses the '));
code_videoref_helper(doc, df, 'trackevent', 'TrackEvent');
df.appendChild(doc.createTextNode(' interface,'));
}
function queue_and_run_helper(doc, df, id, text) {
webappapis_helper(doc, df, 'queue-a-task', text);
df.appendChild(doc.createTextNode(' to run the'));
}
function fragment_helper(doc, df, id, text) {
var f = doc.createElement('span')
f.innerHTML = text;
df.appendChild(f);
}
function contributors_helper(doc, df, id, text) {
var contributors = window.respecConfig.emeContributors;
contributors.sort();
var str = "";
for (var i = 0; i < contributors.length - 1; ++i) {
if (i > 0)
str += ", ";
str += contributors[i];
}
str += ", and ";
str += contributors[contributors.length - 1];
df.appendChild(doc.createTextNode(str));
}
var emeDefinitions = {
'cdm': { func: term_helper, fragment: 'cdm', link_text: 'CDM' },
'keysystem': { func: term_helper, fragment: 'key-system', link_text: 'Key System' },
'keysystems': { func: term_helper, fragment: 'key-system', link_text: 'Key Systems' },
'key-id': { func: term_helper, fragment: 'decryption-key-id', link_text: 'key ID' },
'initialization-data': { func: term_helper, fragment: 'initialization-data', link_text: 'Initialization Data' },
'initialization-data-type': { func: term_helper, fragment: 'initialization-data-type', link_text: 'Initialization Data Type' },
'session-id': { func: term_helper, fragment: 'session-id', link_text: 'Session ID' },
'distinctive-identifier': { func: term_helper, fragment: 'distinctive-identifier', link_text: 'Distinctive Identifier' },
'distinctive-identifiers': { func: term_helper, fragment: 'distinctive-identifier', link_text: 'Distinctive Identifiers' },
'requestMediaKeySystemAccess': { func: idlref_helper, fragment: 'widl-Navigator-requestMediaKeySystemAccess-Promise-MediaKeySystemAccess--DOMString-keySystem-sequence-MediaKeySystemConfiguration--supportedConfigurations', link_text: 'requestMediaKeySystemAccess()', },
'requestMediaKeySystemAccess-call': { func: idlref_helper, fragment: 'widl-Navigator-requestMediaKeySystemAccess-Promise-MediaKeySystemAccess--DOMString-keySystem-sequence-MediaKeySystemConfiguration--supportedConfigurations', link_text: 'requestMediaKeySystemAccess', },
'get-supported-configuration-algorithm': { func: term_helper, fragment: 'get-supported-configuration', link_text: 'Get Supported Configuration', },
'get-supported-capabilities-for-media-type-algorithm': { func: term_helper, fragment: 'get-supported-capabilities-for-media-type', link_text: 'Get Supported Capabilities for Media Type', },
'requirement-required': { func: idlref_helper, fragment: 'idl-def-MediaKeysRequirement.required', link_text: '"required"', },
'requirement-optional': { func: idlref_helper, fragment: 'idl-def-MediaKeysRequirement.optional', link_text: '"optional"', },
'requirement-not-allowed': { func: idlref_helper, fragment: 'idl-def-MediaKeysRequirement.not-allowed', link_text: '"not-allowed"', },
'option-initDataTypes': { func: idlref_helper, fragment: 'widl-MediaKeySystemConfiguration-initDataTypes', link_text: 'initDataTypes', },
'option-audioCapabilities': { func: idlref_helper, fragment: 'widl-MediaKeySystemConfiguration-audioCapabilities', link_text: 'audioCapabilities', },
'option-videoCapabilities': { func: idlref_helper, fragment: 'widl-MediaKeySystemConfiguration-videoCapabilities', link_text: 'videoCapabilities', },
'option-persistentState': { func: idlref_helper, fragment: 'widl-MediaKeySystemConfiguration-persistentState', link_text: 'persistentState', },
'option-distinctiveIdentifier': { func: idlref_helper, fragment: 'widl-MediaKeySystemConfiguration-distinctiveIdentifier', link_text: 'distinctiveIdentifier', },
'capability-contentType' : { func: idlref_helper, fragment: 'widl-MediaKeySystemMediaCapability-contentType', link_text: 'contentType', },
'capability-robustness' : { func: idlref_helper, fragment: 'widl-MediaKeySystemMediaCapability-robustness', link_text: 'robustness', },
'keySystem-attribute': { func: idlref_helper, fragment: 'widl-MediaKeySystemAccess-keySystem', link_text: 'keySystem', },
'getConfiguration': { func: idlref_helper, fragment: 'widl-MediaKeySystemAccess-getConfiguration-MediaKeySystemConfiguration', link_text: 'getConfiguration()', },
// 'createMediaKeys': { func: idlref_helper, fragment: 'widl-MediaKeySystemAccess-createMediaKeys-Promise-MediaKeys', link_text: 'createMediaKeys()', },
'createMediaKeys-call': { func: idlref_helper, fragment: 'widl-MediaKeySystemAccess-createMediaKeys-Promise-MediaKeys', link_text: 'createMediaKeys', },
'temporary-session': { func: idlref_helper, fragment: 'idl-def-MediaKeySessionType.temporary', link_text: '"temporary"', },
'persistent-license-session': { func: idlref_helper, fragment: 'idl-def-MediaKeySessionType.persistent-license', link_text: '"persistent-license"', },
'persistent-release-message-session': { func: idlref_helper, fragment: 'idl-def-MediaKeySessionType.persistent-release-message', link_text: '"persistent-release-message"', },
'createSession-call': { func: idlref_helper, fragment: 'widl-MediaKeys-createSession-MediaKeySession-MediaKeySessionType-sessionType', link_text: 'createSession', },
'setServerCertificate': { func: idlref_helper, fragment: 'widl-MediaKeys-setServerCertificate-Promise-void--BufferSource-serverCertificate', link_text: 'setServerCertificate()', },
'setServerCertificate-call': { func: idlref_helper, fragment: 'widl-MediaKeys-setServerCertificate-Promise-void--BufferSource-serverCertificate', link_text: 'setServerCertificate', },
'sessionId': { func: idlref_helper, fragment: 'widl-MediaKeySession-sessionId', link_text: 'sessionId', },
'expiration': { func: idlref_helper, fragment: 'widl-MediaKeySession-expiration', link_text: 'expiration', },
'closed': { func: idlref_helper, fragment: 'widl-MediaKeySession-closed', link_text: 'closed', },
'keyStatuses': { func: idlref_helper, fragment: 'widl-MediaKeySession-keyStatuses', link_text: 'keyStatuses', },
'generateRequest': { func: idlref_helper, fragment: 'widl-MediaKeySession-generateRequest-Promise-void--DOMString-initDataType-BufferSource-initData', link_text: 'generateRequest()', },
'generateRequest-call': { func: idlref_helper, fragment: 'widl-MediaKeySession-generateRequest-Promise-void--DOMString-initDataType-BufferSource-initData', link_text: 'generateRequest', },
'load': { func: idlref_helper, fragment: 'widl-MediaKeySession-load-Promise-boolean--DOMString-sessionId', link_text: 'load()', },
'load-call': { func: idlref_helper, fragment: 'widl-MediaKeySession-load-Promise-boolean--DOMString-sessionId', link_text: 'load', },
'update': { func: idlref_helper, fragment: 'widl-MediaKeySession-update-Promise-void--BufferSource-response', link_text: 'update()', },
'update-call': { func: idlref_helper, fragment: 'widl-MediaKeySession-update-Promise-void--BufferSource-response', link_text: 'update', },
'close': { func: idlref_helper, fragment: 'widl-MediaKeySession-close-Promise-void', link_text: 'close()', },
'close-call': { func: idlref_helper, fragment: 'widl-MediaKeySession-close-Promise-void', link_text: 'close', },
'remove': { func: idlref_helper, fragment: 'widl-MediaKeySession-remove-Promise-void', link_text: 'remove()', },
'remove-call': { func: idlref_helper, fragment: 'widl-MediaKeySession-remove-Promise-void', link_text: 'remove', },
'status-usable': { func: idlref_helper, fragment: 'idl-def-MediaKeyStatus.usable', link_text: '"usable"', },
'status-expired': { func: idlref_helper, fragment: 'idl-def-MediaKeyStatus.expired', link_text: '"expired"', },
'queue-message-algorithm': { func: term_helper, fragment: 'queue-message', link_text: 'queue a "message" event', },
'session-close-algorithm': { func: term_helper, fragment: 'session-close', link_text: 'session close', },
'encrypted-block-encountered-algorithm': { func: term_helper, fragment: 'encrypted-block-encountered', link_text: 'encrypted block encountered', },
'update-key-statuses-algorithm': { func: term_helper, fragment: 'update-key-statuses', link_text: 'update key statuses', },
'update-expiration-algorithm': { func: term_helper, fragment: 'update-expiration', link_text: 'update expiration', },
'resume-playback-algorithm': { func: term_helper, fragment: 'resume-playback', link_text: 'attempt to resume playback if necessary', },
'queue-waiting-algorithm': { func: term_helper, fragment: 'queue-waiting', link_text: 'queue a "waiting" event', },
'session-storage': { func: term_helper, fragment: 'session-storage', link_text: 'Session Storage and Persistence', },
'MediaWaitingFor-none': { func: idlref_helper, fragment: 'idl-def-MediaWaitingFor.none', link_text: '"none"', },
'MediaWaitingFor-key': { func: idlref_helper, fragment: 'idl-def-MediaWaitingFor.key', link_text: '"key"', },
'MediaWaitingFor-data': { func: idlref_helper, fragment: 'idl-def-MediaWaitingFor.data', link_text: '"data"', },
'mediaKeys-attribute': { func: idlref_helper, fragment: 'widl-HTMLMediaElement-mediaKeys', link_text: 'mediaKeys', },
'waitingFor': { func: idlref_helper, fragment: 'widl-HTMLMediaElement-waitingFor', link_text: 'waitingFor', },
'onencrypted': { func: idlref_helper, fragment: 'widl-HTMLMediaElement-onencrypted', link_text: 'onencrypted', },
'setMediaKeys': { func: idlref_helper, fragment: 'widl-HTMLMediaElement-setMediaKeys-Promise-void--MediaKeys-mediaKeys', link_text: 'setMediaKeys()', },
'setMediaKeys-call': { func: idlref_helper, fragment: 'widl-HTMLMediaElement-setMediaKeys-Promise-void--MediaKeys-mediaKeys', link_text: 'setMediaKeys', },
'keyschange': { func: eventref_helper, fragment: 'keyschange', link_text: 'keyschange', },
'message': { func: eventref_helper, fragment: 'message', link_text: 'message', },
'encrypted': { func: eventref_helper, fragment: 'encrypted', link_text: 'encrypted', },
'message-type-license-request': { func: idlref_helper, fragment: 'idl-def-MediaKeyMessageType.license-request', link_text: '"license-request"', },
'message-type-license-renewal': { func: idlref_helper, fragment: 'idl-def-MediaKeyMessageType.license-renewal', link_text: '"license-renewal"', },
'message-event-messagetype-attribute': { func: idlref_helper, fragment: 'widl-MediaKeyMessageEvent-messageType', link_text: 'messageType', },
'message-event-message-attribute': { func: idlref_helper, fragment: 'widl-MediaKeyMessageEvent-message', link_text: 'message', },
'encrypted-event-initdatatype-attribute': { func: idlref_helper, fragment: 'widl-MediaEncryptedEventInit-initDataType', link_text: 'initDataType', },
'encrypted-event-initdata-attribute': { func: idlref_helper, fragment: 'widl-MediaEncryptedEventInit-initData', link_text: 'initData', },
'NotSupportedError': { func: local_exception_helper, fragment: '', link_text: 'NotSupportedError' },
'InvalidStateError': { func: local_exception_helper, fragment: '', link_text: 'InvalidStateError' },
'InvalidAccessError': { func: local_exception_helper, fragment: '', link_text: 'InvalidAccessError' },
'QuotaExceededError': { func: local_exception_helper, fragment: '', link_text: 'QuotaExceededError' },
'appropriate-error-name': { func: appropriate_error_name_helper, fragment: '', },
'interface-textdecoder': { func: encodingapi_helper, fragment: 'interface-textdecoder', link_text: 'TextDecoder interface', },
'interface-textencoder': { func: encodingapi_helper, fragment: 'interface-textencoder', link_text: 'TextEncoder interface', },
'eventdfn': { func: eventdfn_helper, fragment: '', link_text: '', },
'event': { func: code_dom_helper, fragment: 'event', link_text: 'Event', },
'videoref': { func: videoref_helper, fragment: '', link_text: '', },
// 'media-element-load-algorithm': { func: videoref_helper, fragment: 'media-element-load-algorithm', link_text: 'media element load', },
'resource-fetch-algorithm': { func: videoref_helper, fragment: 'concept-media-load-resource', link_text: 'resource fetch', },
'current-playback-position': { func: videoref_helper, fragment: 'current-playback-position', link_text: 'current playback position', },
'media-data': { func: videoref_helper, fragment: 'media-data', link_text: 'media data', },
'media-resource': { func: videoref_helper, fragment: 'media-resource', link_text: 'media resource', },
'current-playback-position': { func: videoref_helper, fragment: 'current-playback-position', link_text: 'current playback position', },
'direction-of-playback': { func: videoref_helper, fragment: 'direction-of-playback', link_text: 'direction of playback', },
'media-element-decode-error': { func: videoref_helper, fragment: 'dom-mediaerror-media_err_decode', link_text: 'MEDIA_ERR_DECODE', },
'media-crossorigin': { func: code_videoref_helper, fragment: 'attr-media-crossorigin', link_text: 'crossorigin', },
'media-src': { func: code_videoref_helper, fragment: 'attr-media-src', link_text: 'src', },
'readystate': { func: code_videoref_helper, fragment: 'dom-media-readystate', link_text: 'readyState', },
// 'have-nothing': { func: code_videoref_helper, fragment: 'dom-media-have_nothing', link_text: 'HAVE_NOTHING', },
'have-metadata': { func: code_videoref_helper, fragment: 'dom-media-have_metadata', link_text: 'HAVE_METADATA', },
// 'have-current-data': { func: code_videoref_helper, fragment: 'dom-media-have_current_data', link_text: 'HAVE_CURRENT_DATA', },
// 'have-future-data': { func: code_videoref_helper, fragment: 'dom-media-have_future_data', link_text: 'HAVE_FUTURE_DATA', },
// 'have-enough-data': { func: code_videoref_helper, fragment: 'dom-media-have_enough_data', link_text: 'HAVE_ENOUGH_DATA', },
// 'loadedmetadata': { func: code_videoref_helper, fragment: 'event-media-loadedmetadata', link_text: 'loadedmetadata', },
// 'loadeddata': { func: code_videoref_helper, fragment: 'event-media-loadeddata', link_text: 'loadeddata', },
'canplay': { func: code_videoref_helper, fragment: 'event-media-canplay', link_text: 'canplay', },
// 'canplaythrough': { func: code_videoref_helper, fragment: 'event-media-canplaythrough', link_text: 'canplaythrough', },
'paused': { func: code_videoref_helper, fragment: 'dom-media-paused', link_text: 'paused', },
'playing': { func: code_videoref_helper, fragment: 'dom-media-playing', link_text: 'playing', },
'waiting': { func: code_videoref_helper, fragment: 'event-media-waiting', link_text: 'waiting', },
'htmlmediaelement': { func: code_videoref_helper, fragment: 'htmlmediaelement', link_text: 'HTMLMediaElement', },
// 'invalid-access-err': { func: exception_helper, fragment: 'invalid_access_err', link_text: 'INVALID_ACCESS_ERR', },
// 'invalid-state-err': { func: exception_helper, fragment: 'invalid_state_err', link_text: 'INVALID_STATE_ERR', },
// 'not-found-err': { func: exception_helper, fragment: 'not_found_err', link_text: 'NOT_FOUND_ERR', },
// 'not-supported-err': { func: exception_helper, fragment: 'not_supported_err', link_text: 'NOT_SUPPORTED_ERR', },
// 'quota-exceeded-err': { func: exception_helper, fragment: 'quota_exceeded_err', link_text: 'QUOTA_EXCEEDED_ERR', },
'new-domexception-named': { func: new_domexception_helper, fragment: '', },
'domexception': { func: domexception_helper, fragment: '', },
'domexception-names': { func: webidl_helper, fragment: 'idl-DOMException-error-names', link_text: '', },
'maplike': { func: code_webidl_helper, fragment: 'idl-maplike', link_text: 'maplike', },
'queue-a-task-to-fire-an-event-named': { func: queue_and_fire_helper, fragment: '', link_text: 'queue a task', },
'Queue-a-task-to-fire-an-event-named': { func: queue_and_fire_helper, fragment: '', link_text: 'Queue a task', },
'Queue-a-task-to-run-algorithm': { func: queue_and_run_helper, fragment: '', link_text: 'Queue a task', },
'constructing-events': { func: dom_helper, fragment: 'constructing-events', link_text: 'Constructing events', },
'document-concept': { func: dom_helper, fragment: 'concept-document', link_text: 'Document', },
'origin': { func: browsers_helper, fragment: 'origin-0', link_text: 'origin', },
// 'effective-script-origin': { func: browsers_helper, fragment: 'effective-script-origin', link_text: 'effective script origin', },
'cors-same-origin': { func: infrastructure_helper, fragment: 'cors-same-origin', link_text: 'CORS-same-origin', },
'may-document-use-powerful-features-algorithm': { func: mixedcontent_helper, fragment: 'may-document-use-powerful-features', link_text: 'May Document use powerful features?', },
// 'contributors': { func: contributors_helper, fragment: '', link_text: '', },
};
// These definitions referring to locations in the main EME spec are only referenced from the registry.
var emeRegistryReferencesDefinitions = {
'eme-spec': { func: link_helper, fragment: '#', link_text: 'Encrypted Media Extensions', },
'clear-key': { func: term_helper, fragment: 'clear-key', link_text: 'Clear Key' },
'createSession': { func: idlref_helper, fragment: 'widl-MediaKeys-createSession-MediaKeySession-MediaKeySessionType-sessionType', link_text: 'createSession()', },
'initdata-encountered-algorithm': { func: term_helper, fragment: 'initdata-encountered', link_text: 'Initialization Data encountered', },
'using-base64url': { func: term_helper, fragment: 'using-base64url', link_text: 'Using base64url' },
};
var definitionInfo = {};
var groupBaseURLs = {};
var helperTypes = {
'link' : link_helper,
'var' : var_helper,
};
function encryptedMediaAddDefinitionInfo(groupName, groupBaseURL, definitions) {
groupBaseURLs[groupName] = groupBaseURL;
for (var def_id in definitions) {
if (definitionInfo[def_id]) {
console.log("Overriding previous definition of def-id '" + def_id + "'.");
}
var info = definitions[def_id];
info.groupName = groupName;
if (!info.func) {
var helper_type = info.helper_type || "link";
info.func = helperTypes[helper_type];
}
definitionInfo[def_id] = info;
}
}
function encryptedMediaPreProcessor() {
var original_EME_spec_url = EME_spec_url; // The loop may change multiple groupBaseURLs.
for (var x in groupBaseURLs) {
if (groupBaseURLs[x] == original_EME_spec_url && window.respecConfig.specStatus == "ED") {
EME_spec_url = "index.html";
groupBaseURLs[x] = EME_spec_url;
}
}
$("a[def-id]").each(function () {
$(this).addClass('externalDFN');
});
}
function encryptedMediaPostProcessor() {
var doc = document;
doc.normalize();
var usedMap = {};
$("a[def-id]").each(function () {
var $ant = $(this);
var def_id = $ant.attr('def-id');
var info = definitionInfo[def_id];
if (info) {
if (!usedMap[def_id]) {
usedMap[def_id] = 1;
} else {
usedMap[def_id]++;
}
var id = info.fragment;
var text = info.link_text;
if ($ant.attr('name')) {
id = $ant.attr('name');
}
var element_text = this.innerHTML;
if (element_text) {
text = element_text;
}
var df = doc.createDocumentFragment();
doc.emeDefGroupName = info.groupName;
info.func(doc, df, id, text);
doc.emeDefGroupName = "";
this.parentNode.replaceChild(df, this);
} else {
console.log("Found def-id '" + def_id + "' but it does not correspond to anything");
}
});
// Update links to external type definitions.
var externalClassInfo = {
'MediaKeys': { spec: 'eme', fragment: 'idl-def-MediaKeys' },
'AudioTrackList': {spec: 'html5', fragment: 'audiotracklist' },
'TextTrackList': {spec: 'html5', fragment: 'texttracklist' },
'TimeRanges': { spec: 'html5', fragment: 'timeranges' },
'VideoTrackList': {spec: 'html5', fragment: 'videotracklist' },
'EventTarget': { spec: 'dom', fragment: 'eventtarget' },
'DOMString': { spec: 'webidl', fragment: 'idl-DOMString' },
'boolean': { spec: 'webidl', fragment: 'idl-boolean' },
'double': { spec: 'webidl', fragment: 'idl-double' },
'unrestricted double': { spec: 'webidl', fragment: 'idl-unrestricted-double' },
'unsigned long': { spec: 'webidl', fragment: 'idl-unsigned-long' },
'unsigned long long': { spec: 'webidl', fragment: 'idl-unsigned-long-long' },
'void': { spec: 'webidl', fragment: 'idl-void' },
'ArrayBuffer': { spec: 'typed-array', fragment: 'ArrayBuffer' },
'ArrayBufferView': { spec: 'typed-array', fragment: 'ArrayBufferView' },
'EventHandler': { spec: 'webappapis', fragment: 'eventhandler' },
};
$("a:not([href])").each(function () {
var $ant = $(this);
var className = this.innerHTML;
var info = externalClassInfo[className];
if (info) {
var id = info.fragment;
var df = doc.createDocumentFragment();
var baseURL = null;
if (info.spec == 'html5') {
baseURL = HTML_spec_url;
} else if (info.spec == 'dom') {
baseURL = DOM_spec_url;
} else if (info.spec == 'webidl') {
baseURL = "http://dev.w3.org/2006/webapi/WebIDL/";
} else if (info.spec == 'typed-array') {
baseURL = "https://www.khronos.org/registry/typedarray/specs/latest/";
} else if (info.spec == 'eme') {
baseURL = EME_spec_url;
}
if (baseURL) {
df.appendChild($("<code/>").wrapInner($("<a/>").attr({href: baseURL + "#" + id, 'class': 'idlType'}).text(className))[0]);
this.parentNode.replaceChild(df, this);
}
}
});
// Move algorithm text after method parameter & return value information.
$("ol.method-algorithm").each(function() {
var parent = this.parentNode;
parent.removeChild(this);
parent.appendChild($("<p/>").text("When this method is invoked, the user agent must run the following steps:")[0]);
parent.appendChild(this);
});
// Add a simple id names for each method.
// This is more useful than the long "widl-..." names when referencing
// methods from outside this spec.
// Because the <dt> already has a generated id, the id is added to the <code>.
$("dl.methods > dt > code").each(function() {
if (this.id) {
console.error("Method " + this.textContent + "'s <code> element already has an 'id'.");
}
this.id = this.textContent;
});
// Validate that all defined def-ids are actually used.
var excludeList = window.respecConfig.emeUnusedGroupNameExcludeList || [];
for (var k in definitionInfo) {
var defGroupName = definitionInfo[k].groupName;
if (!usedMap[k] && !(excludeList.indexOf(defGroupName) != -1)) {
console.log("def-id '" + k + "' from groupName '" + defGroupName + "' never used.");
}
}
$("a[href]").each(function () {
var link = $(this);
var href = link.attr('href');
var matched = /^#(.+)$/.exec(href);
if (matched) {
var id = matched[1];
if (!document.getElementById(id)) {
console.log("Internal link to an id '" + id + "' which does not exist");
}
}
});
// THIS MUST BE LAST.
// Check for duplicate ids.
$("[id]").each(function () {
var elements = $("[id='" + this.id + "']");
if (elements.length != 1) {
console.error("id '" + this.id + "' is used for " + elements.length + " elements. This instance: ", this);
}
});
return;
}
encryptedMediaAddDefinitionInfo("encrypted-media", EME_spec_url, emeDefinitions);
encryptedMediaAddDefinitionInfo("eme-references-from-registry", EME_spec_url, emeRegistryReferencesDefinitions);
window.encryptedMediaAddDefinitionInfo = encryptedMediaAddDefinitionInfo;
window.encryptedMediaPreProcessor = encryptedMediaPreProcessor;
window.encryptedMediaPostProcessor = encryptedMediaPostProcessor;
})();