Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Range / acid3-surround-contents.html
blobe45c9fff3d00c9c3e10c2f0a59109f2bc8376511
1 <iframe src="empty.html" id="selectors" width=0 height=0 frameborder=0></iframe>
2 <p>The test below should report no failures, and should say PASS at the end.</p>
3 <script>
4 if (window.testRunner) {
5 testRunner.dumpAsText();
7 </script>
8 <script>
10 function getTestDocument() {
11 var iframe = document.getElementById("selectors");
12 var doc = iframe.contentDocument;
13 for (var i = doc.documentElement.childNodes.length-1; i >= 0; i -= 1)
14 doc.documentElement.removeChild(doc.documentElement.childNodes[i]);
15 doc.documentElement.appendChild(doc.createElement('head'));
16 doc.documentElement.firstChild.appendChild(doc.createElement('title'));
17 doc.documentElement.appendChild(doc.createElement('body'));
18 return doc;
21 var failCount = 0;
23 function fail(message) {
24 document.write(message.replace("&", "&amp;").replace("<", "&lt;") + "<br>");
25 ++failCount;
28 function assert(condition, message) {
29 if (!condition)
30 fail(message);
33 function assertEquals(expression, value, message) {
34 if (expression != value) {
35 expression = (""+expression).replace(/[\r\n]+/g, "\\n");
36 value = (""+value).replace(/\r?\n/g, "\\n");
37 fail("expected '" + value + "' but got '" + expression + "' - " + message);
41 // test 11: Ranges and Comments
42 var msg;
43 var doc = getTestDocument();
44 var c1 = doc.createComment("11111");
45 doc.appendChild(c1);
46 var r = doc.createRange();
47 r.selectNode(c1);
48 msg = 'wrong exception raised';
49 try {
50 r.surroundContents(doc.createElement('a'));
51 msg = 'no exception raised';
52 } catch (e) {
53 if ('code' in e)
54 msg += '; code = ' + e.code;
55 if (e.code == 3) // HIERARCHY_REQUEST_ERR
56 msg = '';
58 assert(msg == '', "when inserting <a> into Document with another child: " + msg);
59 var c2 = doc.createComment("22222");
60 doc.body.appendChild(c2);
61 var c3 = doc.createComment("33333");
62 doc.body.appendChild(c3);
63 r.setStart(c2, 2);
64 r.setEnd(c3, 3);
65 var msg = 'wrong exception raised';
66 try {
67 r.surroundContents(doc.createElement('a'));
68 msg = 'no exception raised';
69 } catch (e) {
70 // COMMENTED OUT FOR 2011 UPDATE - DOM Core changes the exception from RangeException.BAD_BOUNDARYPOINTS_ERR (1) to DOMException.INVALID_STATE_ERR (11)
71 // if ('code' in e)
72 // msg += '; code = ' + e.code;
73 // if (e.code == 1)
74 msg = '';
76 assert(msg == '', "when trying to surround two halves of comment: " + msg);
77 assertEquals(r.toString(), "", "comments returned text");
79 if (failCount == 0)
80 document.write("PASS<br>");
81 </script>