forked from whatwg/webidl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebIDLTest.htm
512 lines (445 loc) · 21.1 KB
/
WebIDLTest.htm
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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>WebIDL Testing</title>
<style>
iframe {
width: 95%;
height: 600px;
border: 1px solid orange;
margin-top: 10px;
display: block;
}
.assertView {
width: 95%;
border: 1px solid orange;
border-top: none;
overflow: auto;
}
#addPanel, #createPanel {
text-align: center;
}
#visible-asserts {
height: 400px;
}
#visible-asserts dl {
margin-top: 0;
}
#matching_asserts > :first-child, #matching_asserts > :nth-child(2) {
display: none; /* These are the template elements... */
}
.assert-ui-title a {
color: orange;
text-decoration: underline;
}
.assert-ui-title a:hover {
color: red;
cursor: pointer;
}
.assert-ui-notes {
width: 95%;
height: 5em;
background-color: #ceeaff;
border: 1px solid blue;
display: block;
}
.assert-ui-id, .assert-ui-author, .assert-ui-date {
font-size: xx-small;
font-style: italic;
}
.assert-ui-test {
float: right;
}
.approved {
background-color: #0b7000;
color: white;
}
.submitted {
background-color: #ffed97;
color: #5c3600;
}
</style>
<style>
/*****************************************************************
* ReSpec 3 CSS
* Robin Berjon - http://berjon.com/
*****************************************************************/
/* --- INLINES --- */
em.rfc2119 {
text-transform: lowercase;
font-variant: small-caps;
font-style: normal;
color: #900;
}
h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
border: none;
}
dfn {
font-weight: bold;
}
a.internalDFN {
color: inherit;
border-bottom: 1px solid #99c;
text-decoration: none;
}
a.externalDFN {
color: inherit;
border-bottom: 1px dotted #ccc;
text-decoration: none;
}
a.bibref {
text-decoration: none;
}
cite .bibref {
font-style: normal;
}
code {
color: #ff4500;
}
/* --- --- */
ol.algorithm { counter-reset:numsection; list-style-type: none; }
ol.algorithm li { margin: 0.5em 0; }
ol.algorithm li:before { font-weight: bold; counter-increment: numsection; content: counters(numsection, ".") ") "; }
/* --- TOC --- */
.toc a, .tof a {
text-decoration: none;
}
a .secno, a .figno {
color: #000;
}
ul.tof, ol.tof {
list-style: none outside none;
}
.caption {
margin-top: 0.5em;
font-style: italic;
}
/* --- TABLE --- */
table.simple {
border-spacing: 0;
border-collapse: collapse;
border-bottom: 3px solid #005a9c;
}
.simple th {
background: #005a9c;
color: #fff;
padding: 3px 5px;
text-align: left;
}
.simple th[scope="row"] {
background: inherit;
color: inherit;
border-top: 1px solid #ddd;
}
.simple td {
padding: 3px 10px;
border-top: 1px solid #ddd;
}
.simple tr:nth-child(even) {
background: #f0f6ff;
}
/* --- DL --- */
.section dd > p:first-child {
margin-top: 0;
}
.section dd > p:last-child {
margin-bottom: 0;
}
.section dd {
margin-bottom: 1em;
}
.section dl.attrs dd, .section dl.eldef dd {
margin-bottom: 0;
}
</style>
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet"><!--[if lt IE 9]><script src='http://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]--></head>
<body><div class="head">
<p>
<a href="http://www.w3.org/"><img width="72" height="48" alt="W3C" src="http://www.w3.org/Icons/w3c_home"></a>
</p>
<h1 class="title" id="title">WebIDL Testing</h1>
<h2 id="subtitle">Testing Summary, Conformance Report and Testable Assertions for WebIDL</h2>
<h2 id="w3c-editor-s-draft-13-july-2012"><abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft 13 July 2012</h2>
<dl>
<dt>This version:</dt>
<dd><a href="none">none</a></dd>
<dt>Latest published version:</dt>
<dd><a href="http://www.w3.org/TR/webidl-test/">http://www.w3.org/TR/webidl-test/</a></dd>
<dt>Latest editor's draft:</dt>
<dd><a href="none">none</a></dd>
<dt>Editor:</dt>
<dd><span>Travis Leithead</span>, <a href="http://microsoft.com/">Microsoft</a></dd>
</dl>
<p class="copyright">
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
2012
<a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
<a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
<abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
<a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
</p>
<hr>
</div>
<section class="introductory" id="abstract"><h2>Abstract</h2><p>
This document defines the testable assertions in WebIDL [first edition], and cross-links to tests that have been authored.
It will also contain the implementation report as tests are approved according to the <a href="http://www.w3.org/2008/webapps/wiki/Testing">WebApps Testing Process</a>.
</p></section><section class="introductory" id="sotd"><h2>Status of This Document</h2>
<p>
<em>This section describes the status of this document at the time of its publication. Other
documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the latest revision
of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports
index</a> at http://www.w3.org/TR/.</em>
</p>
<p>
This document was published by the <a href="http://www.w3.org/2008/webapps/">Web Application Working Group</a> as an Editor's Draft.
If you wish to make comments regarding this document, please send them to
<a href="mailto:public-webapps@w3.org">public-webapps@w3.org</a>
(<a href="mailto:public-webapps-request@w3.org?subject=subscribe">subscribe</a>,
<a href="http://lists.w3.org/Archives/Public/public-webapps/">archives</a>).
All feedback is welcome.
</p>
<p>
Publication as an Editor's Draft does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership.
This is a draft document and may be updated, replaced or obsoleted by other documents at
any time. It is inappropriate to cite this document as other than work in progress.
</p>
<p>
This document was produced by a group operating under the
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
<abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="" rel="disclosure">public list of any patent disclosures</a>
made in connection with the deliverables of the group; that page also includes instructions for
disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the
information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
</p>
</section>
<section id="toc"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a class="tocxref" href="#testable-assertions-visualizer"><span class="secno">1. </span>Testable assertions visualizer</a></li><li class="tocline"><a class="tocxref" href="#this-section-shows-the-testable-assertions-that-are-currently-visible-in-the-above-iframe"><span class="secno">2. </span>This section shows the testable assertions that are currently visible in the above iframe</a></li><li class="tocline"><a class="tocxref" href="#all-matching-assertions"><span class="secno">3. </span>All matching assertions</a></li><li class="tocline"><a class="tocxref" href="#unmatched-assertions"><span class="secno">4. </span>Unmatched assertions</a></li></ul></section>
<section id="testable-assertions-visualizer">
<!--OddPage--><h2><span class="secno">1. </span>Testable assertions visualizer</h2>
<p>This section hosts the WebIDL specification and is used for identifying testable assertions in that spec according to the list of assertions defined in this document.</p>
<iframe src='v1.html' onload='oniframeload()'></iframe>
</section>
<section id="this-section-shows-the-testable-assertions-that-are-currently-visible-in-the-above-iframe">
<!--OddPage--><h2><span class="secno">2. </span>This section shows the testable assertions that are currently visible in the above iframe</h2>
<div class="assertView">
<div id="addPanel">
<input id="markNew" type="button" value="Create a new testable assertion">
<input id="exportNew" type="button" value="Export/Download">
</div>
<div id="createPanel" style="display: none;">
<form id="formNew">
<label>Spec reference: <input id="A_specRef" style="width: 60em;" required="" type="text" placeholder="Select an element in the above spec to populate this field"></label>
<br>
<label>Assert Id: <input id="A_id" style="width: 10em;" required="" type="text"></label>
<label>Title: <input id="A_title" style="width: 50em;" required="" type="text" placeholder="Include section number and brief description"></label>
<label>Author: <input id="A_author" style="width: 10em;" required="" type="text"></label>
<br>
<textarea id="A_notes" style="width: 98%; height: 5em;" placeholder="Describe the test and any other relevant info here...">Describe the test and any other relevant info here...</textarea>
<input id="saveNew" type="submit" value="Save">
<input id="cancelNew" type="button" value="Cancel">
</form>
<hr>
</div>
</div>
<div class="assertView" id="visible-asserts">
<dl id="dynamic_asserts"></dl>
</div>
</section>
<section id="all-matching-assertions">
<!--OddPage--><h2><span class="secno">3. </span>All matching assertions</h2>
All the identified testable assertions in WebIDL are identified in the list below.
<dl id="matching_asserts">
<dt class="assert-ui-title"><a></a></dt>
<dd>
<textarea class="assert-ui-notes" readonly=""></textarea>
<span class="assert-ui-id"></span> |
<span class="assert-ui-author"></span> |
<span class="assert-ui-date"></span>
<button class="assert-ui-test"></button>
</dd>
</dl>
</section>
<section id="unmatched-assertions">
<!--OddPage--><h2><span class="secno">4. </span>Unmatched assertions</h2>
<p>These assertions no longer match the part of the document they were authored against. This likely happened because the section of the document they were
referencing changed. These assertions should be reviewed and have their matching path udpated.</p>
<dl id="unmatched_asserts"></dl>
</section>
<script>
var existingAssertMap = null;
var newAssertsMap = {};
var iframeWindow = null;
var SPEC_TESTING_COMPANION_URL = "spec-testing-companion.js";
var WEBIDL_ASSERTIONS_URL = "testable_assertions.txt";
var isSecondOnloadAfterRespec = false;
addEventListener("message", ie9CompatMessageDecoder);
// IE9 can't send complex objects (structured clone algorithm) through postMessage. Works in IE10
function ie9CompatMessageDecoder(messageString) {
messageString.data2 = JSON.parse(messageString.data);
message(messageString);
}
function ie9CompatMessageEncoder(messageObject) {
iframeWindow.postMessage(JSON.stringify(messageObject), "*");
}
function prepAsserts() {
var initPayload = [];
for (var key in existingAssertMap) {
initPayload.push({ assertId: key, selector: existingAssertMap[key].specRef });
}
return initPayload;
}
// Load asserts
function requestAssertions(assertionsLoadedCallback) {
// Request the assertions for WebIDL...
var xhr = new XMLHttpRequest();
xhr.open("get", WEBIDL_ASSERTIONS_URL);
xhr.onload = function () {
if (this.status != 404) {
existingAssertMap = JSON.parse(this.responseText);
assertionsLoadedCallback();
}
}
xhr.send();
}
function oniframeload() {
// Inject the testing companion into the WebIDL spec
iframeWindow = document.querySelector("iframe").contentWindow;
var scriptToInject = iframeWindow.document.createElement("script");
scriptToInject.src = SPEC_TESTING_COMPANION_URL;
scriptToInject.onload = function () {
requestAssertions(function () {
// Assertions loaded...
ie9CompatMessageEncoder({ message: "init", data: prepAsserts() });
ie9CompatMessageEncoder({ message: "notify" });
});
};
iframeWindow.document.body.appendChild(scriptToInject);
}
function message(e) {
var d = e.data2;
if ((typeof d == "object") && (d != null)) {
if (d.message == "initialized") {
//alert("spec testing companion initialized:\n\n" + JSON.stringify(d.data));
replicateAssertsTo(d.data.matched, "matching_asserts");
replicateAssertsTo(d.data.unmatched, "unmatched_asserts");
}
if (d.message == "assert")
document.getElementById("A_specRef").value = d.data;
if (d.message == "asserts-in-view") {
document.getElementById("dynamic_asserts").innerHTML = ""; // Clear it out...
replicateAssertsTo(d.data, "dynamic_asserts");
}
}
}
// Setup new insertion finding...
document.getElementById("markNew").addEventListener('click', function () {
// Set the companion in the identify mode...(asnyc)
if (iframeWindow == null)
return; // Not ready yet...
ie9CompatMessageEncoder({ message: "identify" });
// Hide the new button
document.getElementById("addPanel").style.display = "none";
// Show the form
document.getElementById("createPanel").style.display = "";
// Clear all the entries in the form...
document.getElementById("A_id").value = "";
document.getElementById("A_specRef").value = "";
document.getElementById("A_title").value = "";
// NOTE: Leave author alone...(probably the same author)
document.getElementById("A_notes").value = "";
});
document.getElementById("cancelNew").addEventListener('click', function () {
document.getElementById("createPanel").style.display = "none";
document.getElementById("addPanel").style.display = "";
});
document.getElementById("formNew").addEventListener('submit', function (e) {
// Verify this id doesn't already exist...
var keyName = document.getElementById("A_id").value;
if (typeof existingAssertMap[keyName] != "undefined")
alert("Note: This assert id is already in use in the existing assert id list; adding it anyway");
if (typeof newAssertsMap[keyName] != "undefined") {
alert("This assert id is a duplicate of one you added earlier, please change the id");
e.preventDefault();
return;
}
newAssertsMap[keyName] = {
title: document.getElementById("A_title").value,
specRef: document.getElementById("A_specRef").value,
notes: document.getElementById("A_notes").value,
author: document.getElementById("A_author").value,
date: new Date(),
testURL: "",
testApproved: false
};
if (Object.keys(newAssertsMap).length == 1) { // First entry...
document.getElementById("exportNew").style.display = ""; // Make it visible.
}
e.preventDefault(); // Don't actually submit and reload the page.
document.getElementById("createPanel").style.display = "none";
document.getElementById("addPanel").style.display = "";
});
document.getElementById("exportNew").addEventListener('click', function () {
var rawOutput = JSON.stringify(newAssertsMap, null, " ");
if (navigator.msSaveOrOpenBlob) {
// Create a Blob with the JSON content in it.
var exportBlob = new Blob([rawOutput], "text/json");
navigator.msSaveOrOpenBlob(exportBlob, "NewTestableAssertions.json");
}
else {
var newWin = open("about:blank");
setTimeout(function (windowOpenHandler, content) {
var pre = windowOpenHandler.document.createElement("pre");
windowOpenHandler.document.body.appendChild(pre);
pre.innerHTML = content;
}, 500, newWin, rawOutput);
}
});
function replicateAssertsTo(assertIdList, targetId) {
var target = null;
target = document.getElementById(targetId);
for (var i = 0, len = assertIdList.length; i < len; i++) {
if (typeof assertIdList[i] != "string") // Which happens for notify messages...
assertIdList[i] = assertIdList[i].assertId;
// Clone the assert template...
var definitionTerm = document.getElementById("matching_asserts").firstElementChild.cloneNode(true);
var definitionDesc = document.getElementById("matching_asserts").firstElementChild.nextElementSibling.cloneNode(true);
// Add the title
if (targetId == "matching_asserts") {
definitionTerm.firstElementChild.innerHTML = existingAssertMap[assertIdList[i]].title;
definitionTerm.firstElementChild.privId = assertIdList[i];
definitionTerm.firstElementChild.onclick = click_showAssert;
}
else
definitionTerm.innerHTML = existingAssertMap[assertIdList[i]].title; // Blow away the Anchor element.
definitionDesc.children[0].innerHTML = existingAssertMap[assertIdList[i]].notes; // textarea
definitionDesc.children[1].innerHTML = assertIdList[i]; // span
definitionDesc.children[2].innerHTML = existingAssertMap[assertIdList[i]].author; // span
var d = new Date(existingAssertMap[assertIdList[i]].date);
definitionDesc.children[3].innerHTML = d.toLocaleDateString(); // span
if (existingAssertMap[assertIdList[i]].testURL == "") {
definitionDesc.children[4].innerHTML = "Test case not available";
definitionDesc.children[4].setAttribute("disabled", "")
}
else {
definitionDesc.children[4].innerHTML = existingAssertMap[assertIdList[i]].testApproved ? "Approved test case >" : "Submitted test case >";
definitionDesc.children[4].className += existingAssertMap[assertIdList[i]].testApproved ? " approved" : " submitted";
definitionDesc.children[4].testURL = existingAssertMap[assertIdList[i]].testURL;
definitionDesc.children[4].onclick = click_goToTest;
}
target.appendChild(definitionTerm);
target.appendChild(definitionDesc);
}
}
function click_showAssert() {
ie9CompatMessageEncoder({ message: "show", data: this.privId });
}
function click_goToTest() {
open(this.testURL, "_blank");
}
</script>
</body></html>