+
+
diff --git a/dom/base/test/test_bug789315.html b/dom/base/test/test_bug789315.html
new file mode 100644
index 000000000..e3081f36e
--- /dev/null
+++ b/dom/base/test/test_bug789315.html
@@ -0,0 +1,49 @@
+
+
+
+
+
+ Test for Bug 789315
+
+
+
+
+
+
+
+
+
+Mozilla Bug 789315
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug789856.html b/dom/base/test/test_bug789856.html
new file mode 100644
index 000000000..6cf30a7a4
--- /dev/null
+++ b/dom/base/test/test_bug789856.html
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Test for Bug 789856
+
+
+
+
+Mozilla Bug 789856
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug793311.html b/dom/base/test/test_bug793311.html
new file mode 100644
index 000000000..5c1e8e7d3
--- /dev/null
+++ b/dom/base/test/test_bug793311.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+ Test for Bug 793311
+
+
+
+
+
+Mozilla Bug 793311
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug804395.html b/dom/base/test/test_bug804395.html
new file mode 100644
index 000000000..58e5fcf38
--- /dev/null
+++ b/dom/base/test/test_bug804395.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+ Test for Bug 804395
+
+
+
+
+Mozilla Bug 804395
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug809003.html b/dom/base/test/test_bug809003.html
new file mode 100644
index 000000000..06515b178
--- /dev/null
+++ b/dom/base/test/test_bug809003.html
@@ -0,0 +1,47 @@
+
+
+
+
+
+ Test for Bug 809003
+
+
+
+
+
+Mozilla Bug 809003
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug810494.html b/dom/base/test/test_bug810494.html
new file mode 100644
index 000000000..2aa659b80
--- /dev/null
+++ b/dom/base/test/test_bug810494.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+ Test for Bug 810494
+
+
+
+
+
+Mozilla Bug 810494
+
+
+
+
+
diff --git a/dom/base/test/test_bug811701.html b/dom/base/test/test_bug811701.html
new file mode 100644
index 000000000..70c5abe0b
--- /dev/null
+++ b/dom/base/test/test_bug811701.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+ Test for Bug 811701
+
+
+
+
+Mozilla Bug 811701
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug811701.xhtml b/dom/base/test/test_bug811701.xhtml
new file mode 100644
index 000000000..10e11013d
--- /dev/null
+++ b/dom/base/test/test_bug811701.xhtml
@@ -0,0 +1,52 @@
+
+
+
+ Test for Bug 811701
+
+
+
+
+Mozilla Bug 811701
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug813919.html b/dom/base/test/test_bug813919.html
new file mode 100644
index 000000000..5afa50444
--- /dev/null
+++ b/dom/base/test/test_bug813919.html
@@ -0,0 +1,46 @@
+
+
+
+
+
+ Test for Bug 813919
+
+
+
+
+Mozilla Bug 813919
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug814576.html b/dom/base/test/test_bug814576.html
new file mode 100644
index 000000000..8ed47a5b8
--- /dev/null
+++ b/dom/base/test/test_bug814576.html
@@ -0,0 +1,41 @@
+
+
+
+
+
+ Test for Bug 814576
+
+
+
+
+Mozilla Bug 814576
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug819051.html b/dom/base/test/test_bug819051.html
new file mode 100644
index 000000000..bb4f15204
--- /dev/null
+++ b/dom/base/test/test_bug819051.html
@@ -0,0 +1,59 @@
+
+
+
+
+ Test for Bug 819051
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug820909.html b/dom/base/test/test_bug820909.html
new file mode 100644
index 000000000..21ecb2f04
--- /dev/null
+++ b/dom/base/test/test_bug820909.html
@@ -0,0 +1,87 @@
+
+
+
+
+
+ Test for Bug 820909
+
+
+
+
+Mozilla Bug 820909
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug840098.html b/dom/base/test/test_bug840098.html
new file mode 100644
index 000000000..8eaceb589
--- /dev/null
+++ b/dom/base/test/test_bug840098.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+ Test for Bug 840098
+
+
+
+
+Mozilla Bug 840098
+
+
+Hello
+
+
+
+
+
diff --git a/dom/base/test/test_bug864595.html b/dom/base/test/test_bug864595.html
new file mode 100644
index 000000000..37504353f
--- /dev/null
+++ b/dom/base/test/test_bug864595.html
@@ -0,0 +1,34 @@
+
+
+
+
+ Test for Bug 864595
+
+
+
+
+Mozilla Bug 864595
+abcd
+
+
+
diff --git a/dom/base/test/test_bug868999.html b/dom/base/test/test_bug868999.html
new file mode 100644
index 000000000..0d189004b
--- /dev/null
+++ b/dom/base/test/test_bug868999.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+ Test for Bug 868999
+
+
+
+
+Mozilla Bug 869006
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug869000.html b/dom/base/test/test_bug869000.html
new file mode 100644
index 000000000..71ecea55b
--- /dev/null
+++ b/dom/base/test/test_bug869000.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+ Test for Bug 869000
+
+
+
+
+Mozilla Bug 869006
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug869002.html b/dom/base/test/test_bug869002.html
new file mode 100644
index 000000000..a93200a1b
--- /dev/null
+++ b/dom/base/test/test_bug869002.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+ Test for Bug 868999
+
+
+
+
+Mozilla Bug 869002
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug869006.html b/dom/base/test/test_bug869006.html
new file mode 100644
index 000000000..947166030
--- /dev/null
+++ b/dom/base/test/test_bug869006.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+ Test for Bug 869006
+
+
+
+
+Mozilla Bug 869006
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug876282.html b/dom/base/test/test_bug876282.html
new file mode 100644
index 000000000..bb5a6a02a
--- /dev/null
+++ b/dom/base/test/test_bug876282.html
@@ -0,0 +1,45 @@
+
+
+
+
+ Test for Bug 647518
+
+
+
+
+Mozilla Bug 647518
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug890580.html b/dom/base/test/test_bug890580.html
new file mode 100644
index 000000000..808a4a868
--- /dev/null
+++ b/dom/base/test/test_bug890580.html
@@ -0,0 +1,58 @@
+
+
+
+
+
+ Test for Bug 883129
+
+
+
+
+
+Mozilla Bug 890580
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug891952.html b/dom/base/test/test_bug891952.html
new file mode 100644
index 000000000..471e72712
--- /dev/null
+++ b/dom/base/test/test_bug891952.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+ Test for Bug 891952
+
+
+
+
+
+Mozilla Bug 891952
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug894874.html b/dom/base/test/test_bug894874.html
new file mode 100644
index 000000000..f9a0c4fce
--- /dev/null
+++ b/dom/base/test/test_bug894874.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+ Test for Bug 894874
+
+
+
+
+
+
+
+
+
+Mozilla Bug 894874
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug895239.html b/dom/base/test/test_bug895239.html
new file mode 100644
index 000000000..32c0717e5
--- /dev/null
+++ b/dom/base/test/test_bug895239.html
@@ -0,0 +1,123 @@
+
+
+
+
+
+ Test for Bug 895239
+
+
+
+
+
+Mozilla Bug 895239
+
+
+
This is an audio
+
+ Your browser does not support audio
element.
+ !
+
+
This is a canvas
+
+ Your browser does not support canvas element.
+ !
+
+
This is an iframe
+ !
+
+
One iframe
+ with another iframe
+ .
+
+
This is a meter
+
+ 50%
+ !
+
+
This is a progress
+
+ 70%
+ !
+
+
This is an object
+
+ Download the plugin.
+ !
+
+
This is a svg
+
+ Your browser does not support svg.
+
+ !
+
+
This is a video
+
+ Your browser does not support videos.
+ !
+
+
This is a video
+
+ Your browser does not support videos.
+ !
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug895974.html b/dom/base/test/test_bug895974.html
new file mode 100644
index 000000000..25499d5a2
--- /dev/null
+++ b/dom/base/test/test_bug895974.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+ Test for Bug 895974
+
+
+
+
+
+Mozilla Bug 895974
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug902847.html b/dom/base/test/test_bug902847.html
new file mode 100644
index 000000000..b8ab1bfc4
--- /dev/null
+++ b/dom/base/test/test_bug902847.html
@@ -0,0 +1,58 @@
+
+
+
+
+
+ Test for Bug 902847
+
+
+
+
+
+Mozilla Bug 902847
+
+
+
Hello boy!
+
Hello boy!
+
Hello boy!
+
Hello boy!
+
+
+
+
+
diff --git a/dom/base/test/test_bug907892.html b/dom/base/test/test_bug907892.html
new file mode 100644
index 000000000..a62cf90a1
--- /dev/null
+++ b/dom/base/test/test_bug907892.html
@@ -0,0 +1,49 @@
+
+
+
+
+
+ Test for Bug 907892
+
+
+
+
+
+Mozilla Bug 907892
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug913761.html b/dom/base/test/test_bug913761.html
new file mode 100644
index 000000000..bfa05b150
--- /dev/null
+++ b/dom/base/test/test_bug913761.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Test for Bug 913761 - basic support
+
+
+
+
+Mozilla Bug 913761
+
+
+
diff --git a/dom/base/test/test_bug922681.html b/dom/base/test/test_bug922681.html
new file mode 100644
index 000000000..b04c0c675
--- /dev/null
+++ b/dom/base/test/test_bug922681.html
@@ -0,0 +1,113 @@
+
+
+
+
+
+ Test for Bug 922681
+
+
+
+
+
+Mozilla Bug 922681
+
+
+
+
diff --git a/dom/base/test/test_bug927196.html b/dom/base/test/test_bug927196.html
new file mode 100644
index 000000000..0a2868171
--- /dev/null
+++ b/dom/base/test/test_bug927196.html
@@ -0,0 +1,56 @@
+
+
+
+
+ Test for Bug 426308
+
+
+
+
+Mozilla Bug 927196
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug945152.html b/dom/base/test/test_bug945152.html
new file mode 100644
index 000000000..aa4bf7c3e
--- /dev/null
+++ b/dom/base/test/test_bug945152.html
@@ -0,0 +1,58 @@
+
+
+
+
+
+ Test for Bug 945152
+
+
+
+
+Mozilla Bug 945152
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug962251.html b/dom/base/test/test_bug962251.html
new file mode 100644
index 000000000..8b870d899
--- /dev/null
+++ b/dom/base/test/test_bug962251.html
@@ -0,0 +1,258 @@
+
+
+
+
+
+
+ Test for Bug 962251
+
+
+
+
+
+Mozilla Bug 962251
+
+
+ 1
+ 2
+ 3
+
+
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/test_bug976673.html b/dom/base/test/test_bug976673.html
new file mode 100644
index 000000000..d028f70d8
--- /dev/null
+++ b/dom/base/test/test_bug976673.html
@@ -0,0 +1,107 @@
+
+
+
+
+
+ Test for Bug 976673
+
+
+
+
+
+Mozilla Bug 976673
+
+
+
+
+
+
+
+set focus
+
+
+
+
diff --git a/dom/base/test/test_bug982153.html b/dom/base/test/test_bug982153.html
new file mode 100644
index 000000000..17121d4e2
--- /dev/null
+++ b/dom/base/test/test_bug982153.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+ Test for Bug 982153
+
+
+
+
+
+Mozilla Bug 982153
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_bug999456.html b/dom/base/test/test_bug999456.html
new file mode 100644
index 000000000..6f5cd7a00
--- /dev/null
+++ b/dom/base/test/test_bug999456.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+ Test for Bug 999456
+
+
+
+
+
+Mozilla Bug 999456
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_caretPositionFromPoint.html b/dom/base/test/test_caretPositionFromPoint.html
new file mode 100644
index 000000000..50f12b1ef
--- /dev/null
+++ b/dom/base/test/test_caretPositionFromPoint.html
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+ Test for Bug 654352
+
+
+
+
+abc, abc, abc
+abc, abc, abc
+
+marquee
+
+
+
+
+
diff --git a/dom/base/test/test_change_policy.html b/dom/base/test/test_change_policy.html
new file mode 100644
index 000000000..76816f01f
--- /dev/null
+++ b/dom/base/test/test_change_policy.html
@@ -0,0 +1,129 @@
+
+
+
+
+ Test policies for Bug 1101288
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_classList.html b/dom/base/test/test_classList.html
new file mode 100644
index 000000000..2a108d7f5
--- /dev/null
+++ b/dom/base/test/test_classList.html
@@ -0,0 +1,426 @@
+
+
+
+
+ Test for the classList element attribute
+
+
+
+
+classList DOM attribute
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_clearTimeoutIntervalNoArg.html b/dom/base/test/test_clearTimeoutIntervalNoArg.html
new file mode 100644
index 000000000..e1d60022f
--- /dev/null
+++ b/dom/base/test/test_clearTimeoutIntervalNoArg.html
@@ -0,0 +1,14 @@
+
+
+Test for clearTimeout/clearInterval with no arguments not throwing
+
+
+
+
diff --git a/dom/base/test/test_constructor-assignment.html b/dom/base/test/test_constructor-assignment.html
new file mode 100644
index 000000000..f04a991da
--- /dev/null
+++ b/dom/base/test/test_constructor-assignment.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_constructor.html b/dom/base/test/test_constructor.html
new file mode 100644
index 000000000..b987057e2
--- /dev/null
+++ b/dom/base/test/test_constructor.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_copyimage.html b/dom/base/test/test_copyimage.html
new file mode 100644
index 000000000..a2610e360
--- /dev/null
+++ b/dom/base/test/test_copyimage.html
@@ -0,0 +1,94 @@
+
+
+
+
+ Test for copy image
+
+
+
+
+Mozilla Bug 518249
+Mozilla Bug 952456
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_copypaste.html b/dom/base/test/test_copypaste.html
new file mode 100644
index 000000000..db929270d
--- /dev/null
+++ b/dom/base/test/test_copypaste.html
@@ -0,0 +1,119 @@
+
+
+
+
+ Test for copy/paste
+
+
+
+
+
+
+Mozilla Bug
+
+
+
+
+
+
+
+
+
This is a draggable bit of text.
+
+
+
+
+
+ mozilla
+
+ foo
+ baz
+ bar
+
+
+
+
+
+
+ T
+
+
+
+ T
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
div7
+
div8
+
+
+
+
+
div 11
+
div 12
+
+
_FAIL _
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_copypaste.xhtml b/dom/base/test/test_copypaste.xhtml
new file mode 100644
index 000000000..9b06cb8b8
--- /dev/null
+++ b/dom/base/test/test_copypaste.xhtml
@@ -0,0 +1,108 @@
+
+
+
+
+ Test for copy/paste with XHTML
+
+
+
+
+
+Mozilla Bug 888839
+
+
+
+
+
+
+
+
+
This is a draggable bit of text.
+
+
+
+
+
+ mozilla
+
+ foo
+ baz
+ bar
+
+
+
+
+
+
+ T
+
+
+
+ T
+
+
+
+
+
+
div7
+
div8
+
+
+
+
+
div 11
+
div 12
+
+
_FAIL _
+
+
+
+
+
+
diff --git a/dom/base/test/test_copypaste.xul b/dom/base/test/test_copypaste.xul
new file mode 100644
index 000000000..6c14c7357
--- /dev/null
+++ b/dom/base/test/test_copypaste.xul
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Mozilla Bug 888839
+
+
diff --git a/dom/base/test/test_createHTMLDocument.html b/dom/base/test/test_createHTMLDocument.html
new file mode 100644
index 000000000..66b090d18
--- /dev/null
+++ b/dom/base/test/test_createHTMLDocument.html
@@ -0,0 +1,52 @@
+
+createHTMLDocument
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_declare_stylesheet_obsolete.html b/dom/base/test/test_declare_stylesheet_obsolete.html
new file mode 100644
index 000000000..baceea2e9
--- /dev/null
+++ b/dom/base/test/test_declare_stylesheet_obsolete.html
@@ -0,0 +1,94 @@
+
+
+
+
+
+ Test for Bug 713564
+
+
+
+
+
+
+
+
+
+Mozilla Bug 713564
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_dialogArguments.html b/dom/base/test/test_dialogArguments.html
new file mode 100644
index 000000000..70a091d00
--- /dev/null
+++ b/dom/base/test/test_dialogArguments.html
@@ -0,0 +1,31 @@
+
+
+
+ Test for Bug 1019761
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_document.all_iteration.html b/dom/base/test/test_document.all_iteration.html
new file mode 100644
index 000000000..a5140d9df
--- /dev/null
+++ b/dom/base/test/test_document.all_iteration.html
@@ -0,0 +1,11 @@
+
+
+Test for document.all iteration behavior
+
+
+
+
diff --git a/dom/base/test/test_document.all_unqualified.html b/dom/base/test/test_document.all_unqualified.html
new file mode 100644
index 000000000..763ba9898
--- /dev/null
+++ b/dom/base/test/test_document.all_unqualified.html
@@ -0,0 +1,35 @@
+
+
+
+ Test for Bug 823283
+
+
+
+
+Mozilla Bug 823283
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_document_constructor.html b/dom/base/test/test_document_constructor.html
new file mode 100644
index 000000000..831120050
--- /dev/null
+++ b/dom/base/test/test_document_constructor.html
@@ -0,0 +1,31 @@
+
+
+
+
+
+ Test for Bug 1017932
+
+
+
+
+
+Mozilla Bug 1017932
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_document_importNode_document.html b/dom/base/test/test_document_importNode_document.html
new file mode 100644
index 000000000..e33575e84
--- /dev/null
+++ b/dom/base/test/test_document_importNode_document.html
@@ -0,0 +1,32 @@
+
+
+
+
+ Test for Bug 1177914
+
+
+
+
+
+Mozilla Bug 1177914
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_document_register.html b/dom/base/test/test_document_register.html
new file mode 100644
index 000000000..6cf15a52f
--- /dev/null
+++ b/dom/base/test/test_document_register.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+ Mozilla Bug 783129
+
+
+
+
diff --git a/dom/base/test/test_domcursor.html b/dom/base/test/test_domcursor.html
new file mode 100644
index 000000000..d33581f12
--- /dev/null
+++ b/dom/base/test/test_domcursor.html
@@ -0,0 +1,140 @@
+
+
+
+ Test for DOMCursor
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_domparser_null_char.html b/dom/base/test/test_domparser_null_char.html
new file mode 100644
index 000000000..2bc19c717
--- /dev/null
+++ b/dom/base/test/test_domparser_null_char.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+ Test for Bug 817469
+
+
+
+
+Mozilla Bug 817469
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_domparsing.html b/dom/base/test/test_domparsing.html
new file mode 100644
index 000000000..b45187d66
--- /dev/null
+++ b/dom/base/test/test_domparsing.html
@@ -0,0 +1,84 @@
+
+
+
+
+ Test for the DOM Parsing and Serialization Standard
+
+
+
+
+Mozilla Bug 816410
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_domrequest.html b/dom/base/test/test_domrequest.html
new file mode 100644
index 000000000..85636ba52
--- /dev/null
+++ b/dom/base/test/test_domrequest.html
@@ -0,0 +1,229 @@
+
+
+
+ Test for DOMRequest
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_domrequesthelper.xul b/dom/base/test/test_domrequesthelper.xul
new file mode 100644
index 000000000..4365e4f0e
--- /dev/null
+++ b/dom/base/test/test_domrequesthelper.xul
@@ -0,0 +1,552 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_domwindowutils.html b/dom/base/test/test_domwindowutils.html
new file mode 100644
index 000000000..218f510ff
--- /dev/null
+++ b/dom/base/test/test_domwindowutils.html
@@ -0,0 +1,85 @@
+
+
+
+
+ Test for DOMWindowUtils
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_e4x_for_each.html b/dom/base/test/test_e4x_for_each.html
new file mode 100644
index 000000000..3d1ffa57a
--- /dev/null
+++ b/dom/base/test/test_e4x_for_each.html
@@ -0,0 +1,55 @@
+
+
+
+ Test for E4X "for each" syntax
+
+
+
+
+
+
+
+
+
+function runTest(i) {
+ var t = tests[i];
+ count++;
+ try {
+ Function("for each (var a in []) {}");
+ ok(t.enabled, "JavaScript" + ("version" in t ? " " + t.version : "") + " supports for-each-in");
+ } catch (e) {
+ ok(!t.enabled, "JavaScript" + ("version" in t ? " " + t.version : "") + " does NOT support for-each-in");
+ }
+}
+
+
+
+
+
+
diff --git a/dom/base/test/test_element.matches.html b/dom/base/test/test_element.matches.html
new file mode 100644
index 000000000..9b360b16f
--- /dev/null
+++ b/dom/base/test/test_element.matches.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+ Test for Bug 886308
+
+
+
+
+
+Mozilla Bug 886308
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_elementTraversal.html b/dom/base/test/test_elementTraversal.html
new file mode 100644
index 000000000..3ff4db0e7
--- /dev/null
+++ b/dom/base/test/test_elementTraversal.html
@@ -0,0 +1,111 @@
+
+
+
+
+ Test for the ElementTraversal spec
+
+
+
+
+ElementTraversal
+
+
span div
+
+
p1
+text here
+
p2
+
ab cd e
+
+
+
+
+
+
diff --git a/dom/base/test/test_element_closest.html b/dom/base/test/test_element_closest.html
new file mode 100644
index 000000000..adede6b8b
--- /dev/null
+++ b/dom/base/test/test_element_closest.html
@@ -0,0 +1,84 @@
+
+
+
+
+ Test for Bug 1055533
+
+
+
+
+
+
+ Mozilla Bug 1055533
+
+
+
+
diff --git a/dom/base/test/test_encodeToStringWithMaxLength.html b/dom/base/test/test_encodeToStringWithMaxLength.html
new file mode 100644
index 000000000..587aff77b
--- /dev/null
+++ b/dom/base/test/test_encodeToStringWithMaxLength.html
@@ -0,0 +1,64 @@
+
+
+
+
+
+ Test for Bug 995321 - encodeToStringWithMaxLength
+
+
+
+
+
+Mozilla Bug 995321
+
+
+The Mozilla project is a global community of people who believe that openness, innovation, and opportunity are key to the continued health of the Internet. We have worked together since 1998 to ensure that the Internet is developed in a way that benefits everyone. We are best known for creating the Mozilla Firefox web browser.
+
+The Mozilla project uses a community-based approach to create world-class open source software and to develop new types of collaborative activities. We create communities of people involved in making the Internet experience better for all of us.
+
+As a result of these efforts, we have distilled a set of principles that we believe are critical for the Internet to continue to benefit the public good as well as commercial aspects of life. We set out these principles below.
+
+
+
+
+
diff --git a/dom/base/test/test_error.html b/dom/base/test/test_error.html
new file mode 100644
index 000000000..c06d82526
--- /dev/null
+++ b/dom/base/test/test_error.html
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+ Test for Bug 869013
+
+
+
+
+Mozilla Bug 869013
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_explicit_user_agent.html b/dom/base/test/test_explicit_user_agent.html
new file mode 100644
index 000000000..9cac4c933
--- /dev/null
+++ b/dom/base/test/test_explicit_user_agent.html
@@ -0,0 +1,65 @@
+
+
+
+ Test for XMLHttpRequest.GetResponseHeader(foo) byte-inflates the output
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_file_from_blob.html b/dom/base/test/test_file_from_blob.html
new file mode 100644
index 000000000..d596d1dca
--- /dev/null
+++ b/dom/base/test/test_file_from_blob.html
@@ -0,0 +1,111 @@
+
+
+
+
+Test for crash caused by unloading and reloading srcdoc iframes
+
+
+
+
+Mozilla Bug 819900
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_file_negative_date.html b/dom/base/test/test_file_negative_date.html
new file mode 100644
index 000000000..ebfa9bd0d
--- /dev/null
+++ b/dom/base/test/test_file_negative_date.html
@@ -0,0 +1,39 @@
+
+
+
+
+ Test for negative date in File (Bug 1158437)
+
+
+
+
+
+
+Mozilla Bug 1158437
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_fileapi.html b/dom/base/test/test_fileapi.html
new file mode 100644
index 000000000..fc33c7ae6
--- /dev/null
+++ b/dom/base/test/test_fileapi.html
@@ -0,0 +1,479 @@
+
+
+
+
+ Test for Bug 414796
+
+
+
+
+
+Mozilla Bug 414796
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_fileapi_slice.html b/dom/base/test/test_fileapi_slice.html
new file mode 100644
index 000000000..efe4aa259
--- /dev/null
+++ b/dom/base/test/test_fileapi_slice.html
@@ -0,0 +1,167 @@
+
+
+
+
+ Test for Bug 575946
+
+
+
+
+
+
+Mozilla Bug 575946
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_getAttribute_after_createAttribute.html b/dom/base/test/test_getAttribute_after_createAttribute.html
new file mode 100644
index 000000000..5e2f4ec30
--- /dev/null
+++ b/dom/base/test/test_getAttribute_after_createAttribute.html
@@ -0,0 +1,15 @@
+
+
+Test for ...
+
+
+
+
diff --git a/dom/base/test/test_getElementById.html b/dom/base/test/test_getElementById.html
new file mode 100644
index 000000000..b0c2b01db
--- /dev/null
+++ b/dom/base/test/test_getElementById.html
@@ -0,0 +1,58 @@
+
+
+
+
+
+ Test for Bug 933193
+
+
+
+
+Mozilla Bug 933193
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_getTranslationNodes.html b/dom/base/test/test_getTranslationNodes.html
new file mode 100644
index 000000000..e19a0cea7
--- /dev/null
+++ b/dom/base/test/test_getTranslationNodes.html
@@ -0,0 +1,227 @@
+
+
+
+ Test for nsIDOMWindowUtils.getTranslationNodes
+
+
+
+
+
+
+
+
+
+ lorem ipsum dolor sit amet
+
+
+
+
+
+
+ lorem ipsum dolor sit amet
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ lorem
+ ipsum
+ -.,;'/!@#$%^*()
+ 0123456789
+
+
+
+
+
+
+
+
Lorem ipsum dolor sit amet , consetetur
+
Lorem ipsum dolor sit amet , consetetur
+
+
+
+
+
Lorem ipsum dolor sit amet , consetetur
+
+
+
+
+
+
+
+
+
+
+
+ Lorem Ipsum
+ Lorem Ipsum
+
+
+ code
+
+ lorem
+ ipsum
+
+
+
+
+
+
+
+
+
Lorem ipsum
+
+
Lorem ipsum
+
+
+
+
+
+
diff --git a/dom/base/test/test_getTranslationNodes_limit.html b/dom/base/test/test_getTranslationNodes_limit.html
new file mode 100644
index 000000000..8a815f49f
--- /dev/null
+++ b/dom/base/test/test_getTranslationNodes_limit.html
@@ -0,0 +1,33 @@
+
+
+
+ Test for nsIDOMWindowUtils.getTranslationNodes
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_gsp-qualified.html b/dom/base/test/test_gsp-qualified.html
new file mode 100644
index 000000000..3d670b92d
--- /dev/null
+++ b/dom/base/test/test_gsp-qualified.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+ Test for Bug 799875
+
+
+
+
+Mozilla Bug 799875
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_gsp-quirks.html b/dom/base/test/test_gsp-quirks.html
new file mode 100644
index 000000000..a315fe03e
--- /dev/null
+++ b/dom/base/test/test_gsp-quirks.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+ Test for Bug 622491
+
+
+
+
+Mozilla Bug 622491
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_gsp-standards.html b/dom/base/test/test_gsp-standards.html
new file mode 100644
index 000000000..d5349829a
--- /dev/null
+++ b/dom/base/test/test_gsp-standards.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+ Test for Bug 622491
+
+
+
+
+Mozilla Bug 622491
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_history_document_open.html b/dom/base/test/test_history_document_open.html
new file mode 100644
index 000000000..ae4f46b94
--- /dev/null
+++ b/dom/base/test/test_history_document_open.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+ Test for Bug 943418
+
+
+
+
+
+Mozilla Bug 943418
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_history_state_null.html b/dom/base/test/test_history_state_null.html
new file mode 100644
index 000000000..6eeaf52cf
--- /dev/null
+++ b/dom/base/test/test_history_state_null.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+ Test for Bug 949471
+
+
+
+
+
+Mozilla Bug 949471
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_html_colors_quirks.html b/dom/base/test/test_html_colors_quirks.html
new file mode 100644
index 000000000..68c8620db
--- /dev/null
+++ b/dom/base/test/test_html_colors_quirks.html
@@ -0,0 +1,711 @@
+
+
+
+
+ Test for Bug 121738
+
+
+
+
+Mozilla Bug 121738
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_html_colors_standards.html b/dom/base/test/test_html_colors_standards.html
new file mode 100644
index 000000000..a466bd765
--- /dev/null
+++ b/dom/base/test/test_html_colors_standards.html
@@ -0,0 +1,712 @@
+
+
+
+
+
+ Test for Bug 121738
+
+
+
+
+Mozilla Bug 121738
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_htmlcopyencoder.html b/dom/base/test/test_htmlcopyencoder.html
new file mode 100644
index 000000000..dbd87471f
--- /dev/null
+++ b/dom/base/test/test_htmlcopyencoder.html
@@ -0,0 +1,196 @@
+
+
+
+
+ Test on the html copy encoder
+
+
+
+
+Mozilla Bug
+
+
+
+
+
+
+
+
+
This is a draggable bit of text.
+
+
+
+
+
+ Lorem ipsum dolor
+ sit amet, consectetuer
+ adipiscing elit
+ Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class
+ aptent taciti
+
+foo bar
+
+
+
+
+
diff --git a/dom/base/test/test_htmlcopyencoder.xhtml b/dom/base/test/test_htmlcopyencoder.xhtml
new file mode 100644
index 000000000..57559fc00
--- /dev/null
+++ b/dom/base/test/test_htmlcopyencoder.xhtml
@@ -0,0 +1,180 @@
+
+
+
+
+ Test the html copy encoder with XHTML
+
+
+
+
+Mozilla Bug
+
+
+
+
+
+
+
+
+
This is a draggable bit of text.
+
+
+
+
+
+ Lorem ipsum dolor
+ sit amet, consectetuer
+ adipiscing elit
+ Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class
+ aptent taciti
+
+foo bar
+
+
+
diff --git a/dom/base/test/test_iframe_referrer.html b/dom/base/test/test_iframe_referrer.html
new file mode 100644
index 000000000..3c46096b9
--- /dev/null
+++ b/dom/base/test/test_iframe_referrer.html
@@ -0,0 +1,107 @@
+
+
+
+
+ Test iframe referrer policy attribute for Bug 1175736
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_iframe_referrer_changing.html b/dom/base/test/test_iframe_referrer_changing.html
new file mode 100644
index 000000000..c65058fe8
--- /dev/null
+++ b/dom/base/test/test_iframe_referrer_changing.html
@@ -0,0 +1,50 @@
+
+
+
+
+ Test iframe referrer policy attribute for Bug 1175736
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_iframe_referrer_invalid.html b/dom/base/test/test_iframe_referrer_invalid.html
new file mode 100644
index 000000000..c4bd1d6ac
--- /dev/null
+++ b/dom/base/test/test_iframe_referrer_invalid.html
@@ -0,0 +1,81 @@
+
+
+
+
+ Test iframe referrer policy attribute for Bug 1175736
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_img_referrer.html b/dom/base/test/test_img_referrer.html
new file mode 100644
index 000000000..16259bcc3
--- /dev/null
+++ b/dom/base/test/test_img_referrer.html
@@ -0,0 +1,189 @@
+
+
+
+
+ Test img policy attribute for Bug 1166910
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_innersize_scrollport.html b/dom/base/test/test_innersize_scrollport.html
new file mode 100644
index 000000000..a000e9355
--- /dev/null
+++ b/dom/base/test/test_innersize_scrollport.html
@@ -0,0 +1,48 @@
+
+
+
+
+ Test for Bug 919437
+
+
+
+
+Mozilla Bug 919437
+
+
+
+
+
+
diff --git a/dom/base/test/test_integer_attr_with_leading_zero.html b/dom/base/test/test_integer_attr_with_leading_zero.html
new file mode 100644
index 000000000..816fb331c
--- /dev/null
+++ b/dom/base/test/test_integer_attr_with_leading_zero.html
@@ -0,0 +1,64 @@
+
+
+Test for parsing of integer attributes with leading zero
+
+
+
+
diff --git a/dom/base/test/test_intersectionobservers.html b/dom/base/test/test_intersectionobservers.html
new file mode 100644
index 000000000..e7875e3af
--- /dev/null
+++ b/dom/base/test/test_intersectionobservers.html
@@ -0,0 +1,1214 @@
+
+
+
+
+
+ Test for Bug 1243846
+
+
+
+
+Mozilla Bug 1243846
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_ipc_messagemanager_blob.html b/dom/base/test/test_ipc_messagemanager_blob.html
new file mode 100644
index 000000000..74eab2945
--- /dev/null
+++ b/dom/base/test/test_ipc_messagemanager_blob.html
@@ -0,0 +1,143 @@
+
+
+
+ Test for OOP Blobs in MessageManager
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_link_prefetch.html b/dom/base/test/test_link_prefetch.html
new file mode 100644
index 000000000..c13492fd1
--- /dev/null
+++ b/dom/base/test/test_link_prefetch.html
@@ -0,0 +1,220 @@
+
+
+
+
+ Test link policy attribute for Bug 1264165
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_link_stylesheet.html b/dom/base/test/test_link_stylesheet.html
new file mode 100644
index 000000000..58f70668a
--- /dev/null
+++ b/dom/base/test/test_link_stylesheet.html
@@ -0,0 +1,221 @@
+
+
+
+
+ Test link policy attribute for Bug 1264165
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_messagePort.html b/dom/base/test/test_messagePort.html
new file mode 100644
index 000000000..6f37e683e
--- /dev/null
+++ b/dom/base/test/test_messagePort.html
@@ -0,0 +1,115 @@
+
+
+
+
+
+ Test for Bug 912456 - port cloning
+
+
+
+
+Mozilla Bug 912456
+
+
+
+
diff --git a/dom/base/test/test_messagemanager_principal.html b/dom/base/test/test_messagemanager_principal.html
new file mode 100644
index 000000000..cd5528e67
--- /dev/null
+++ b/dom/base/test/test_messagemanager_principal.html
@@ -0,0 +1,95 @@
+
+
+
+ Test for Principal in MessageManager
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_messagemanager_send_principal.html b/dom/base/test/test_messagemanager_send_principal.html
new file mode 100644
index 000000000..c50cdfeb3
--- /dev/null
+++ b/dom/base/test/test_messagemanager_send_principal.html
@@ -0,0 +1,131 @@
+
+
+
+ Test for Principal in MessageManager
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_messagemanager_targetchain.html b/dom/base/test/test_messagemanager_targetchain.html
new file mode 100644
index 000000000..3f3f8f60f
--- /dev/null
+++ b/dom/base/test/test_messagemanager_targetchain.html
@@ -0,0 +1,126 @@
+
+
+
+ Test for EventTarget chain of MessageManagers
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_meta_viewport0.html b/dom/base/test/test_meta_viewport0.html
new file mode 100644
index 000000000..0e0d8991c
--- /dev/null
+++ b/dom/base/test/test_meta_viewport0.html
@@ -0,0 +1,81 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+ No <meta name="viewport"> tag
+
+
+
diff --git a/dom/base/test/test_meta_viewport1.html b/dom/base/test/test_meta_viewport1.html
new file mode 100644
index 000000000..678931d4e
--- /dev/null
+++ b/dom/base/test/test_meta_viewport1.html
@@ -0,0 +1,77 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+
+ width=device-width, initial-scale=1
+
+
+
diff --git a/dom/base/test/test_meta_viewport2.html b/dom/base/test/test_meta_viewport2.html
new file mode 100644
index 000000000..c31d1909e
--- /dev/null
+++ b/dom/base/test/test_meta_viewport2.html
@@ -0,0 +1,77 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+
+ width=device-width
+
+
+
diff --git a/dom/base/test/test_meta_viewport3.html b/dom/base/test/test_meta_viewport3.html
new file mode 100644
index 000000000..cf1153d49
--- /dev/null
+++ b/dom/base/test/test_meta_viewport3.html
@@ -0,0 +1,79 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+
+ width=320
+
+
+
diff --git a/dom/base/test/test_meta_viewport4.html b/dom/base/test/test_meta_viewport4.html
new file mode 100644
index 000000000..9e53419ae
--- /dev/null
+++ b/dom/base/test/test_meta_viewport4.html
@@ -0,0 +1,78 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+
+ initial-scale=1.0, user-scalable=no
+
+
+
diff --git a/dom/base/test/test_meta_viewport5.html b/dom/base/test/test_meta_viewport5.html
new file mode 100644
index 000000000..739e5b7fe
--- /dev/null
+++ b/dom/base/test/test_meta_viewport5.html
@@ -0,0 +1,54 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+
+ user-scalable=NO
+
+
+
diff --git a/dom/base/test/test_meta_viewport6.html b/dom/base/test/test_meta_viewport6.html
new file mode 100644
index 000000000..b003ed2c0
--- /dev/null
+++ b/dom/base/test/test_meta_viewport6.html
@@ -0,0 +1,83 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+
+ width=2000, minimum-scale=0.75
+
+
+
diff --git a/dom/base/test/test_meta_viewport7.html b/dom/base/test/test_meta_viewport7.html
new file mode 100644
index 000000000..373674c53
--- /dev/null
+++ b/dom/base/test/test_meta_viewport7.html
@@ -0,0 +1,114 @@
+
+
+
+
+ meta viewport test
+
+
+
+
+
+
+ Dynamic viewport updates
+
+
+
diff --git a/dom/base/test/test_mozMatchesSelector.html b/dom/base/test/test_mozMatchesSelector.html
new file mode 100644
index 000000000..3f163e07a
--- /dev/null
+++ b/dom/base/test/test_mozMatchesSelector.html
@@ -0,0 +1,14 @@
+
+
+Test for legacy mozMatchesSelector
+
+
+
+
+
diff --git a/dom/base/test/test_mozbrowser_apis_allowed.html b/dom/base/test/test_mozbrowser_apis_allowed.html
new file mode 100644
index 000000000..86ff3e2ff
--- /dev/null
+++ b/dom/base/test/test_mozbrowser_apis_allowed.html
@@ -0,0 +1,46 @@
+
+
+
+ Verify mozbrowser APIs are allowed with browser permission
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_mozbrowser_apis_blocked.html b/dom/base/test/test_mozbrowser_apis_blocked.html
new file mode 100644
index 000000000..303c48625
--- /dev/null
+++ b/dom/base/test/test_mozbrowser_apis_blocked.html
@@ -0,0 +1,38 @@
+
+
+
+ Verify mozbrowser APIs are blocked without browser permission
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_mozfiledataurl.html b/dom/base/test/test_mozfiledataurl.html
new file mode 100644
index 000000000..b842336d8
--- /dev/null
+++ b/dom/base/test/test_mozfiledataurl.html
@@ -0,0 +1,225 @@
+
+
+
+
+ Test for File urls
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_mutationobserver_anonymous.html b/dom/base/test/test_mutationobserver_anonymous.html
new file mode 100644
index 000000000..98ff6e3a4
--- /dev/null
+++ b/dom/base/test/test_mutationobserver_anonymous.html
@@ -0,0 +1,265 @@
+
+
+
+
+ Test for Bug 1034110
+
+
+
+
+
+Mozilla Bug 1034110
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_mutationobservers.html b/dom/base/test/test_mutationobservers.html
new file mode 100644
index 000000000..bde07c79c
--- /dev/null
+++ b/dom/base/test/test_mutationobservers.html
@@ -0,0 +1,935 @@
+
+
+
+
+
+ Test for Bug 641821
+
+
+
+
+Mozilla Bug 641821
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_named_frames.html b/dom/base/test/test_named_frames.html
new file mode 100644
index 000000000..e2cc572ca
--- /dev/null
+++ b/dom/base/test/test_named_frames.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+ Test for Bug 823227
+
+
+
+
+
+Mozilla Bug 823227
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_navigatorPrefOverride.html b/dom/base/test/test_navigatorPrefOverride.html
new file mode 100644
index 000000000..d2c5133e8
--- /dev/null
+++ b/dom/base/test/test_navigatorPrefOverride.html
@@ -0,0 +1,54 @@
+
+
+
+
+ Test for navigator property override
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_navigator_hardwareConcurrency.html b/dom/base/test/test_navigator_hardwareConcurrency.html
new file mode 100644
index 000000000..b48e640e6
--- /dev/null
+++ b/dom/base/test/test_navigator_hardwareConcurrency.html
@@ -0,0 +1,24 @@
+
+
+
+
+ Test for Navigator.hardwareConcurrency
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_navigator_language.html b/dom/base/test/test_navigator_language.html
new file mode 100644
index 000000000..7b986aecb
--- /dev/null
+++ b/dom/base/test/test_navigator_language.html
@@ -0,0 +1,212 @@
+
+
+
+
+
+ Test for NavigatorLanguage
+
+
+
+
+Mozilla Bug 889335
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_navigator_resolve_identity_xrays.xul b/dom/base/test/test_navigator_resolve_identity_xrays.xul
new file mode 100644
index 000000000..cf3e23d9f
--- /dev/null
+++ b/dom/base/test/test_navigator_resolve_identity_xrays.xul
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+ Mozilla Bug 985827
+
+
+
+
+
+
diff --git a/dom/base/test/test_noAudioNotification.html b/dom/base/test/test_noAudioNotification.html
new file mode 100644
index 000000000..18ac833a8
--- /dev/null
+++ b/dom/base/test/test_noAudioNotification.html
@@ -0,0 +1,77 @@
+
+
+
+ Test for video controller in windows
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_noAudioNotificationOnMutedElement.html b/dom/base/test/test_noAudioNotificationOnMutedElement.html
new file mode 100644
index 000000000..e9cdd2759
--- /dev/null
+++ b/dom/base/test/test_noAudioNotificationOnMutedElement.html
@@ -0,0 +1,129 @@
+
+
+
+ Test for audio controller in windows
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_noAudioNotificationOnMutedOrVolume0Element.html b/dom/base/test/test_noAudioNotificationOnMutedOrVolume0Element.html
new file mode 100644
index 000000000..0e4cc93f0
--- /dev/null
+++ b/dom/base/test/test_noAudioNotificationOnMutedOrVolume0Element.html
@@ -0,0 +1,162 @@
+
+
+
+ Test for audio controller in windows
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_noAudioNotificationOnVolume0Element.html b/dom/base/test/test_noAudioNotificationOnVolume0Element.html
new file mode 100644
index 000000000..530dc88bf
--- /dev/null
+++ b/dom/base/test/test_noAudioNotificationOnVolume0Element.html
@@ -0,0 +1,129 @@
+
+
+
+ Test for audio controller in windows
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_noWebAudioNotification.html b/dom/base/test/test_noWebAudioNotification.html
new file mode 100644
index 000000000..794f92d57
--- /dev/null
+++ b/dom/base/test/test_noWebAudioNotification.html
@@ -0,0 +1,62 @@
+
+
+
+ Test for video controller in windows
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_nodelist_holes.html b/dom/base/test/test_nodelist_holes.html
new file mode 100644
index 000000000..a8aa8934f
--- /dev/null
+++ b/dom/base/test/test_nodelist_holes.html
@@ -0,0 +1,42 @@
+
+
+
+
+ Test for Bug 699826
+
+
+
+
+Mozilla Bug 699826
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_nonascii_blob_url.html b/dom/base/test/test_nonascii_blob_url.html
new file mode 100644
index 000000000..ce5d050e2
--- /dev/null
+++ b/dom/base/test/test_nonascii_blob_url.html
@@ -0,0 +1,30 @@
+
+
+
+ Test blob URL for non-ascii domain
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_openDialogChromeOnly.html b/dom/base/test/test_openDialogChromeOnly.html
new file mode 100644
index 000000000..6548668c0
--- /dev/null
+++ b/dom/base/test/test_openDialogChromeOnly.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+ Test for Bug 931768
+
+
+
+
+
+
+
+
+
+Mozilla Bug 931768
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_open_null_features.html b/dom/base/test/test_open_null_features.html
new file mode 100644
index 000000000..f3f1e6196
--- /dev/null
+++ b/dom/base/test/test_open_null_features.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+ Test for Bug 1009529
+
+
+
+
+
+Mozilla Bug 1009529
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_orientation_alternate.html b/dom/base/test/test_orientation_alternate.html
new file mode 100644
index 000000000..7276ad82c
--- /dev/null
+++ b/dom/base/test/test_orientation_alternate.html
@@ -0,0 +1,27 @@
+
+
+Test for ScreenOrientation API
+
+
+
+
+
diff --git a/dom/base/test/test_orientation_frame.html b/dom/base/test/test_orientation_frame.html
new file mode 100644
index 000000000..748b3264e
--- /dev/null
+++ b/dom/base/test/test_orientation_frame.html
@@ -0,0 +1,37 @@
+
+
+Test for ScreenOrientation API
+
+
+
+
+
+
diff --git a/dom/base/test/test_orientation_frame_lock.html b/dom/base/test/test_orientation_frame_lock.html
new file mode 100644
index 000000000..f8b7a65d0
--- /dev/null
+++ b/dom/base/test/test_orientation_frame_lock.html
@@ -0,0 +1,46 @@
+
+
+Test for ScreenOrientation API
+
+
+
+
+
+
diff --git a/dom/base/test/test_orientation_sandbox_no_lock.html b/dom/base/test/test_orientation_sandbox_no_lock.html
new file mode 100644
index 000000000..e020a6daa
--- /dev/null
+++ b/dom/base/test/test_orientation_sandbox_no_lock.html
@@ -0,0 +1,36 @@
+
+
+Test for ScreenOrientation API
+
+
+
+
+
+
diff --git a/dom/base/test/test_pluginAudioNotification.html b/dom/base/test/test_pluginAudioNotification.html
new file mode 100644
index 000000000..399a4307f
--- /dev/null
+++ b/dom/base/test/test_pluginAudioNotification.html
@@ -0,0 +1,121 @@
+
+
+
+ Test for audio controller in windows
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_pluginMutedBeforePlay.html b/dom/base/test/test_pluginMutedBeforePlay.html
new file mode 100644
index 000000000..658875dc9
--- /dev/null
+++ b/dom/base/test/test_pluginMutedBeforePlay.html
@@ -0,0 +1,76 @@
+
+
+
+ Mute window before the plugin starts playing
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_plugin_freezing.html b/dom/base/test/test_plugin_freezing.html
new file mode 100644
index 000000000..41d41be58
--- /dev/null
+++ b/dom/base/test/test_plugin_freezing.html
@@ -0,0 +1,68 @@
+
+
+
+ Test for plugin freezing and thawing
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_postMessage_originAttributes.html b/dom/base/test/test_postMessage_originAttributes.html
new file mode 100644
index 000000000..5ababc1d4
--- /dev/null
+++ b/dom/base/test/test_postMessage_originAttributes.html
@@ -0,0 +1,60 @@
+
+
+
+ Test window.postMessages from system principal to window with non-default originAttributes
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_postMessage_solidus.html b/dom/base/test/test_postMessage_solidus.html
new file mode 100644
index 000000000..ab3e4ecec
--- /dev/null
+++ b/dom/base/test/test_postMessage_solidus.html
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+ Test for Bug 949488 - basic support
+
+
+
+
+ Mozilla Bug 949488
+
+
+
+
diff --git a/dom/base/test/test_postMessages.html b/dom/base/test/test_postMessages.html
new file mode 100644
index 000000000..13a284270
--- /dev/null
+++ b/dom/base/test/test_postMessages.html
@@ -0,0 +1,654 @@
+
+
+
+ Test for postMessages cloning/transferring objects
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_processing_instruction_update_stylesheet.xhtml b/dom/base/test/test_processing_instruction_update_stylesheet.xhtml
new file mode 100644
index 000000000..c921bcc1c
--- /dev/null
+++ b/dom/base/test/test_processing_instruction_update_stylesheet.xhtml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+ Test for Bug 888864
+
+
+
+
+
+This changes color
+Mozilla Bug 888864
+
+
+
+
diff --git a/dom/base/test/test_progress_events_for_gzip_data.html b/dom/base/test/test_progress_events_for_gzip_data.html
new file mode 100644
index 000000000..46a048934
--- /dev/null
+++ b/dom/base/test/test_progress_events_for_gzip_data.html
@@ -0,0 +1,44 @@
+
+
+
+ Test progess events in case of gzipped data.
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_range_bounds.html b/dom/base/test/test_range_bounds.html
new file mode 100644
index 000000000..bebb81d8e
--- /dev/null
+++ b/dom/base/test/test_range_bounds.html
@@ -0,0 +1,288 @@
+
+
+
+
+ Test for Bug 396392
+
+
+
+
+
+
+Mozilla Bug Range getClientRects and getBoundingClientRect
+
+
0000000
000000
00000000 0000
000000000000 00000000000000 000000
000000000000 00000000000003 100305
+
+english rtl-overide english word
+english rtl-override english word
+
+
+
+
+
diff --git a/dom/base/test/test_reentrant_flush.html b/dom/base/test/test_reentrant_flush.html
new file mode 100644
index 000000000..fe1088526
--- /dev/null
+++ b/dom/base/test/test_reentrant_flush.html
@@ -0,0 +1,61 @@
+
+
+
+
+ Test for Bug 709256
+
+
+
+
+Mozilla Bug 709256
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_referrer_redirect.html b/dom/base/test/test_referrer_redirect.html
new file mode 100644
index 000000000..b5d968b6f
--- /dev/null
+++ b/dom/base/test/test_referrer_redirect.html
@@ -0,0 +1,72 @@
+
+
+
+
+ Test anchor and area policy attribute for Bug 1184781
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_root_iframe.html b/dom/base/test/test_root_iframe.html
new file mode 100644
index 000000000..ce99cc228
--- /dev/null
+++ b/dom/base/test/test_root_iframe.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+ Test for Bug 511084
+
+
+
+
+Mozilla Bug 511084
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_sandboxed_blob_uri.html b/dom/base/test/test_sandboxed_blob_uri.html
new file mode 100644
index 000000000..8b94d7273
--- /dev/null
+++ b/dom/base/test/test_sandboxed_blob_uri.html
@@ -0,0 +1,24 @@
+
+
+
+ Test for Principal in MessageManager
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_screen_orientation.html b/dom/base/test/test_screen_orientation.html
new file mode 100644
index 000000000..ea3016eef
--- /dev/null
+++ b/dom/base/test/test_screen_orientation.html
@@ -0,0 +1,86 @@
+
+
+
+
+
+ Test for Screen Orientation API
+
+
+
+
+Screen Orientation API
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_script_loader_crossorigin_data_url.html b/dom/base/test/test_script_loader_crossorigin_data_url.html
new file mode 100644
index 000000000..cfbb90c8d
--- /dev/null
+++ b/dom/base/test/test_script_loader_crossorigin_data_url.html
@@ -0,0 +1,38 @@
+
+
+Test for handling of 'crossorigin' attribute on script with data: URL
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_sendQueryContentAndSelectionSetEvent.html b/dom/base/test/test_sendQueryContentAndSelectionSetEvent.html
new file mode 100644
index 000000000..369ed1c9d
--- /dev/null
+++ b/dom/base/test/test_sendQueryContentAndSelectionSetEvent.html
@@ -0,0 +1,250 @@
+
+
+
+ Test for nsIDOMWindowUtils.sendQueryContentEvent() and .sendSelectionSetEvent()
+
+
+
+
+
+
+
+
+abc def
+
+
+
+
+
diff --git a/dom/base/test/test_setInterval_uncatchable_exception.html b/dom/base/test/test_setInterval_uncatchable_exception.html
new file mode 100644
index 000000000..70a1d96c0
--- /dev/null
+++ b/dom/base/test/test_setInterval_uncatchable_exception.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+ Test for Bug 1252268
+
+
+
+
+Mozilla Bug 1252268
+
+
+
+
+
diff --git a/dom/base/test/test_setTimeoutWith0.html b/dom/base/test/test_setTimeoutWith0.html
new file mode 100644
index 000000000..71e653da7
--- /dev/null
+++ b/dom/base/test/test_setTimeoutWith0.html
@@ -0,0 +1,22 @@
+
+
+ Test for setTimeout and strings containing 0
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_settimeout_extra_arguments.html b/dom/base/test/test_settimeout_extra_arguments.html
new file mode 100644
index 000000000..b790eff06
--- /dev/null
+++ b/dom/base/test/test_settimeout_extra_arguments.html
@@ -0,0 +1,12 @@
+
+
+Test for setTimeout with a string argument and more than 2 arguments
+
+
+
+
diff --git a/dom/base/test/test_settimeout_inner.html b/dom/base/test/test_settimeout_inner.html
new file mode 100644
index 000000000..b0e6a9d4e
--- /dev/null
+++ b/dom/base/test/test_settimeout_inner.html
@@ -0,0 +1,53 @@
+
+
+
+
+
+ Test for Bug 936129
+
+
+
+
+
+Mozilla Bug 936129
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_setting_opener.html b/dom/base/test/test_setting_opener.html
new file mode 100644
index 000000000..babdf8570
--- /dev/null
+++ b/dom/base/test/test_setting_opener.html
@@ -0,0 +1,125 @@
+
+
+
+
+
+ Test for Bug 868996
+
+
+
+
+
+Mozilla Bug 868996
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_simplecontentpolicy.html b/dom/base/test/test_simplecontentpolicy.html
new file mode 100644
index 000000000..9fa5dd3fd
--- /dev/null
+++ b/dom/base/test/test_simplecontentpolicy.html
@@ -0,0 +1,149 @@
+
+
+
+ Test for nsISimpleContentPolicy
+
+
+
+
+Mozilla Bug 1128798
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_text_wholeText.html b/dom/base/test/test_text_wholeText.html
new file mode 100644
index 000000000..31fa0f076
--- /dev/null
+++ b/dom/base/test/test_text_wholeText.html
@@ -0,0 +1,232 @@
+
+
+
+
+ Text.wholeText tests
+
+
+
+
+Mozilla Bug 421765
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_textnode_normalize_in_selection.html b/dom/base/test/test_textnode_normalize_in_selection.html
new file mode 100644
index 000000000..f87973214
--- /dev/null
+++ b/dom/base/test/test_textnode_normalize_in_selection.html
@@ -0,0 +1,201 @@
+
+
+
+
+
+ Test for Bug 804784
+
+
+
+
+Mozilla Bug 804784
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_textnode_split_in_selection.html b/dom/base/test/test_textnode_split_in_selection.html
new file mode 100644
index 000000000..e9bcba2ea
--- /dev/null
+++ b/dom/base/test/test_textnode_split_in_selection.html
@@ -0,0 +1,221 @@
+
+
+
+
+
+ Test for Bug 803924
+
+
+
+
+Mozilla Bug 803924
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_timer_flood.html b/dom/base/test/test_timer_flood.html
new file mode 100644
index 000000000..b74b04cf2
--- /dev/null
+++ b/dom/base/test/test_timer_flood.html
@@ -0,0 +1,116 @@
+
+
+
+
+ Test Behavior During Timer Flood
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_title.html b/dom/base/test/test_title.html
new file mode 100644
index 000000000..8d735b453
--- /dev/null
+++ b/dom/base/test/test_title.html
@@ -0,0 +1,54 @@
+
+
+
+
+ Test for titles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_treewalker_nextsibling.xml b/dom/base/test/test_treewalker_nextsibling.xml
new file mode 100644
index 000000000..a10ab31a0
--- /dev/null
+++ b/dom/base/test/test_treewalker_nextsibling.xml
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ zero
+
+ one-A
+
+ two-A
+
+
+ two-B
+
+ one-B
+
+
+ one-C
+
+ two-D
+
+
+ two-E
+
+ one-F
+
+ zero
+
+
+
diff --git a/dom/base/test/test_user_select.html b/dom/base/test/test_user_select.html
new file mode 100644
index 000000000..c2b117597
--- /dev/null
+++ b/dom/base/test/test_user_select.html
@@ -0,0 +1,341 @@
+
+
+
+-moz-user-select selection tests
+
+
+
+
+
+
+
+
+
+aaaaaaabbbbbbbb ccccccc
+aaaaaaa bbbbbbbbccccccc
+aaaaaaabbbbbbbbccccccc
+aaaaaaabbbbbbbb ccccccc
+aaaaaaa bbbbbbbbccccccc
+aaaaaaabbbbbbbbccccccc
+aaaaaaabbbb bbbb ccccccc
+aaaaa aa bbbbbbbbccccccc
+aaaaaaabbbbbbbbccccccc
+aaaaaaabbbbbbbb ccccccc
+aaaa aaa bbbbbbbbccccccc
+aaaaaaabbbbbbbbccc cccc
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_viewport_scroll.html b/dom/base/test/test_viewport_scroll.html
new file mode 100644
index 000000000..9b812360b
--- /dev/null
+++ b/dom/base/test/test_viewport_scroll.html
@@ -0,0 +1,89 @@
+
+
+
+ Test for mapping of scrollTop/scrollLeft to viewport
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_viewsource_forbidden_in_object.html b/dom/base/test/test_viewsource_forbidden_in_object.html
new file mode 100644
index 000000000..67ad367ef
--- /dev/null
+++ b/dom/base/test/test_viewsource_forbidden_in_object.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+Tests for Bug 973837
+
+
+
+
+
+
+
+Mozilla Bug 973837
+
+
+
+
+
+
diff --git a/dom/base/test/test_w3element_traversal.html b/dom/base/test/test_w3element_traversal.html
new file mode 100644
index 000000000..fdd4ac03c
--- /dev/null
+++ b/dom/base/test/test_w3element_traversal.html
@@ -0,0 +1,148 @@
+
+
+
+
+ W3 Tests for Element Traversal - HTML
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_w3element_traversal.xhtml b/dom/base/test/test_w3element_traversal.xhtml
new file mode 100644
index 000000000..28ef46511
--- /dev/null
+++ b/dom/base/test/test_w3element_traversal.xhtml
@@ -0,0 +1,149 @@
+
+
+
+
+
+ W3 Tests for Element Traversal - XHTML
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_w3element_traversal_svg.html b/dom/base/test/test_w3element_traversal_svg.html
new file mode 100644
index 000000000..7a1407434
--- /dev/null
+++ b/dom/base/test/test_w3element_traversal_svg.html
@@ -0,0 +1,107 @@
+
+
+
+ Test for ElementTraversal via SVG
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_warning_for_blocked_cross_site_request.html b/dom/base/test/test_warning_for_blocked_cross_site_request.html
new file mode 100644
index 000000000..590506d2e
--- /dev/null
+++ b/dom/base/test/test_warning_for_blocked_cross_site_request.html
@@ -0,0 +1,92 @@
+
+
+
+
+
+ Test for Bug 713980
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_webSocket_sandbox.html b/dom/base/test/test_webSocket_sandbox.html
new file mode 100644
index 000000000..b343fa784
--- /dev/null
+++ b/dom/base/test/test_webSocket_sandbox.html
@@ -0,0 +1,34 @@
+
+
+
+ Bug 1252751
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_webaudioNotification.html b/dom/base/test/test_webaudioNotification.html
new file mode 100644
index 000000000..d010e916b
--- /dev/null
+++ b/dom/base/test/test_webaudioNotification.html
@@ -0,0 +1,81 @@
+
+
+
+ Test for audio controller in windows
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_webaudioNotificationStopOnNavigation.html b/dom/base/test/test_webaudioNotificationStopOnNavigation.html
new file mode 100644
index 000000000..237d67402
--- /dev/null
+++ b/dom/base/test/test_webaudioNotificationStopOnNavigation.html
@@ -0,0 +1,71 @@
+
+
+
+ Test for audio controller in windows
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket1.html b/dom/base/test/test_websocket1.html
new file mode 100644
index 000000000..1894f5314
--- /dev/null
+++ b/dom/base/test/test_websocket1.html
@@ -0,0 +1,42 @@
+
+
+
+
+ WebSocket test
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket2.html b/dom/base/test/test_websocket2.html
new file mode 100644
index 000000000..5711057cf
--- /dev/null
+++ b/dom/base/test/test_websocket2.html
@@ -0,0 +1,44 @@
+
+
+
+
+ WebSocket test
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket3.html b/dom/base/test/test_websocket3.html
new file mode 100644
index 000000000..57482dae7
--- /dev/null
+++ b/dom/base/test/test_websocket3.html
@@ -0,0 +1,44 @@
+
+
+
+
+ WebSocket test
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket4.html b/dom/base/test/test_websocket4.html
new file mode 100644
index 000000000..4bc700fb8
--- /dev/null
+++ b/dom/base/test/test_websocket4.html
@@ -0,0 +1,42 @@
+
+
+
+
+ WebSocket test
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket5.html b/dom/base/test/test_websocket5.html
new file mode 100644
index 000000000..70a948821
--- /dev/null
+++ b/dom/base/test/test_websocket5.html
@@ -0,0 +1,40 @@
+
+
+
+
+ WebSocket test
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket_basic.html b/dom/base/test/test_websocket_basic.html
new file mode 100644
index 000000000..e3269382e
--- /dev/null
+++ b/dom/base/test/test_websocket_basic.html
@@ -0,0 +1,255 @@
+
+
+
+ Basic WebSocket test
+
+
+
+
+
+Mozilla Bug 472529
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket_frame.html b/dom/base/test/test_websocket_frame.html
new file mode 100644
index 000000000..59ab85907
--- /dev/null
+++ b/dom/base/test/test_websocket_frame.html
@@ -0,0 +1,166 @@
+
+
+
+
+ Basic websocket frame interception test
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket_hello.html b/dom/base/test/test_websocket_hello.html
new file mode 100644
index 000000000..c1874ab98
--- /dev/null
+++ b/dom/base/test/test_websocket_hello.html
@@ -0,0 +1,49 @@
+
+
+
+
+ Basic websocket test
+
+
+
+
+Mozilla Bug
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_websocket_permessage_deflate.html b/dom/base/test/test_websocket_permessage_deflate.html
new file mode 100644
index 000000000..5c40600c4
--- /dev/null
+++ b/dom/base/test/test_websocket_permessage_deflate.html
@@ -0,0 +1,110 @@
+
+
+
+ Basic test of permessage compression websocket extension
+
+
+
+
+Mozilla Bug
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_constructor.html b/dom/base/test/test_window_constructor.html
new file mode 100644
index 000000000..702043839
--- /dev/null
+++ b/dom/base/test/test_window_constructor.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+ Test for Bug 824217
+
+
+
+
+Mozilla Bug 824217
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_cross_origin_props.html b/dom/base/test/test_window_cross_origin_props.html
new file mode 100644
index 000000000..d16a103fb
--- /dev/null
+++ b/dom/base/test/test_window_cross_origin_props.html
@@ -0,0 +1,101 @@
+
+
+
+
+
+ Test for Bug 946067
+
+
+
+
+
+Mozilla Bug 946067
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_define_nonconfigurable.html b/dom/base/test/test_window_define_nonconfigurable.html
new file mode 100644
index 000000000..ad1cf7687
--- /dev/null
+++ b/dom/base/test/test_window_define_nonconfigurable.html
@@ -0,0 +1,49 @@
+
+
+
+
+
+ Test for Bug 1107443
+
+
+
+
+
+Mozilla Bug 1107443
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_define_symbol.html b/dom/base/test/test_window_define_symbol.html
new file mode 100644
index 000000000..95ea9e6ee
--- /dev/null
+++ b/dom/base/test/test_window_define_symbol.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+ Test for Bug 1082672 part 2
+
+
+
+
+Mozilla Bug 1082672
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_element_enumeration.html b/dom/base/test/test_window_element_enumeration.html
new file mode 100644
index 000000000..f8ea6728c
--- /dev/null
+++ b/dom/base/test/test_window_element_enumeration.html
@@ -0,0 +1,70 @@
+
+
+
+
+
+ Test for Bug 959992
+
+
+
+
+Mozilla Bug 959992
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_enumeration.html b/dom/base/test/test_window_enumeration.html
new file mode 100644
index 000000000..c2377426c
--- /dev/null
+++ b/dom/base/test/test_window_enumeration.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Test for Bug 807222
+
+
+
+
+Mozilla Bug 807222
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_extensible.html b/dom/base/test/test_window_extensible.html
new file mode 100644
index 000000000..5f9f09291
--- /dev/null
+++ b/dom/base/test/test_window_extensible.html
@@ -0,0 +1,46 @@
+
+
+
+
+
+ Test for Bug 856384
+
+
+
+
+Mozilla Bug 856384
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_indexing.html b/dom/base/test/test_window_indexing.html
new file mode 100644
index 000000000..c7450adda
--- /dev/null
+++ b/dom/base/test/test_window_indexing.html
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+ Test for Bug 823228
+
+
+
+
+Mozilla Bug 823228
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_named_frame_enumeration.html b/dom/base/test/test_window_named_frame_enumeration.html
new file mode 100644
index 000000000..4d3335db4
--- /dev/null
+++ b/dom/base/test/test_window_named_frame_enumeration.html
@@ -0,0 +1,96 @@
+
+
+
+
+
+ Test for Bug 1019417
+
+
+
+
+
+Mozilla Bug 1019417
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_window_orientation.html b/dom/base/test/test_window_orientation.html
new file mode 100644
index 000000000..4921a95cd
--- /dev/null
+++ b/dom/base/test/test_window_orientation.html
@@ -0,0 +1,33 @@
+
+
+Test for window.orientation
+
+
+
+
+
diff --git a/dom/base/test/test_window_proto.html b/dom/base/test/test_window_proto.html
new file mode 100644
index 000000000..944f953bc
--- /dev/null
+++ b/dom/base/test/test_window_proto.html
@@ -0,0 +1,17 @@
+
+
+Test for ...
+
+
+
+
diff --git a/dom/base/test/test_writable-replaceable.html b/dom/base/test/test_writable-replaceable.html
new file mode 100644
index 000000000..20aad7aef
--- /dev/null
+++ b/dom/base/test/test_writable-replaceable.html
@@ -0,0 +1,49 @@
+
+
+
+
+ Test for Bug 823283
+
+
+
+
+Mozilla Bug 823283
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_x-frame-options.html b/dom/base/test/test_x-frame-options.html
new file mode 100644
index 000000000..8e24d8a78
--- /dev/null
+++ b/dom/base/test/test_x-frame-options.html
@@ -0,0 +1,156 @@
+
+
+
+ Test for X-Frame-Options response header
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_xbl_userdata.xhtml b/dom/base/test/test_xbl_userdata.xhtml
new file mode 100644
index 000000000..852298853
--- /dev/null
+++ b/dom/base/test/test_xbl_userdata.xhtml
@@ -0,0 +1,56 @@
+
+
+
+ Test for getUserData/setUserData support in XBL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/test_youtube_flash_embed.html b/dom/base/test/test_youtube_flash_embed.html
new file mode 100644
index 000000000..9b7f25d0f
--- /dev/null
+++ b/dom/base/test/test_youtube_flash_embed.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+ Test for Bug 1240471
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/unit/1_original.xml b/dom/base/test/unit/1_original.xml
new file mode 100644
index 000000000..4b7915159
--- /dev/null
+++ b/dom/base/test/unit/1_original.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/1_result.xml b/dom/base/test/unit/1_result.xml
new file mode 100644
index 000000000..61d4458be
--- /dev/null
+++ b/dom/base/test/unit/1_result.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/2_original.xml b/dom/base/test/unit/2_original.xml
new file mode 100644
index 000000000..a6b9e340b
--- /dev/null
+++ b/dom/base/test/unit/2_original.xml
@@ -0,0 +1,15 @@
+
+
+
+ <robots> & <aliens>
+ a a a a a éèàùûî
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam tellus massa, fringilla aliquam, fermentum sit amet, posuere ac, est. Duis tristique egestas ligula. Mauris quis felis. Fusce a ipsum non lacus posuere aliquet. Sed fermentum posuere nulla. Donec tempor. Donec sollicitudin tortor lacinia libero ullamcorper laoreet. Cras quis nisi at odio consectetuer molestie.
+
+
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/2_result_1.xml b/dom/base/test/unit/2_result_1.xml
new file mode 100644
index 000000000..16eeb817f
--- /dev/null
+++ b/dom/base/test/unit/2_result_1.xml
@@ -0,0 +1,13 @@
+
+
+
+ <robots> & <aliens>
+ a a a a a éèàùûî
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam tellus massa, fringilla aliquam, fermentum sit amet, posuere ac, est. Duis tristique egestas ligula. Mauris quis felis. Fusce a ipsum non lacus posuere aliquet. Sed fermentum posuere nulla. Donec tempor. Donec sollicitudin tortor lacinia libero ullamcorper laoreet. Cras quis nisi at odio consectetuer molestie.
+
+
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/2_result_2.xml b/dom/base/test/unit/2_result_2.xml
new file mode 100644
index 000000000..c3eeadb58
--- /dev/null
+++ b/dom/base/test/unit/2_result_2.xml
@@ -0,0 +1,14 @@
+
+
+
+
+ <robots> & <aliens>
+ a a a a a éèàùûî
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam tellus massa, fringilla aliquam, fermentum sit amet, posuere ac, est. Duis tristique egestas ligula. Mauris quis felis. Fusce a ipsum non lacus posuere aliquet. Sed fermentum posuere nulla. Donec tempor. Donec sollicitudin tortor lacinia libero ullamcorper laoreet. Cras quis nisi at odio consectetuer molestie.
+
+
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/2_result_3.xml b/dom/base/test/unit/2_result_3.xml
new file mode 100644
index 000000000..906ac89ee
--- /dev/null
+++ b/dom/base/test/unit/2_result_3.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ <robots> & <aliens>
+ a a a a a éèàùûî
+ Lorem ipsum dolor sit amet, consectetuer
+ adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis
+ ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent
+ taciti sociosqu ad litora torquent per conubia nostra, per
+ inceptos hymenaeos. Nam tellus massa, fringilla aliquam, fermentum
+ sit amet, posuere ac, est. Duis tristique egestas ligula. Mauris
+ quis felis. Fusce a ipsum non lacus posuere aliquet. Sed fermentum
+ posuere nulla. Donec tempor. Donec sollicitudin tortor lacinia
+ libero ullamcorper laoreet. Cras quis nisi at odio consectetuer
+ molestie.
+
+
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/2_result_4.xml b/dom/base/test/unit/2_result_4.xml
new file mode 100644
index 000000000..27ed21921
--- /dev/null
+++ b/dom/base/test/unit/2_result_4.xml
@@ -0,0 +1,21 @@
+
+
+
+ <robots> & <aliens>
+ a a a a a éèàùûî
+ Lorem ipsum dolor sit amet, consectetuer
+adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum.
+Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti
+sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.
+Nam tellus massa, fringilla aliquam, fermentum sit amet, posuere ac,
+est. Duis tristique egestas ligula. Mauris quis felis. Fusce a ipsum non
+ lacus posuere aliquet. Sed fermentum posuere nulla. Donec tempor. Donec
+ sollicitudin tortor lacinia libero ullamcorper laoreet. Cras quis nisi
+at odio consectetuer molestie.
+
+
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/3_original.xml b/dom/base/test/unit/3_original.xml
new file mode 100644
index 000000000..eb9c1bd65
--- /dev/null
+++ b/dom/base/test/unit/3_original.xml
@@ -0,0 +1,4 @@
+
+
+Lorem ipsum dolorsitamet, consectetuer adipiscing elit. Nameusapien. Sed viverralacus. this_is_a_very_long_long_word_which_has_a_length_higher_than_the_max_column Donecquisipsum. Nunc cursus aliquet lectus. Nunc vitae eros.
+
\ No newline at end of file
diff --git a/dom/base/test/unit/3_result.xml b/dom/base/test/unit/3_result.xml
new file mode 100644
index 000000000..e556c61e5
--- /dev/null
+++ b/dom/base/test/unit/3_result.xml
@@ -0,0 +1,7 @@
+
+
+ Lorem ipsum dolorsitamet, consectetuer adipiscing elit.
+ Nameusapien. Sed viverralacus.
+ this_is_a_very_long_long_word_which_has_a_length_higher_than_the_max_column
+ Donecquisipsum. Nunc cursus aliquet lectus. Nunc vitae eros.
+
\ No newline at end of file
diff --git a/dom/base/test/unit/3_result_2.xml b/dom/base/test/unit/3_result_2.xml
new file mode 100644
index 000000000..2df257ca7
--- /dev/null
+++ b/dom/base/test/unit/3_result_2.xml
@@ -0,0 +1,7 @@
+
+
+Lorem ipsum dolorsitamet, consectetuer adipiscing elit.
+Nameusapien. Sed viverralacus.
+this_is_a_very_long_long_word_which_has_a_length_higher_than_the_max_column
+ Donecquisipsum. Nunc cursus aliquet lectus. Nunc vitae eros.
+
\ No newline at end of file
diff --git a/dom/base/test/unit/4_original.xml b/dom/base/test/unit/4_original.xml
new file mode 100644
index 000000000..4c9c61b5d
--- /dev/null
+++ b/dom/base/test/unit/4_original.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+ <robots> & <aliens>
+ a a a a a éèàùûî
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+
+
+
+
+ lorem ipsum
+ xul fake
+
+
+
+
+
+ lorem ipsum
+ xul fake
+ lorem ipsum the return
+
+
+
+
+
+ lorem ipsum
+ xul fake
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/4_result_1.xml b/dom/base/test/unit/4_result_1.xml
new file mode 100644
index 000000000..b985da960
--- /dev/null
+++ b/dom/base/test/unit/4_result_1.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+ <robots> & <aliens>
+ a a a a a éèàùûî
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+
+
+
+
+ lorem ipsum
+ xul fake
+
+
+
+
+
+ lorem ipsum
+ xul fake
+ lorem ipsum the return
+
+
+
+
+
+ lorem ipsum
+ xul fake
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/4_result_2.xml b/dom/base/test/unit/4_result_2.xml
new file mode 100644
index 000000000..bc408b431
--- /dev/null
+++ b/dom/base/test/unit/4_result_2.xml
@@ -0,0 +1,7 @@
+
+
+ lorem ipsum
+ xul fake
+ lorem ipsum the return
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/4_result_3.xml b/dom/base/test/unit/4_result_3.xml
new file mode 100644
index 000000000..30c8b47de
--- /dev/null
+++ b/dom/base/test/unit/4_result_3.xml
@@ -0,0 +1,4 @@
+
+ lorem ipsum
+ xul fake
+
\ No newline at end of file
diff --git a/dom/base/test/unit/4_result_4.xml b/dom/base/test/unit/4_result_4.xml
new file mode 100644
index 000000000..9346d5d17
--- /dev/null
+++ b/dom/base/test/unit/4_result_4.xml
@@ -0,0 +1,4 @@
+
+ lorem ipsum
+ xul fake
+
\ No newline at end of file
diff --git a/dom/base/test/unit/4_result_5.xml b/dom/base/test/unit/4_result_5.xml
new file mode 100644
index 000000000..936dd950b
--- /dev/null
+++ b/dom/base/test/unit/4_result_5.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+ <robots> &
+ <aliens>
+ a
+ a a
+ a a éèàùûî
+ Lorem ipsum dolor sit amet,
+ consectetuer adipiscing elit.
+
+
+
+ lorem ipsum
+ xul
+ fake
+
+
+
+
+ lorem ipsum
+ xul fake
+ lorem
+ ipsum
+
+ the return
+
+
+
+
+ lorem ipsum
+ xul fake
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/4_result_6.xml b/dom/base/test/unit/4_result_6.xml
new file mode 100644
index 000000000..e9917cfdc
--- /dev/null
+++ b/dom/base/test/unit/4_result_6.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+ <robots> &
+<aliens>
+ a a a a
+ a éèàùûî
+ Lorem ipsum dolor sit
+amet, consectetuer adipiscing elit.
+
+
+
+
+ lorem ipsum
+ xul
+fake
+
+
+
+
+
+ lorem ipsum
+ xul fake
+ lorem
+ ipsum
+the return
+
+
+
+
+
+ lorem ipsum
+ xul fake
+
+
+
\ No newline at end of file
diff --git a/dom/base/test/unit/empty_document.xml b/dom/base/test/unit/empty_document.xml
new file mode 100644
index 000000000..ebd60b08c
--- /dev/null
+++ b/dom/base/test/unit/empty_document.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/dom/base/test/unit/head_utilities.js b/dom/base/test/unit/head_utilities.js
new file mode 100644
index 000000000..d3b68520d
--- /dev/null
+++ b/dom/base/test/unit/head_utilities.js
@@ -0,0 +1,40 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+Components.utils.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://gre/modules/NetUtil.jsm");
+
+const nsIDocumentEncoder = Components.interfaces.nsIDocumentEncoder;
+const replacementChar = Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER;
+
+function loadContentFile(aFile, aCharset) {
+ //if(aAsIso == undefined) aAsIso = false;
+ if(aCharset == undefined)
+ aCharset = 'UTF-8';
+
+ var file = do_get_file(aFile);
+ var ios = Components.classes['@mozilla.org/network/io-service;1']
+ .getService(Components.interfaces.nsIIOService);
+ var chann = NetUtil.newChannel({
+ uri: ios.newFileURI(file),
+ loadUsingSystemPrincipal: true
+ });
+ chann.contentCharset = aCharset;
+
+ /*var inputStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Components.interfaces.nsIScriptableInputStream);
+ inputStream.init(chann.open2());
+ return inputStream.read(file.fileSize);
+ */
+
+ var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
+ .createInstance(Components.interfaces.nsIConverterInputStream);
+ inputStream.init(chann.open2(), aCharset, 1024, replacementChar);
+ var str = {}, content = '';
+ while (inputStream.readString(4096, str) != 0) {
+ content += str.value;
+ }
+ return content;
+}
diff --git a/dom/base/test/unit/head_xml.js b/dom/base/test/unit/head_xml.js
new file mode 100644
index 000000000..3d445b748
--- /dev/null
+++ b/dom/base/test/unit/head_xml.js
@@ -0,0 +1,156 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const I = Components.interfaces;
+const C = Components.classes;
+
+const nsILocalFile = I.nsILocalFile;
+const nsIProperties = I.nsIProperties;
+const nsIFileInputStream = I.nsIFileInputStream;
+const nsIInputStream = I.nsIInputStream;
+
+const nsIDOMParser = I.nsIDOMParser;
+const nsIDOMSerializer = I.nsIDOMSerializer;
+const nsIDOMDocument = I.nsIDOMDocument;
+const nsIDOMElement = I.nsIDOMElement;
+const nsIDOMNode = I.nsIDOMNode;
+const nsIDOMCharacterData = I.nsIDOMCharacterData;
+const nsIDOMAttr = I.nsIDOMAttr;
+const nsIDOMNodeList = I.nsIDOMNodeList;
+const nsIDOMXULElement = I.nsIDOMXULElement;
+const nsIDOMProcessingInstruction = I.nsIDOMProcessingInstruction;
+
+function DOMParser() {
+ var parser = C["@mozilla.org/xmlextras/domparser;1"].createInstance(nsIDOMParser);
+ parser.init();
+ return parser;
+}
+
+var __testsDirectory = null;
+
+function ParseFile(file) {
+ if (typeof(file) == "string") {
+ if (!__testsDirectory) {
+ __testsDirectory = do_get_cwd();
+ }
+ var fileObj = __testsDirectory.clone();
+ fileObj.append(file);
+ file = fileObj;
+ }
+
+ do_check_eq(file instanceof nsILocalFile, true);
+
+ var fileStr = C["@mozilla.org/network/file-input-stream;1"]
+ .createInstance(nsIFileInputStream);
+ // Init for readonly reading
+ fileStr.init(file, 0x01, 0o400, nsIFileInputStream.CLOSE_ON_EOF);
+ return ParseXML(fileStr);
+}
+
+function ParseXML(data) {
+ if (typeof(data) == "string") {
+ return DOMParser().parseFromString(data, "application/xml");
+ }
+
+ do_check_eq(data instanceof nsIInputStream, true);
+
+ return DOMParser().parseFromStream(data, "UTF-8", data.available(),
+ "application/xml");
+}
+
+function DOMSerializer() {
+ return C["@mozilla.org/xmlextras/xmlserializer;1"]
+ .createInstance(nsIDOMSerializer);
+}
+
+function SerializeXML(node) {
+ return DOMSerializer().serializeToString(node);
+}
+
+function roundtrip(obj) {
+ if (typeof(obj) == "string") {
+ return SerializeXML(ParseXML(obj));
+ }
+
+ do_check_eq(obj instanceof nsIDOMNode, true);
+ return ParseXML(SerializeXML(obj));
+}
+
+function do_compare_attrs(e1, e2) {
+ const xmlns = "http://www.w3.org/2000/xmlns/";
+
+ var a1 = e1.attributes;
+ var a2 = e2.attributes;
+ for (var i = 0; i < a1.length; ++i) {
+ var att = a1.item(i);
+ // Don't test for namespace decls, since those can just sorta be
+ // scattered about
+ if (att.namespaceURI != xmlns) {
+ var att2 = a2.getNamedItemNS(att.namespaceURI, att.localName);
+ if (!att2) {
+ do_throw("Missing attribute with namespaceURI '" + att.namespaceURI +
+ "' and localName '" + att.localName + "'");
+ }
+ do_check_eq(att.QueryInterface(nsIDOMAttr).value,
+ att2.QueryInterface(nsIDOMAttr).value);
+ }
+ }
+}
+
+function do_check_equiv(dom1, dom2) {
+ do_check_eq(dom1.nodeType, dom2.nodeType);
+ // There's no classinfo around, so we'll need to do some QIing to
+ // make sure the right interfaces are flattened as needed.
+ switch (dom1.nodeType) {
+ case nsIDOMNode.PROCESSING_INSTRUCTION_NODE:
+ do_check_eq(dom1.QueryInterface(nsIDOMProcessingInstruction).target,
+ dom2.QueryInterface(nsIDOMProcessingInstruction).target);
+ do_check_eq(dom1.data, dom2.data);
+ case nsIDOMNode.TEXT_NODE:
+ case nsIDOMNode.CDATA_SECTION_NODE:
+ case nsIDOMNode.COMMENT_NODE:
+ do_check_eq(dom1.QueryInterface(nsIDOMCharacterData).data,
+ dom2.QueryInterface(nsIDOMCharacterData).data);
+ break;
+ case nsIDOMNode.ELEMENT_NODE:
+ do_check_eq(dom1.namespaceURI, dom2.namespaceURI);
+ do_check_eq(dom1.localName, dom2.localName);
+ // Compare attrs in both directions -- do_compare_attrs does a
+ // subset check.
+ do_compare_attrs(dom1, dom2);
+ do_compare_attrs(dom2, dom1);
+ // Fall through
+ case nsIDOMNode.DOCUMENT_NODE:
+ do_check_eq(dom1.childNodes.length, dom2.childNodes.length);
+ for (var i = 0; i < dom1.childNodes.length; ++i) {
+ do_check_equiv(dom1.childNodes.item(i), dom2.childNodes.item(i));
+ }
+ break;
+ }
+}
+
+function do_check_serialize(dom) {
+ do_check_equiv(dom, roundtrip(dom));
+}
+
+function Pipe() {
+ var p = C["@mozilla.org/pipe;1"].createInstance(I.nsIPipe);
+ p.init(false, false, 0, 0xffffffff, null);
+ return p;
+}
+
+function ScriptableInput(arg) {
+ if (arg instanceof I.nsIPipe) {
+ arg = arg.inputStream;
+ }
+
+ var str = C["@mozilla.org/scriptableinputstream;1"].
+ createInstance(I.nsIScriptableInputStream);
+
+ str.init(arg);
+
+ return str;
+}
diff --git a/dom/base/test/unit/isequalnode_data.xml b/dom/base/test/unit/isequalnode_data.xml
new file mode 100644
index 000000000..4b72f5d50
--- /dev/null
+++ b/dom/base/test/unit/isequalnode_data.xml
@@ -0,0 +1,150 @@
+
+
+]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/unit/nodelist_data_1.xml b/dom/base/test/unit/nodelist_data_1.xml
new file mode 100644
index 000000000..ddde596a2
--- /dev/null
+++ b/dom/base/test/unit/nodelist_data_1.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/unit/nodelist_data_2.xul b/dom/base/test/unit/nodelist_data_2.xul
new file mode 100644
index 000000000..247ef0353
--- /dev/null
+++ b/dom/base/test/unit/nodelist_data_2.xul
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+'>
+]>
+
+
+
+ &fooSet;
+
+ &fooSet;
+
+
+
+ &fooSet;
+
+ &fooSet;
+
+
+
+ &fooSet;
+
+ &fooSet;
+
+
+
+ &fooSet;
+
+
+
diff --git a/dom/base/test/unit/test_bloburi.js b/dom/base/test/unit/test_bloburi.js
new file mode 100644
index 000000000..36e2e1eb7
--- /dev/null
+++ b/dom/base/test/unit/test_bloburi.js
@@ -0,0 +1,33 @@
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cr = Components.results;
+
+var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+
+var uris = [
+ {
+ uri: "blob:https://example.com/230d5d50-35f9-9745-a64a-15e47b731a81",
+ local: true,
+ },
+ {
+ uri: "rstp://1.2.3.4/some_path?param=a",
+ local: false,
+ },
+ {
+ uri: "moz-fonttable://something",
+ local: true,
+ }
+];
+
+function run_test()
+{
+ for (let i = 0; i < uris.length; i++) {
+ let uri = ios.newURI(uris[i].uri);
+ let handler = ios.getProtocolHandler(uri.scheme).QueryInterface(Ci.nsIProtocolHandler);
+ let flags = handler.protocolFlags;
+
+ do_check_eq(Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE & flags,
+ (uris[i].local) ? Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE : 0);
+ }
+}
+
diff --git a/dom/base/test/unit/test_bug553888.js b/dom/base/test/unit/test_bug553888.js
new file mode 100644
index 000000000..036d51211
--- /dev/null
+++ b/dom/base/test/unit/test_bug553888.js
@@ -0,0 +1,60 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+Components.utils.import("resource://testing-common/httpd.js");
+
+var server = new HttpServer();
+server.start(-1);
+
+const SERVER_PORT = server.identity.primaryPort;
+const HTTP_BASE = "http://localhost:" + SERVER_PORT;
+const redirectPath = "/redirect";
+const headerCheckPath = "/headerCheck";
+const redirectURL = HTTP_BASE + redirectPath;
+const headerCheckURL = HTTP_BASE + headerCheckPath;
+
+function redirectHandler(metadata, response) {
+ response.setStatusLine(metadata.httpVersion, 302, "Found");
+ response.setHeader("Location", headerCheckURL, false);
+}
+
+function headerCheckHandler(metadata, response) {
+ try {
+ let headerValue = metadata.getHeader("X-Custom-Header");
+ do_check_eq(headerValue, "present");
+ } catch(e) {
+ do_throw("No header present after redirect");
+ }
+ try {
+ metadata.getHeader("X-Unwanted-Header");
+ do_throw("Unwanted header present after redirect");
+ } catch (x) {
+ }
+ response.setStatusLine(metadata.httpVersion, 200, "OK");
+ response.setHeader("Content-Type", "text/plain");
+ response.write("");
+}
+
+function run_test() {
+ server.registerPathHandler(redirectPath, redirectHandler);
+ server.registerPathHandler(headerCheckPath, headerCheckHandler);
+
+ do_test_pending();
+ var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
+ .createInstance(Components.interfaces.nsIXMLHttpRequest);
+ request.open("GET", redirectURL, true);
+ request.setRequestHeader("X-Custom-Header", "present");
+ request.addEventListener("readystatechange", function() {
+ if (request.readyState == 4) {
+ do_check_eq(request.status, 200);
+ server.stop(do_test_finished);
+ }
+ }, false);
+ request.send();
+ try {
+ request.setRequestHeader("X-Unwanted-Header", "present");
+ do_throw("Shouldn't be able to set a header after send");
+ } catch (x) {
+ }
+}
diff --git a/dom/base/test/unit/test_bug737966.js b/dom/base/test/unit/test_bug737966.js
new file mode 100644
index 000000000..448f6fa74
--- /dev/null
+++ b/dom/base/test/unit/test_bug737966.js
@@ -0,0 +1,20 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/* If charset parameter is invalid, the encoding should be detected as UTF-8 */
+
+function run_test()
+{
+ let body = '%c3%80';
+ let result = '\u00c0';
+
+ let xhr = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].
+ createInstance(Components.interfaces.nsIXMLHttpRequest);
+ xhr.open('GET',
+ 'data:text/xml;charset=abc,' + body,
+ false);
+ xhr.send(null);
+
+ do_check_eq(xhr.responseText, result);
+}
diff --git a/dom/base/test/unit/test_cancelPrefetch.js b/dom/base/test/unit/test_cancelPrefetch.js
new file mode 100644
index 000000000..1a10240a9
--- /dev/null
+++ b/dom/base/test/unit/test_cancelPrefetch.js
@@ -0,0 +1,134 @@
+//Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+var prefetch = Cc["@mozilla.org/prefetch-service;1"].
+ getService(Ci.nsIPrefetchService);
+var ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+var prefs = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+
+var parser = Cc["@mozilla.org/xmlextras/domparser;1"].
+ createInstance(Ci.nsIDOMParser);
+
+var doc;
+
+var docbody = '' +
+ ' ' +
+ '';
+
+var node1;
+var node2;
+
+function run_test() {
+ prefs.setBoolPref("network.prefetch-next", true);
+
+ parser.init();
+ doc = parser.parseFromString(docbody, "text/html");
+
+ node1 = doc.getElementById("node1");
+ node2 = doc.getElementById("node2");
+
+ run_next_test();
+}
+
+add_test(function test_cancel1() {
+
+ var uri = ios.newURI("http://localhost/1", null, null);
+ prefetch.prefetchURI(uri, uri, node1, true);
+
+ do_check_true(prefetch.hasMoreElements(), 'There is a request in the queue');
+
+ // Trying to prefetch again the same uri with the same node will fail.
+ var didFail = 0;
+
+ try {
+ prefetch.prefetchURI(uri, uri, node1, true);
+ } catch(e) {
+ didFail = 1;
+ }
+
+ do_check_true(didFail == 1, 'Prefetching the same request with the same ' +
+ 'node fails.');
+
+ do_check_true(prefetch.hasMoreElements(), 'There is still request in ' +
+ 'the queue');
+
+ prefetch.cancelPrefetchURI(uri, node1);
+
+ do_check_false(prefetch.hasMoreElements(), 'There is no request in the ' +
+ 'queue');
+ run_next_test();
+});
+
+add_test(function test_cancel2() {
+ // Prefetch a uri with 2 different nodes. There should be 2 request
+ // in the queue and canceling one will not cancel the other.
+
+ var uri = ios.newURI("http://localhost/1", null, null);
+ prefetch.prefetchURI(uri, uri, node1, true);
+ prefetch.prefetchURI(uri, uri, node2, true);
+
+ do_check_true(prefetch.hasMoreElements(), 'There are requests in the queue');
+
+ prefetch.cancelPrefetchURI(uri, node1);
+
+ do_check_true(prefetch.hasMoreElements(), 'There is still one more request ' +
+ 'in the queue');
+
+ prefetch.cancelPrefetchURI(uri, node2);
+
+ do_check_false(prefetch.hasMoreElements(), 'There is no request in the queue');
+ run_next_test();
+});
+
+add_test(function test_cancel3() {
+ // Request a prefetch of a uri. Trying to cancel a prefetch for the same uri
+ // with a different node will fail.
+ var uri = ios.newURI("http://localhost/1", null, null);
+ prefetch.prefetchURI(uri, uri, node1, true);
+
+ do_check_true(prefetch.hasMoreElements(), 'There is a request in the queue');
+
+ var didFail = 0;
+
+ try {
+ prefetch.cancelPrefetchURI(uri, node2);
+ } catch(e) {
+ didFail = 1;
+ }
+ do_check_true(didFail == 1, 'Canceling the request failed');
+
+ do_check_true(prefetch.hasMoreElements(), 'There is still a request ' +
+ 'in the queue');
+
+ prefetch.cancelPrefetchURI(uri, node1);
+ do_check_false(prefetch.hasMoreElements(), 'There is no request in the queue');
+ run_next_test();
+});
+
+add_test(function test_cancel4() {
+ // Request a prefetch of a uri. Trying to cancel a prefetch for a different uri
+ // with the same node will fail.
+ var uri1 = ios.newURI("http://localhost/1", null, null);
+ var uri2 = ios.newURI("http://localhost/2", null, null);
+ prefetch.prefetchURI(uri1, uri1, node1, true);
+
+ do_check_true(prefetch.hasMoreElements(), 'There is a request in the queue');
+
+ var didFail = 0;
+
+ try {
+ prefetch.cancelPrefetchURI(uri2, node1);
+ } catch(e) {
+ didFail = 1;
+ }
+ do_check_true(didFail == 1, 'Canceling the request failed');
+
+ do_check_true(prefetch.hasMoreElements(), 'There is still a request ' +
+ 'in the queue');
+
+ prefetch.cancelPrefetchURI(uri1, node1);
+ do_check_false(prefetch.hasMoreElements(), 'There is no request in the queue');
+ run_next_test();
+});
diff --git a/dom/base/test/unit/test_chromeutils_base64.js b/dom/base/test/unit/test_chromeutils_base64.js
new file mode 100644
index 000000000..361392c44
--- /dev/null
+++ b/dom/base/test/unit/test_chromeutils_base64.js
@@ -0,0 +1,105 @@
+"use strict";
+
+function run_test() {
+ test_base64URLEncode();
+ test_base64URLDecode();
+}
+
+// Test vectors from RFC 4648, section 10.
+let textTests = {
+ "": "",
+ "f": "Zg",
+ "fo": "Zm8",
+ "foo": "Zm9v",
+ "foob": "Zm9vYg",
+ "fooba": "Zm9vYmE",
+ "foobar": "Zm9vYmFy",
+}
+
+// Examples from RFC 4648, section 9.
+let binaryTests = [{
+ decoded: new Uint8Array([0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e]),
+ encoded: "FPucA9l-",
+}, {
+ decoded: new Uint8Array([0x14, 0xfb, 0x9c, 0x03, 0xd9]),
+ encoded: "FPucA9k",
+}, {
+ decoded: new Uint8Array([0x14, 0xfb, 0x9c, 0x03]),
+ encoded: "FPucAw",
+}];
+
+function padEncodedValue(value) {
+ switch (value.length % 4) {
+ case 0:
+ return value;
+ case 2:
+ return value + "==";
+ case 3:
+ return value + "=";
+ default:
+ throw new TypeError("Invalid encoded value");
+ }
+}
+
+function testEncode(input, encoded) {
+ equal(ChromeUtils.base64URLEncode(input, { pad: false }),
+ encoded, encoded + " without padding");
+ equal(ChromeUtils.base64URLEncode(input, { pad: true }),
+ padEncodedValue(encoded), encoded + " with padding");
+}
+
+function test_base64URLEncode() {
+ throws(_ => ChromeUtils.base64URLEncode(new Uint8Array(0)), /TypeError/,
+ "Should require encoding options");
+ throws(_ => ChromeUtils.base64URLEncode(new Uint8Array(0), {}), /TypeError/,
+ "Encoding should require the padding option");
+
+ for (let {decoded, encoded} of binaryTests) {
+ testEncode(decoded, encoded);
+ }
+
+ let textEncoder = new TextEncoder("utf-8");
+ for (let decoded of Object.keys(textTests)) {
+ let input = textEncoder.encode(decoded);
+ testEncode(input, textTests[decoded]);
+ }
+}
+
+function testDecode(input, decoded) {
+ let buffer = ChromeUtils.base64URLDecode(input, { padding: "reject" });
+ deepEqual(new Uint8Array(buffer), decoded, input + " with padding rejected");
+
+ let paddedValue = padEncodedValue(input);
+ buffer = ChromeUtils.base64URLDecode(paddedValue, { padding: "ignore" });
+ deepEqual(new Uint8Array(buffer), decoded, input + " with padding ignored");
+
+ if (paddedValue.length > input.length) {
+ throws(_ => ChromeUtils.base64URLDecode(paddedValue, { padding: "reject" }),
+ paddedValue + " with padding rejected should throw");
+
+ throws(_ => ChromeUtils.base64URLDecode(input, { padding: "require" }),
+ input + " with padding required should throw");
+
+ buffer = ChromeUtils.base64URLDecode(paddedValue, { padding: "require" });
+ deepEqual(new Uint8Array(buffer), decoded, paddedValue + " with padding required");
+ }
+}
+
+function test_base64URLDecode() {
+ throws(_ => ChromeUtils.base64URLDecode(""), /TypeError/,
+ "Should require decoding options");
+ throws(_ => ChromeUtils.base64URLDecode("", {}), /TypeError/,
+ "Decoding should require the padding option");
+ throws(_ => ChromeUtils.base64URLDecode("", { padding: "chocolate" }),
+ "Decoding should throw for invalid padding policy");
+
+ for (let {decoded, encoded} of binaryTests) {
+ testDecode(encoded, decoded);
+ }
+
+ let textEncoder = new TextEncoder("utf-8");
+ for (let decoded of Object.keys(textTests)) {
+ let expectedBuffer = textEncoder.encode(decoded);
+ testDecode(textTests[decoded], expectedBuffer);
+ }
+}
diff --git a/dom/base/test/unit/test_delete_range.xml b/dom/base/test/unit/test_delete_range.xml
new file mode 100644
index 000000000..c8d50bd32
--- /dev/null
+++ b/dom/base/test/unit/test_delete_range.xml
@@ -0,0 +1,125 @@
+
+
+
+
+
+ The quick fox
+ The fox
+ quick
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Fox Fox
+ Fox
+ Fox
+
+
+
+
+ Fox Fox
+ Fox
+ Fox
+
+
+
+
+ Fox Fox
+ Fox F
+ ox
+
+
+
+
+ The quick fox
+ The quick fox
+
+
+
+
+
+ Fox Fox
+ Fox Fox
+
+
+
diff --git a/dom/base/test/unit/test_error_codes.js b/dom/base/test/unit/test_error_codes.js
new file mode 100644
index 000000000..c4f488f18
--- /dev/null
+++ b/dom/base/test/unit/test_error_codes.js
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+var gExpectedStatus = null;
+var gNextTestFunc = null;
+
+var prefs = Components.classes["@mozilla.org/preferences-service;1"].
+ getService(Components.interfaces.nsIPrefBranch);
+
+var asyncXHR = {
+ load: function() {
+ var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
+ .createInstance(Components.interfaces.nsIXMLHttpRequest);
+ request.open("GET", "http://localhost:4444/test_error_code.xml", true);
+
+ var self = this;
+ request.addEventListener("error", function(event) { self.onError(event); }, false);
+ request.send(null);
+ },
+ onError: function doAsyncRequest_onError(event) {
+ var request = event.target.channel.QueryInterface(Components.interfaces.nsIRequest);
+ do_check_eq(request.status, gExpectedStatus);
+ gNextTestFunc();
+ }
+}
+
+function run_test() {
+ do_test_pending();
+ do_timeout(0, run_test_pt1);
+}
+
+// network offline
+function run_test_pt1() {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+
+ try {
+ ioService.manageOfflineStatus = false;
+ }
+ catch (e) {
+ }
+ ioService.offline = true;
+ prefs.setBoolPref("network.dns.offline-localhost", false);
+
+ gExpectedStatus = Components.results.NS_ERROR_OFFLINE;
+ gNextTestFunc = run_test_pt2;
+ dump("Testing error returned by async XHR when the network is offline\n");
+ asyncXHR.load();
+}
+
+// connection refused
+function run_test_pt2() {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+ ioService.offline = false;
+ prefs.clearUserPref("network.dns.offline-localhost");
+
+ gExpectedStatus = Components.results.NS_ERROR_CONNECTION_REFUSED;
+ gNextTestFunc = end_test;
+ dump("Testing error returned by aync XHR when the connection is refused\n");
+ asyncXHR.load();
+}
+
+function end_test() {
+ do_test_finished();
+}
diff --git a/dom/base/test/unit/test_isequalnode.js b/dom/base/test/unit/test_isequalnode.js
new file mode 100644
index 000000000..5d44b5b50
--- /dev/null
+++ b/dom/base/test/unit/test_isequalnode.js
@@ -0,0 +1,435 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function run_test()
+{
+ /*
+ * NOTE: [i] is not allowed in this test, since it's done via classinfo and
+ * we don't have that in xpcshell; the workaround is item(i). Suck.
+ */
+ init();
+
+ test_isEqualNode_setAttribute();
+ test_isEqualNode_clones();
+ test_isEqualNode_variety();
+ test_isEqualNode_normalization();
+ test_isEqualNode_whitespace();
+ test_isEqualNode_namespaces();
+ test_isEqualNode_wholeDoc();
+
+ // XXX should Node.isEqualNode(null) throw or return false?
+ //test_isEqualNode_null();
+
+}
+
+// TEST CODE
+
+var doc, root; // cache for use in all tests
+
+function init()
+{
+ doc = ParseFile("isequalnode_data.xml");
+ root = doc.documentElement;
+}
+
+function test_isEqualNode_setAttribute()
+{
+ // NOTE: 0, 2 are whitespace
+ var test1 = doc.getElementById("test_setAttribute");
+ var node1 = test1.childNodes.item(1);
+ var node2 = test1.childNodes.item(3);
+
+ check_eq_nodes(node1, node2);
+
+
+ el(node1).setAttribute("bar", "baz");
+ check_neq_nodes(node1, node2);
+
+ el(node2).setAttribute("bar", "baz");
+ check_eq_nodes(node1, node2);
+
+
+ // the null namespace is equivalent to no namespace -- section 1.3.3
+ // (XML Namespaces) of DOM 3 Core
+ node1.setAttributeNS(null, "quux", "17");
+ check_neq_nodes(node1, node2);
+
+ node2.setAttribute("quux", "17");
+ check_eq_nodes(node1, node2);
+
+
+ node2.setAttributeNS("http://mozilla.org/", "seamonkey", "rheet");
+ check_neq_nodes(node1, node2);
+
+ node1.setAttribute("seamonkey", "rheet");
+ check_neq_nodes(node1, node2);
+
+ node1.setAttributeNS("http://mozilla.org/", "seamonkey", "rheet");
+ check_neq_nodes(node1, node2);
+
+ // this overwrites the namespaced "seamonkey" attribute added to node2
+ // earlier, because this simply sets whatever attribute has the fully
+ // qualified name "seamonkey" (the setAttributeNS attribute string wasn't
+ // prefixed) -- consequently, node1 and node2 are still unequal
+ node2.setAttribute("seamonkey", "rheet");
+ check_neq_nodes(node1, node2);
+}
+
+function test_isEqualNode_clones()
+{
+ // tests all elements and attributes in the document
+ var all_elts = doc.getElementsByTagName("*");
+ for (var i = 0; i < all_elts.length; i++)
+ {
+ var elt = el(all_elts.item(i));
+ check_eq_nodes(elt, elt.cloneNode(true));
+
+ var attrs = elt.attributes;
+ for (var j = 0; j < attrs.length; j++)
+ {
+ var attr = attrs.item(j);
+ check_eq_nodes(attr, attr.cloneNode(true));
+ }
+ }
+
+ var elm = doc.createElement("foo");
+ check_eq_nodes(elm, elm.cloneNode(true));
+ check_eq_nodes(elm, elm.cloneNode(false));
+
+ elm.setAttribute("fiz", "eit");
+ check_eq_nodes(elm, elm.cloneNode(true));
+ check_eq_nodes(elm, elm.cloneNode(false));
+
+ elm.setAttributeNS("http://example.com/", "trendoid", "arthroscope");
+ check_eq_nodes(elm, elm.cloneNode(true));
+ check_eq_nodes(elm, elm.cloneNode(false));
+
+ var elm2 = elm.cloneNode(true);
+ check_eq_nodes(elm, elm2);
+
+ const TEXT = "fetishist";
+
+ elm.textContent = TEXT;
+ check_neq_nodes(elm, elm2);
+
+ check_neq_nodes(elm, elm.cloneNode(false));
+ check_eq_nodes(elm, elm.cloneNode(true));
+
+ elm2.appendChild(doc.createTextNode(TEXT));
+ check_eq_nodes(elm, elm2);
+
+ var att = doc.createAttribute("bar");
+ check_eq_nodes(att, att.cloneNode(true));
+ check_eq_nodes(att, att.cloneNode(false));
+}
+
+function test_isEqualNode_variety()
+{
+ const nodes =
+ [
+ doc.createElement("foo"),
+ doc.createElementNS("http://example.com/", "foo"),
+ doc.createElementNS("http://example.org/", "foo"),
+ doc.createElementNS("http://example.com/", "FOO"),
+ doc.createAttribute("foo", "href='biz'"),
+ doc.createAttributeNS("http://example.com/", "foo", "href='biz'"),
+ doc.createTextNode("foo"),
+ doc.createTextNode(" "),
+ doc.createTextNode(" "),
+ doc.createComment("foo"),
+ doc.createProcessingInstruction("foo", "href='biz'"),
+ doc.implementation.createDocumentType("foo", "href='biz'", ""),
+ doc.implementation.createDocument("http://example.com/", "foo", null),
+ doc.createDocumentFragment()
+ ];
+
+ for (var i = 0; i < nodes.length; i++)
+ {
+ for (var j = i; j < nodes.length; j++)
+ {
+ if (i == j)
+ check_eq_nodes(nodes[i], nodes[j]);
+ else
+ check_neq_nodes(nodes[i], nodes[j]);
+ }
+ }
+}
+
+function test_isEqualNode_normalization()
+{
+ var norm = doc.getElementById("test_normalization");
+ var node1 = norm.childNodes.item(1);
+ var node2 = norm.childNodes.item(3);
+
+ check_eq_nodes(node1, node2);
+
+ node1.appendChild(doc.createTextNode(""));
+ check_neq_nodes(node1, node2);
+
+ node1.normalize();
+ check_eq_nodes(node1, node2);
+
+ node2.appendChild(doc.createTextNode("fun"));
+ node2.appendChild(doc.createTextNode("ctor"));
+ node1.appendChild(doc.createTextNode("functor"));
+ check_neq_nodes(node1, node2);
+
+ node1.normalize();
+ check_neq_nodes(node1, node2);
+
+ node2.normalize();
+ check_eq_nodes(node1, node2);
+
+ // reset
+ while (node1.hasChildNodes())
+ node1.removeChild(node1.childNodes.item(0));
+ while (node2.hasChildNodes())
+ node2.removeChild(node2.childNodes.item(0));
+
+ // attribute normalization testing
+
+ var at1 = doc.createAttribute("foo");
+ var at2 = doc.createAttribute("foo");
+ check_eq_nodes(at1, at2);
+
+ // Attr.appendChild isn't implemented yet (bug 56758), so don't run this yet
+ if (false)
+ {
+ at1.appendChild(doc.createTextNode("rasp"));
+ at2.appendChild(doc.createTextNode("rasp"));
+ check_eq_nodes(at1, at2);
+
+ at1.appendChild(doc.createTextNode(""));
+ check_neq_nodes(at1, at2);
+
+ at1.normalize();
+ check_eq_nodes(at1, at2);
+
+ at1.appendChild(doc.createTextNode("berry"));
+ check_neq_nodes(at1, at2);
+
+ at2.appendChild(doc.createTextNode("ber"));
+ check_neq_nodes(at1, at2);
+
+ at2.appendChild(doc.createTextNode("ry"));
+ check_neq_nodes(at1, at2);
+
+ at1.normalize();
+ check_neq_nodes(at1, at2);
+
+ at2.normalize();
+ check_eq_nodes(at1, at2);
+ }
+
+ node1.setAttributeNode(at1);
+ check_neq_nodes(node1, node2);
+
+ node2.setAttributeNode(at2);
+ check_eq_nodes(node1, node2);
+
+ var n1text1 = doc.createTextNode("ratfink");
+ var n1elt = doc.createElement("fruitcake");
+ var n1text2 = doc.createTextNode("hydrospanner");
+
+ node1.appendChild(n1text1);
+ node1.appendChild(n1elt);
+ node1.appendChild(n1text2);
+
+ check_neq_nodes(node1, node2);
+
+ var n2text1a = doc.createTextNode("rat");
+ var n2text1b = doc.createTextNode("fink");
+ var n2elt = doc.createElement("fruitcake");
+ var n2text2 = doc.createTextNode("hydrospanner");
+
+ node2.appendChild(n2text1b);
+ node2.appendChild(n2elt);
+ node2.appendChild(n2text2);
+ check_neq_nodes(node1, node2);
+
+ node2.insertBefore(n2text1a, n2text1b);
+ check_neq_nodes(node1, node2);
+
+ var tmp_node1 = node1.cloneNode(true);
+ tmp_node1.normalize();
+ var tmp_node2 = node2.cloneNode(true);
+ tmp_node2.normalize();
+ check_eq_nodes(tmp_node1, tmp_node2);
+
+ n2elt.appendChild(doc.createTextNode(""));
+ check_neq_nodes(node1, node2);
+
+ tmp_node1 = node1.cloneNode(true);
+ tmp_node1.normalize();
+ tmp_node2 = node2.cloneNode(true);
+ tmp_node2.normalize();
+ check_eq_nodes(tmp_node1, tmp_node2);
+
+ var typeText1 = doc.createTextNode("type");
+ n2elt.appendChild(typeText1);
+ tmp_node1 = node1.cloneNode(true);
+ tmp_node1.normalize();
+ tmp_node2 = node2.cloneNode(true);
+ tmp_node2.normalize();
+ check_neq_nodes(tmp_node1, tmp_node2);
+
+ n1elt.appendChild(doc.createTextNode("typedef"));
+ tmp_node1 = node1.cloneNode(true);
+ tmp_node1.normalize();
+ tmp_node2 = node2.cloneNode(true);
+ tmp_node2.normalize();
+ check_neq_nodes(tmp_node1, tmp_node2);
+ check_neq_nodes(n1elt, n2elt);
+
+ var typeText2 = doc.createTextNode("def");
+ n2elt.appendChild(typeText2);
+ tmp_node1 = node1.cloneNode(true);
+ tmp_node1.normalize();
+ tmp_node2 = node2.cloneNode(true);
+ tmp_node2.normalize();
+ check_eq_nodes(tmp_node1, tmp_node2);
+ check_neq_nodes(node1, node2);
+
+ n2elt.insertBefore(doc.createTextNode(""), typeText2);
+ check_neq_nodes(node1, node2);
+
+ n2elt.insertBefore(doc.createTextNode(""), typeText2);
+ check_neq_nodes(node1, node2);
+
+ n2elt.insertBefore(doc.createTextNode(""), typeText1);
+ check_neq_nodes(node1, node2);
+
+ node1.normalize();
+ node2.normalize();
+ check_eq_nodes(node1, node2);
+}
+
+function test_isEqualNode_whitespace()
+{
+ equality_check_kids("test_pi1", true);
+ equality_check_kids("test_pi2", true);
+ equality_check_kids("test_pi3", false);
+ equality_check_kids("test_pi4", true);
+ equality_check_kids("test_pi5", true);
+
+ equality_check_kids("test_elt1", false);
+ equality_check_kids("test_elt2", false);
+ equality_check_kids("test_elt3", true);
+ equality_check_kids("test_elt4", false);
+ equality_check_kids("test_elt5", false);
+
+ equality_check_kids("test_comment1", true);
+ equality_check_kids("test_comment2", false);
+ equality_check_kids("test_comment3", false);
+ equality_check_kids("test_comment4", true);
+
+ equality_check_kids("test_text1", true);
+ equality_check_kids("test_text2", false);
+ equality_check_kids("test_text3", false);
+
+ equality_check_kids("test_cdata1", false);
+ equality_check_kids("test_cdata2", true);
+ equality_check_kids("test_cdata3", false);
+ equality_check_kids("test_cdata4", false);
+ equality_check_kids("test_cdata5", false);
+}
+
+function test_isEqualNode_namespaces()
+{
+ equality_check_kids("test_ns1", false);
+ equality_check_kids("test_ns2", false);
+
+ // XXX want more tests here!
+}
+
+function test_isEqualNode_null()
+{
+ check_neq_nodes(doc, null);
+
+ var elts = doc.getElementsByTagName("*");
+ for (var i = 0; i < elts.length; i++)
+ {
+ var elt = elts.item(i);
+ check_neq_nodes(elt, null);
+
+ var attrs = elt.attributes;
+ for (var j = 0; j < attrs.length; j++)
+ {
+ var att = attrs.item(j);
+ check_neq_nodes(att, null);
+
+ for (var k = 0; k < att.childNodes.length; k++)
+ {
+ check_neq_nodes(att.childNodes.item(k), null);
+ }
+ }
+ }
+}
+
+function test_isEqualNode_wholeDoc()
+{
+ doc = ParseFile("isequalnode_data.xml");
+ var doc2 = ParseFile("isequalnode_data.xml");
+ var tw1 =
+ doc.createTreeWalker(doc, Components.interfaces.nsIDOMNodeFilter.SHOW_ALL,
+ null);
+ var tw2 =
+ doc2.createTreeWalker(doc2, Components.interfaces.nsIDOMNodeFilter.SHOW_ALL,
+ null);
+ do {
+ check_eq_nodes(tw1.currentNode, tw2.currentNode);
+ tw1.nextNode();
+ } while(tw2.nextNode());
+}
+
+// UTILITY FUNCTIONS
+
+function n(node) { return node ? node.QueryInterface(nsIDOMNode) : null; }
+function el(node) { return node ? node.QueryInterface(nsIDOMElement) : null; }
+function at(node) { return node ? node.QueryInterface(nsIDOMAttr) : null; }
+
+
+// TESTING FUNCTIONS
+
+/**
+ * Compares the first and third (zero-indexed) child nodes of the element
+ * (typically to allow whitespace) referenced by parentId for isEqualNode
+ * equality or inequality based on the value of areEqual.
+ *
+ * Note that this means that the contents of the element referenced by parentId
+ * are whitespace-sensitive, and a stray space introduced during an edit to the
+ * file could result in a correct but unexpected (in)equality failure.
+ */
+function equality_check_kids(parentId, areEqual)
+{
+ var parent = doc.getElementById(parentId);
+ var kid1 = parent.childNodes.item(1);
+ var kid2 = parent.childNodes.item(3);
+
+ if (areEqual)
+ check_eq_nodes(kid1, kid2);
+ else
+ check_neq_nodes(kid1, kid2);
+}
+
+function check_eq_nodes(n1, n2)
+{
+ if (n1 && !n1.isEqualNode(n2))
+ do_throw(n1 + " should be equal to " + n2);
+ if (n2 && !n2.isEqualNode(n1))
+ do_throw(n2 + " should be equal to " + n1);
+ if (!n1 && !n2)
+ do_throw("nodes both null!");
+}
+
+function check_neq_nodes(n1, n2)
+{
+ if (n1 && n1.isEqualNode(n2))
+ do_throw(n1 + " should not be equal to " + n2);
+ if (n2 && n2.isEqualNode(n1))
+ do_throw(n2 + " should not be equal to " + n1);
+ if (!n1 && !n2)
+ do_throw("n1 and n2 both null!");
+}
diff --git a/dom/base/test/unit/test_nodelist.js b/dom/base/test/unit/test_nodelist.js
new file mode 100644
index 000000000..50c79da72
--- /dev/null
+++ b/dom/base/test/unit/test_nodelist.js
@@ -0,0 +1,394 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+function run_test()
+{
+
+ /**
+ * NOTE: [i] is not allowed in this test, since it's done via classinfo and
+ * we don't have that in xpcshell.
+ */
+
+ test_getElementsByTagName();
+ test_getElementsByTagNameNS();
+ test_getElementsByAttribute();
+ test_getElementsByAttributeNS();
+
+ // What else should we test?
+ // XXXbz we need more tests here to test liveness!
+
+}
+
+function test_getElementsByTagName()
+{
+ var doc = ParseFile("nodelist_data_1.xml");
+ var root = doc.documentElement;
+
+ // Check that getElementsByTagName returns a nodelist.
+ do_check_true(doc.getElementsByTagName("*") instanceof nsIDOMNodeList);
+ do_check_true(root.getElementsByTagName("*") instanceof nsIDOMNodeList);
+
+ // Check that getElementsByTagName excludes the element it's called on.
+ do_check_eq(doc.getElementsByTagName("*").length,
+ root.getElementsByTagName("*").length + 1);
+ do_check_eq(doc.getElementById("test2").getElementsByTagName("*").length,
+ 8);
+ do_check_eq(doc.getElementById("test2").getElementsByTagName("test").length,
+ 3);
+
+ // Check that the first element of getElementsByTagName on the document is
+ // the right thing.
+ do_check_eq(doc.getElementsByTagName("*").item(0), root);
+
+ // Check that we get the right things in the right order
+ var numTests = doc.getElementsByTagName("test").length;
+ do_check_eq(numTests, 5);
+
+ for (var i = 1; i <= numTests; ++i) {
+ do_check_true(doc.getElementById("test" + i) instanceof nsIDOMElement);
+ do_check_eq(doc.getElementById("test" + i),
+ doc.getElementsByTagName("test").item(i-1));
+ }
+
+ // Check that we handle tagnames containing ':' correctly
+ do_check_true(doc.getElementsByTagName("foo:test")
+ instanceof nsIDOMNodeList);
+ do_check_eq(doc.getElementsByTagName("foo:test").length, 2);
+
+ do_check_true(doc.getElementsByTagName("foo2:test")
+ instanceof nsIDOMNodeList);
+ do_check_eq(doc.getElementsByTagName("foo2:test").length, 3);
+
+ do_check_true(doc.getElementsByTagName("bar:test")
+ instanceof nsIDOMNodeList);
+ do_check_eq(doc.getElementsByTagName("bar:test").length, 4);
+}
+
+function test_getElementsByTagNameNS()
+{
+ var doc = ParseFile("nodelist_data_1.xml");
+ var root = doc.documentElement;
+
+ // Check that getElementsByTagNameNS returns a nodelist.
+ do_check_true(doc.getElementsByTagNameNS("*", "*") instanceof nsIDOMNodeList);
+ do_check_true(root.getElementsByTagNameNS("*", "*") instanceof nsIDOMNodeList);
+
+ // Check that passing "" and null for the namespace URI gives the same result
+ var list1 = doc.getElementsByTagNameNS("", "test");
+ var list2 = doc.getElementsByTagNameNS(null, "test");
+ do_check_eq(list1.length, list2.length);
+ for (var i = 0; i < list1.length; ++i) {
+ do_check_eq(list1.item(i), list2.item(i));
+ }
+
+ // Check that getElementsByTagNameNS excludes the element it's called on.
+ do_check_eq(doc.getElementsByTagNameNS("*", "*").length,
+ root.getElementsByTagNameNS("*", "*").length + 1);
+ do_check_eq(doc.getElementById("test2")
+ .getElementsByTagNameNS("*", "*").length,
+ 8);
+ do_check_eq(doc.getElementById("test2")
+ .getElementsByTagNameNS("", "test").length,
+ 1);
+ do_check_eq(doc.getElementById("test2")
+ .getElementsByTagNameNS("*", "test").length,
+ 7);
+
+ // Check that the first element of getElementsByTagNameNS on the document is
+ // the right thing.
+ do_check_eq(doc.getElementsByTagNameNS("*", "*").item(0), root);
+ do_check_eq(doc.getElementsByTagNameNS(null, "*").item(0), root);
+
+ // Check that we get the right things in the right order
+
+
+ var numTests = doc.getElementsByTagNameNS("*", "test").length;
+ do_check_eq(numTests, 14);
+
+ for (var i = 1; i <= numTests; ++i) {
+ do_check_true(doc.getElementById("test" + i) instanceof nsIDOMElement);
+ do_check_eq(doc.getElementById("test" + i),
+ doc.getElementsByTagNameNS("*", "test").item(i-1));
+ }
+
+ // Check general proper functioning of having a non-wildcard namespace.
+ var test2 = doc.getElementById("test2");
+ do_check_eq(doc.getElementsByTagNameNS("", "test").length,
+ 3);
+ do_check_eq(test2.getElementsByTagNameNS("", "test").length,
+ 1);
+ do_check_eq(doc.getElementsByTagNameNS("foo", "test").length,
+ 7);
+ do_check_eq(test2.getElementsByTagNameNS("foo", "test").length,
+ 4);
+ do_check_eq(doc.getElementsByTagNameNS("foo2", "test").length,
+ 0);
+ do_check_eq(test2.getElementsByTagNameNS("foo2", "test").length,
+ 0);
+ do_check_eq(doc.getElementsByTagNameNS("bar", "test").length,
+ 4);
+ do_check_eq(test2.getElementsByTagNameNS("bar", "test").length,
+ 2);
+
+ // Check that we handle tagnames containing ':' correctly
+ do_check_true(doc.getElementsByTagNameNS(null, "foo:test")
+ instanceof nsIDOMNodeList);
+ do_check_eq(doc.getElementsByTagNameNS(null, "foo:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("foo", "foo:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("bar", "foo:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("*", "foo:test").length, 0);
+
+ do_check_true(doc.getElementsByTagNameNS(null, "foo2:test")
+ instanceof nsIDOMNodeList);
+ do_check_eq(doc.getElementsByTagNameNS(null, "foo2:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("foo2", "foo2:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("bar", "foo2:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("*", "foo2:test").length, 0);
+
+ do_check_true(doc.getElementsByTagNameNS(null, "bar:test")
+ instanceof nsIDOMNodeList);
+ do_check_eq(doc.getElementsByTagNameNS(null, "bar:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("bar", "bar:test").length, 0);
+ do_check_eq(doc.getElementsByTagNameNS("*", "bar:test").length, 0);
+
+ // Check that previously-unknown namespaces are handled right. Note that we
+ // can just hardcode the strings, since we're running only once in XPCshell.
+ // If someone wants to run these in a browser, some use of Math.random() may
+ // be in order.
+ list1 = doc.getElementsByTagNameNS("random-bogus-namespace", "foo");
+ list2 = doc.documentElement.getElementsByTagNameNS("random-bogus-namespace2",
+ "foo");
+ do_check_neq(list1, list2);
+ do_check_eq(list1.length, 0);
+ do_check_eq(list2.length, 0);
+ var newNode = doc.createElementNS("random-bogus-namespace", "foo");
+ doc.documentElement.appendChild(newNode);
+ var newNode = doc.createElementNS("random-bogus-namespace2", "foo");
+ doc.documentElement.appendChild(newNode);
+ do_check_eq(list1.length, 1);
+ do_check_eq(list2.length, 1);
+}
+
+function test_getElementsByAttribute()
+{
+ var doc = ParseFile("nodelist_data_2.xul");
+ var root = doc.documentElement;
+
+ // Sadly, DOMParser can't create XULDocument objects. But at least we have a
+ // XULElement!
+
+ do_check_true(root instanceof nsIDOMXULElement);
+
+ do_check_true(root.getElementsByAttribute("foo", "foo") instanceof
+ nsIDOMNodeList);
+
+ var master1 = doc.getElementById("master1");
+ var master2 = doc.getElementById("master2");
+ var master3 = doc.getElementById("master3");
+ var external = doc.getElementById("external");
+
+ do_check_true(master1 instanceof nsIDOMXULElement);
+ do_check_true(master2 instanceof nsIDOMXULElement);
+ do_check_true(master3 instanceof nsIDOMXULElement);
+ do_check_true(external instanceof nsIDOMXULElement);
+
+ // Basic tests
+ do_check_eq(root.getElementsByAttribute("foo", "foo").length,
+ 14);
+ do_check_eq(master1.getElementsByAttribute("foo", "foo").length,
+ 4);
+
+ do_check_eq(root.getElementsByAttribute("foo", "bar").length,
+ 7);
+ do_check_eq(master1.getElementsByAttribute("foo", "bar").length,
+ 2);
+
+ do_check_eq(root.getElementsByAttribute("bar", "bar").length,
+ 7);
+ do_check_eq(master1.getElementsByAttribute("bar", "bar").length,
+ 2);
+
+ do_check_eq(root.getElementsByAttribute("foo", "*").length,
+ 21);
+ do_check_eq(master1.getElementsByAttribute("foo", "*").length,
+ 6);
+
+ // Test the various combinations of attributes with colons in the name
+ do_check_eq(root.getElementsByAttribute("foo:foo", "foo").length,
+ 16);
+ do_check_eq(master1.getElementsByAttribute("foo:foo", "foo").length,
+ 5);
+ do_check_eq(master2.getElementsByAttribute("foo:foo", "foo").length,
+ 4);
+ do_check_eq(master3.getElementsByAttribute("foo:foo", "foo").length,
+ 4);
+ do_check_eq(external.getElementsByAttribute("foo:foo", "foo").length,
+ 2);
+
+ do_check_eq(root.getElementsByAttribute("foo:foo", "bar").length,
+ 9);
+ do_check_eq(master1.getElementsByAttribute("foo:foo", "bar").length,
+ 2);
+ do_check_eq(master2.getElementsByAttribute("foo:foo", "bar").length,
+ 3);
+ do_check_eq(master3.getElementsByAttribute("foo:foo", "bar").length,
+ 2);
+ do_check_eq(external.getElementsByAttribute("foo:foo", "bar").length,
+ 1);
+
+ do_check_eq(root.getElementsByAttribute("foo:bar", "foo").length,
+ 7);
+ do_check_eq(master1.getElementsByAttribute("foo:bar", "foo").length,
+ 2);
+ do_check_eq(master2.getElementsByAttribute("foo:bar", "foo").length,
+ 2);
+ do_check_eq(master3.getElementsByAttribute("foo:bar", "foo").length,
+ 2);
+ do_check_eq(external.getElementsByAttribute("foo:bar", "foo").length,
+ 1);
+
+ do_check_eq(root.getElementsByAttribute("foo:bar", "bar").length,
+ 14);
+ do_check_eq(master1.getElementsByAttribute("foo:bar", "bar").length,
+ 4);
+ do_check_eq(master2.getElementsByAttribute("foo:bar", "bar").length,
+ 4);
+ do_check_eq(master3.getElementsByAttribute("foo:bar", "bar").length,
+ 4);
+ do_check_eq(external.getElementsByAttribute("foo:bar", "bar").length,
+ 2);
+
+ do_check_eq(root.getElementsByAttribute("foo2:foo", "foo").length,
+ 8);
+ do_check_eq(master1.getElementsByAttribute("foo2:foo", "foo").length,
+ 2);
+ do_check_eq(master2.getElementsByAttribute("foo2:foo", "foo").length,
+ 2);
+ do_check_eq(master3.getElementsByAttribute("foo2:foo", "foo").length,
+ 3);
+ do_check_eq(external.getElementsByAttribute("foo2:foo", "foo").length,
+ 1);
+
+ do_check_eq(root.getElementsByAttribute("foo:foo", "*").length,
+ 25);
+ do_check_eq(master1.getElementsByAttribute("foo:foo", "*").length,
+ 7);
+ do_check_eq(master2.getElementsByAttribute("foo:foo", "*").length,
+ 7);
+ do_check_eq(master3.getElementsByAttribute("foo:foo", "*").length,
+ 6);
+ do_check_eq(external.getElementsByAttribute("foo:foo", "*").length,
+ 3);
+
+ do_check_eq(root.getElementsByAttribute("foo2:foo", "bar").length,
+ 0);
+ do_check_eq(root.getElementsByAttribute("foo:foo", "baz").length,
+ 0);
+}
+
+function test_getElementsByAttributeNS()
+{
+ var doc = ParseFile("nodelist_data_2.xul");
+ var root = doc.documentElement;
+
+ // Sadly, DOMParser can't create XULDocument objects. But at least we have a
+ // XULElement!
+
+ do_check_true(root instanceof nsIDOMXULElement);
+
+ // Check that getElementsByAttributeNS returns a nodelist.
+ do_check_true(root.getElementsByAttributeNS("*", "*", "*") instanceof
+ nsIDOMNodeList);
+
+ var master1 = doc.getElementById("master1");
+ var master2 = doc.getElementById("master2");
+ var master3 = doc.getElementById("master3");
+ var external = doc.getElementById("external");
+
+ do_check_true(master1 instanceof nsIDOMXULElement);
+ do_check_true(master2 instanceof nsIDOMXULElement);
+ do_check_true(master3 instanceof nsIDOMXULElement);
+ do_check_true(external instanceof nsIDOMXULElement);
+
+ // Test wildcard namespace
+ do_check_eq(root.getElementsByAttributeNS("*", "foo", "foo").length,
+ 38);
+ do_check_eq(master1.getElementsByAttributeNS("*", "foo", "foo").length,
+ 11);
+ do_check_eq(master2.getElementsByAttributeNS("*", "foo", "foo").length,
+ 10);
+ do_check_eq(master3.getElementsByAttributeNS("*", "foo", "foo").length,
+ 11);
+
+ do_check_eq(root.getElementsByAttributeNS("*", "foo", "bar").length,
+ 16);
+ do_check_eq(master1.getElementsByAttributeNS("*", "foo", "bar").length,
+ 4);
+ do_check_eq(master2.getElementsByAttributeNS("*", "foo", "bar").length,
+ 5);
+ do_check_eq(master3.getElementsByAttributeNS("*", "foo", "bar").length,
+ 4);
+
+ do_check_eq(root.getElementsByAttributeNS("*", "bar", "bar").length,
+ 21);
+ do_check_eq(master1.getElementsByAttributeNS("*", "bar", "bar").length,
+ 6);
+ do_check_eq(master2.getElementsByAttributeNS("*", "bar", "bar").length,
+ 6);
+ do_check_eq(master3.getElementsByAttributeNS("*", "bar", "bar").length,
+ 6);
+
+ do_check_eq(root.getElementsByAttributeNS("*", "foo", "*").length,
+ 54);
+ do_check_eq(master1.getElementsByAttributeNS("*", "foo", "*").length,
+ 15);
+ do_check_eq(master2.getElementsByAttributeNS("*", "foo", "*").length,
+ 15);
+ do_check_eq(master3.getElementsByAttributeNS("*", "foo", "*").length,
+ 15);
+
+ // Test null namespace. This should be the same as getElementsByAttribute.
+ do_check_eq(root.getElementsByAttributeNS("", "foo", "foo").length,
+ root.getElementsByAttribute("foo", "foo").length);
+ do_check_eq(master1.getElementsByAttributeNS("", "foo", "foo").length,
+ master1.getElementsByAttribute("foo", "foo").length);
+ do_check_eq(master2.getElementsByAttributeNS("", "foo", "foo").length,
+ master2.getElementsByAttribute("foo", "foo").length);
+ do_check_eq(master3.getElementsByAttributeNS("", "foo", "foo").length,
+ master3.getElementsByAttribute("foo", "foo").length);
+
+ // Test namespace "foo"
+ do_check_eq(root.getElementsByAttributeNS("foo", "foo", "foo").length,
+ 24);
+ do_check_eq(master1.getElementsByAttributeNS("foo", "foo", "foo").length,
+ 7);
+ do_check_eq(master2.getElementsByAttributeNS("foo", "foo", "foo").length,
+ 6);
+ do_check_eq(master3.getElementsByAttributeNS("foo", "foo", "foo").length,
+ 7);
+
+ do_check_eq(root.getElementsByAttributeNS("foo", "foo", "bar").length,
+ 9);
+ do_check_eq(master1.getElementsByAttributeNS("foo", "foo", "bar").length,
+ 2);
+ do_check_eq(master2.getElementsByAttributeNS("foo", "foo", "bar").length,
+ 3);
+ do_check_eq(master3.getElementsByAttributeNS("foo", "foo", "bar").length,
+ 2);
+
+ do_check_eq(root.getElementsByAttributeNS("foo", "bar", "foo").length,
+ 7);
+ do_check_eq(master1.getElementsByAttributeNS("foo", "bar", "foo").length,
+ 2);
+ do_check_eq(master2.getElementsByAttributeNS("foo", "bar", "foo").length,
+ 2);
+ do_check_eq(master3.getElementsByAttributeNS("foo", "bar", "foo").length,
+ 2);
+
+ do_check_eq(root.getElementsByAttributeNS("foo", "bar", "bar").length,
+ 14);
+ do_check_eq(master1.getElementsByAttributeNS("foo", "bar", "bar").length,
+ 4);
+ do_check_eq(master2.getElementsByAttributeNS("foo", "bar", "bar").length,
+ 4);
+ do_check_eq(master3.getElementsByAttributeNS("foo", "bar", "bar").length,
+ 4);
+}
diff --git a/dom/base/test/unit/test_normalize.js b/dom/base/test/unit/test_normalize.js
new file mode 100644
index 000000000..a4f1b4df7
--- /dev/null
+++ b/dom/base/test/unit/test_normalize.js
@@ -0,0 +1,109 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function run_test()
+{
+ /*
+ * NOTE: [i] is not allowed in this test, since it's done via classinfo and
+ * we don't have that in xpcshell; the workaround is item(i). Suck.
+ */
+ init();
+
+ test_element();
+
+ // more tests would be nice here (such as for documents), but the primary
+ // uses of Node.normalize() are in test_element; stuff beyond this is either
+ // unimplemented or is unlikely to be used all that much within a browser
+ // DOM implementation
+}
+
+// TEST CODE
+
+var doc; // cache for use in all tests
+
+function init()
+{
+ doc = ParseFile("empty_document.xml");
+}
+
+function test_element()
+{
+ var x = doc.createElement("funk");
+
+ // one empty Text node
+ x.appendChild(doc.createTextNode(""));
+ do_check_eq(x.childNodes.length, 1);
+
+ x.normalize();
+ do_check_eq(x.childNodes.length, 0);
+
+
+ // multiple empty Text nodes
+ x.appendChild(doc.createTextNode(""));
+ x.appendChild(doc.createTextNode(""));
+ do_check_eq(x.childNodes.length, 2);
+
+ x.normalize();
+ do_check_eq(x.childNodes.length, 0);
+
+
+ // empty Text node followed by other Text node
+ x.appendChild(doc.createTextNode(""));
+ x.appendChild(doc.createTextNode("Guaraldi"));
+ do_check_eq(x.childNodes.length, 2);
+
+ x.normalize();
+ do_check_eq(x.childNodes.length, 1);
+ do_check_eq(x.childNodes.item(0).nodeValue, "Guaraldi");
+
+
+ // Text node followed by empty Text node
+ clearKids(x);
+ x.appendChild(doc.createTextNode("Guaraldi"));
+ x.appendChild(doc.createTextNode(""));
+ do_check_eq(x.childNodes.length, 2);
+
+ x.normalize();
+ do_check_eq(x.childNodes.item(0).nodeValue, "Guaraldi");
+
+
+ // Text node followed by empty Text node followed by other Node
+ clearKids(x);
+ x.appendChild(doc.createTextNode("Guaraldi"));
+ x.appendChild(doc.createTextNode(""));
+ x.appendChild(doc.createElement("jazzy"));
+ do_check_eq(x.childNodes.length, 3);
+
+ x.normalize();
+ do_check_eq(x.childNodes.length, 2);
+ do_check_eq(x.childNodes.item(0).nodeValue, "Guaraldi");
+ do_check_eq(x.childNodes.item(1).nodeName, "jazzy");
+
+
+ // Nodes are recursively normalized
+ clearKids(x);
+ var kid = doc.createElement("eit");
+ kid.appendChild(doc.createTextNode(""));
+
+ x.appendChild(doc.createTextNode("Guaraldi"));
+ x.appendChild(doc.createTextNode(""));
+ x.appendChild(kid);
+ do_check_eq(x.childNodes.length, 3);
+ do_check_eq(x.childNodes.item(2).childNodes.length, 1);
+
+ x.normalize();
+ do_check_eq(x.childNodes.length, 2);
+ do_check_eq(x.childNodes.item(0).nodeValue, "Guaraldi");
+ do_check_eq(x.childNodes.item(1).childNodes.length, 0);
+}
+
+
+// UTILITY FUNCTIONS
+
+function clearKids(node)
+{
+ while (node.hasChildNodes())
+ node.removeChild(node.childNodes.item(0));
+}
diff --git a/dom/base/test/unit/test_range.js b/dom/base/test/unit/test_range.js
new file mode 100644
index 000000000..0ba1e1cd8
--- /dev/null
+++ b/dom/base/test/unit/test_range.js
@@ -0,0 +1,465 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const C_i = Components.interfaces;
+
+const UNORDERED_TYPE = C_i.nsIDOMXPathResult.ANY_UNORDERED_NODE_TYPE;
+
+/**
+ * Determine if the data node has only ignorable white-space.
+ *
+ * @return nsIDOMNodeFilter.FILTER_SKIP if it does.
+ * @return nsIDOMNodeFilter.FILTER_ACCEPT otherwise.
+ */
+function isWhitespace(aNode) {
+ return ((/\S/).test(aNode.nodeValue)) ?
+ C_i.nsIDOMNodeFilter.FILTER_SKIP :
+ C_i.nsIDOMNodeFilter.FILTER_ACCEPT;
+}
+
+/**
+ * Create a DocumentFragment with cloned children equaling a node's children.
+ *
+ * @param aNode The node to copy from.
+ *
+ * @return DocumentFragment node.
+ */
+function getFragment(aNode) {
+ var frag = aNode.ownerDocument.createDocumentFragment();
+ for (var i = 0; i < aNode.childNodes.length; i++) {
+ frag.appendChild(aNode.childNodes.item(i).cloneNode(true));
+ }
+ return frag;
+}
+
+// Goodies from head_content.js
+const serializer = new DOMSerializer();
+const parser = new DOMParser();
+
+/**
+ * Dump the contents of a document fragment to the console.
+ *
+ * @param aFragment The fragment to serialize.
+ */
+function dumpFragment(aFragment) {
+ dump(serializer.serializeToString(aFragment) + "\n\n");
+}
+
+/**
+ * Translate an XPath to a DOM node. This method uses a document
+ * fragment as context node.
+ *
+ * @param aContextNode The context node to apply the XPath to.
+ * @param aPath The XPath to use.
+ *
+ * @return nsIDOMNode The target node retrieved from the XPath.
+ */
+function evalXPathInDocumentFragment(aContextNode, aPath) {
+ do_check_true(aContextNode instanceof C_i.nsIDOMDocumentFragment);
+ do_check_true(aContextNode.childNodes.length > 0);
+ if (aPath == ".") {
+ return aContextNode;
+ }
+
+ // Separate the fragment's xpath lookup from the rest.
+ var firstSlash = aPath.indexOf("/");
+ if (firstSlash == -1) {
+ firstSlash = aPath.length;
+ }
+ var prefix = aPath.substr(0, firstSlash);
+ var realPath = aPath.substr(firstSlash + 1);
+ if (!realPath) {
+ realPath = ".";
+ }
+
+ // Set up a special node filter to look among the fragment's child nodes.
+ var childIndex = 1;
+ var bracketIndex = prefix.indexOf("[");
+ if (bracketIndex != -1) {
+ childIndex = Number(prefix.substring(bracketIndex + 1, prefix.indexOf("]")));
+ do_check_true(childIndex > 0);
+ prefix = prefix.substr(0, bracketIndex);
+ }
+
+ var targetType = C_i.nsIDOMNodeFilter.SHOW_ELEMENT;
+ var targetNodeName = prefix;
+ if (prefix.indexOf("processing-instruction(") == 0) {
+ targetType = C_i.nsIDOMNodeFilter.SHOW_PROCESSING_INSTRUCTION;
+ targetNodeName = prefix.substring(prefix.indexOf("(") + 2, prefix.indexOf(")") - 1);
+ }
+ switch (prefix) {
+ case "text()":
+ targetType = C_i.nsIDOMNodeFilter.SHOW_TEXT |
+ C_i.nsIDOMNodeFilter.SHOW_CDATA_SECTION;
+ targetNodeName = null;
+ break;
+ case "comment()":
+ targetType = C_i.nsIDOMNodeFilter.SHOW_COMMENT;
+ targetNodeName = null;
+ break;
+ case "node()":
+ targetType = C_i.nsIDOMNodeFilter.SHOW_ALL;
+ targetNodeName = null;
+ }
+
+ var filter = {
+ count: 0,
+
+ // nsIDOMNodeFilter
+ acceptNode: function acceptNode(aNode) {
+ if (aNode.parentNode != aContextNode) {
+ // Don't bother looking at kids either.
+ return C_i.nsIDOMNodeFilter.FILTER_REJECT;
+ }
+
+ if (targetNodeName && targetNodeName != aNode.nodeName) {
+ return C_i.nsIDOMNodeFilter.FILTER_SKIP;
+ }
+
+ this.count++;
+ if (this.count != childIndex) {
+ return C_i.nsIDOMNodeFilter.FILTER_SKIP;
+ }
+
+ return C_i.nsIDOMNodeFilter.FILTER_ACCEPT;
+ }
+ };
+
+ // Look for the node matching the step from the document fragment.
+ var walker = aContextNode.ownerDocument.createTreeWalker(
+ aContextNode,
+ targetType,
+ filter);
+ var targetNode = walker.nextNode();
+ do_check_neq(targetNode, null);
+
+ // Apply our remaining xpath to the found node.
+ var expr = aContextNode.ownerDocument.createExpression(realPath, null);
+ var result = expr.evaluate(targetNode, UNORDERED_TYPE, null);
+ return result.singleNodeValue;
+}
+
+/**
+ * Get a DOM range corresponding to the test's source node.
+ *
+ * @param aSourceNode element with range information.
+ * @param aFragment DocumentFragment generated with getFragment().
+ *
+ * @return Range object.
+ */
+function getRange(aSourceNode, aFragment) {
+ do_check_true(aSourceNode instanceof C_i.nsIDOMElement);
+ do_check_true(aFragment instanceof C_i.nsIDOMDocumentFragment);
+ var doc = aSourceNode.ownerDocument;
+
+ var containerPath = aSourceNode.getAttribute("startContainer");
+ var startContainer = evalXPathInDocumentFragment(aFragment, containerPath);
+ var startOffset = Number(aSourceNode.getAttribute("startOffset"));
+
+ containerPath = aSourceNode.getAttribute("endContainer");
+ var endContainer = evalXPathInDocumentFragment(aFragment, containerPath);
+ var endOffset = Number(aSourceNode.getAttribute("endOffset"));
+
+ var range = doc.createRange();
+ range.setStart(startContainer, startOffset);
+ range.setEnd(endContainer, endOffset);
+ return range;
+}
+
+/**
+ * Get the document for a given path, and clean it up for our tests.
+ *
+ * @param aPath The path to the local document.
+ */
+function getParsedDocument(aPath) {
+ return do_parse_document(aPath, "application/xml").then(processParsedDocument);
+}
+
+function processParsedDocument(doc) {
+ do_check_true(doc.documentElement.localName != "parsererror");
+ do_check_true(doc instanceof C_i.nsIDOMXPathEvaluator);
+ do_check_true(doc instanceof C_i.nsIDOMDocument);
+
+ // Clean out whitespace.
+ var walker = doc.createTreeWalker(doc,
+ C_i.nsIDOMNodeFilter.SHOW_TEXT |
+ C_i.nsIDOMNodeFilter.SHOW_CDATA_SECTION,
+ isWhitespace);
+ while (walker.nextNode()) {
+ var parent = walker.currentNode.parentNode;
+ parent.removeChild(walker.currentNode);
+ walker.currentNode = parent;
+ }
+
+ // Clean out mandatory splits between nodes.
+ var splits = doc.getElementsByTagName("split");
+ var i;
+ for (i = splits.length - 1; i >= 0; i--) {
+ var node = splits.item(i);
+ node.parentNode.removeChild(node);
+ }
+ splits = null;
+
+ // Replace empty CDATA sections.
+ var emptyData = doc.getElementsByTagName("empty-cdata");
+ for (i = emptyData.length - 1; i >= 0; i--) {
+ var node = emptyData.item(i);
+ var cdata = doc.createCDATASection("");
+ node.parentNode.replaceChild(cdata, node);
+ }
+
+ return doc;
+}
+
+/**
+ * Run the extraction tests.
+ */
+function run_extract_test() {
+ var filePath = "test_delete_range.xml";
+ getParsedDocument(filePath).then(do_extract_test);
+}
+
+function do_extract_test(doc) {
+ var tests = doc.getElementsByTagName("test");
+
+ // Run our deletion, extraction tests.
+ for (var i = 0; i < tests.length; i++) {
+ dump("Configuring for test " + i + "\n");
+ var currentTest = tests.item(i);
+
+ // Validate the test is properly formatted for what this harness expects.
+ var baseSource = currentTest.firstChild;
+ do_check_eq(baseSource.nodeName, "source");
+ var baseResult = baseSource.nextSibling;
+ do_check_eq(baseResult.nodeName, "result");
+ var baseExtract = baseResult.nextSibling;
+ do_check_eq(baseExtract.nodeName, "extract");
+ do_check_eq(baseExtract.nextSibling, null);
+
+ /* We do all our tests on DOM document fragments, derived from the test
+ element's children. This lets us rip the various fragments to shreds,
+ while preserving the original elements so we can make more copies of
+ them.
+
+ After the range's extraction or deletion is done, we use
+ nsIDOMNode.isEqualNode() between the altered source fragment and the
+ result fragment. We also run isEqualNode() between the extracted
+ fragment and the fragment from the baseExtract node. If they are not
+ equal, we have failed a test.
+
+ We also have to ensure the original nodes on the end points of the
+ range are still in the source fragment. This is bug 332148. The nodes
+ may not be replaced with equal but separate nodes. The range extraction
+ may alter these nodes - in the case of text containers, they will - but
+ the nodes must stay there, to preserve references such as user data,
+ event listeners, etc.
+
+ First, an extraction test.
+ */
+
+ var resultFrag = getFragment(baseResult);
+ var extractFrag = getFragment(baseExtract);
+
+ dump("Extract contents test " + i + "\n\n");
+ var baseFrag = getFragment(baseSource);
+ var baseRange = getRange(baseSource, baseFrag);
+ var startContainer = baseRange.startContainer;
+ var endContainer = baseRange.endContainer;
+
+ var cutFragment = baseRange.extractContents();
+ dump("cutFragment: " + cutFragment + "\n");
+ if (cutFragment) {
+ do_check_true(extractFrag.isEqualNode(cutFragment));
+ } else {
+ do_check_eq(extractFrag.firstChild, null);
+ }
+ do_check_true(baseFrag.isEqualNode(resultFrag));
+
+ dump("Ensure the original nodes weren't extracted - test " + i + "\n\n");
+ var walker = doc.createTreeWalker(baseFrag,
+ C_i.nsIDOMNodeFilter.SHOW_ALL,
+ null);
+ var foundStart = false;
+ var foundEnd = false;
+ do {
+ if (walker.currentNode == startContainer) {
+ foundStart = true;
+ }
+
+ if (walker.currentNode == endContainer) {
+ // An end container node should not come before the start container node.
+ do_check_true(foundStart);
+ foundEnd = true;
+ break;
+ }
+ } while (walker.nextNode())
+ do_check_true(foundEnd);
+
+ /* Now, we reset our test for the deleteContents case. This one differs
+ from the extractContents case only in that there is no extracted document
+ fragment to compare against. So we merely compare the starting fragment,
+ minus the extracted content, against the result fragment.
+ */
+ dump("Delete contents test " + i + "\n\n");
+ baseFrag = getFragment(baseSource);
+ baseRange = getRange(baseSource, baseFrag);
+ var startContainer = baseRange.startContainer;
+ var endContainer = baseRange.endContainer;
+ baseRange.deleteContents();
+ do_check_true(baseFrag.isEqualNode(resultFrag));
+
+ dump("Ensure the original nodes weren't deleted - test " + i + "\n\n");
+ walker = doc.createTreeWalker(baseFrag,
+ C_i.nsIDOMNodeFilter.SHOW_ALL,
+ null);
+ foundStart = false;
+ foundEnd = false;
+ do {
+ if (walker.currentNode == startContainer) {
+ foundStart = true;
+ }
+
+ if (walker.currentNode == endContainer) {
+ // An end container node should not come before the start container node.
+ do_check_true(foundStart);
+ foundEnd = true;
+ break;
+ }
+ } while (walker.nextNode())
+ do_check_true(foundEnd);
+
+ // Clean up after ourselves.
+ walker = null;
+ }
+}
+
+/**
+ * Miscellaneous tests not covered above.
+ */
+function run_miscellaneous_tests() {
+ var filePath = "test_delete_range.xml";
+ getParsedDocument(filePath).then(do_miscellaneous_tests);
+}
+
+function do_miscellaneous_tests(doc) {
+ var tests = doc.getElementsByTagName("test");
+
+ // Let's try some invalid inputs to our DOM range and see what happens.
+ var currentTest = tests.item(0);
+ var baseSource = currentTest.firstChild;
+ var baseResult = baseSource.nextSibling;
+ var baseExtract = baseResult.nextSibling;
+
+ var baseFrag = getFragment(baseSource);
+
+ var baseRange = getRange(baseSource, baseFrag);
+ var startContainer = baseRange.startContainer;
+ var endContainer = baseRange.endContainer;
+ var startOffset = baseRange.startOffset;
+ var endOffset = baseRange.endOffset;
+
+ // Text range manipulation.
+ if ((endOffset > startOffset) &&
+ (startContainer == endContainer) &&
+ (startContainer instanceof C_i.nsIDOMText)) {
+ // Invalid start node
+ try {
+ baseRange.setStart(null, 0);
+ do_throw("Should have thrown NOT_OBJECT_ERR!");
+ } catch (e) {
+ do_check_eq(e.constructor.name, "TypeError");
+ }
+
+ // Invalid start node
+ try {
+ baseRange.setStart({}, 0);
+ do_throw("Should have thrown SecurityError!");
+ } catch (e) {
+ do_check_eq(e.constructor.name, "TypeError");
+ }
+
+ // Invalid index
+ try {
+ baseRange.setStart(startContainer, -1);
+ do_throw("Should have thrown IndexSizeError!");
+ } catch (e) {
+ do_check_eq(e.name, "IndexSizeError");
+ }
+
+ // Invalid index
+ var newOffset = startContainer instanceof C_i.nsIDOMText ?
+ startContainer.nodeValue.length + 1 :
+ startContainer.childNodes.length + 1;
+ try {
+ baseRange.setStart(startContainer, newOffset);
+ do_throw("Should have thrown IndexSizeError!");
+ } catch (e) {
+ do_check_eq(e.name, "IndexSizeError");
+ }
+
+ newOffset--;
+ // Valid index
+ baseRange.setStart(startContainer, newOffset);
+ do_check_eq(baseRange.startContainer, baseRange.endContainer);
+ do_check_eq(baseRange.startOffset, newOffset);
+ do_check_true(baseRange.collapsed);
+
+ // Valid index
+ baseRange.setEnd(startContainer, 0);
+ do_check_eq(baseRange.startContainer, baseRange.endContainer);
+ do_check_eq(baseRange.startOffset, 0);
+ do_check_true(baseRange.collapsed);
+ } else {
+ do_throw("The first test should be a text-only range test. Test is invalid.")
+ }
+
+ /* See what happens when a range has a startContainer in one fragment, and an
+ endContainer in another. According to the DOM spec, section 2.4, the range
+ should collapse to the new container and offset. */
+ baseRange = getRange(baseSource, baseFrag);
+ startContainer = baseRange.startContainer;
+ var startOffset = baseRange.startOffset;
+ endContainer = baseRange.endContainer;
+ var endOffset = baseRange.endOffset;
+
+ dump("External fragment test\n\n");
+
+ var externalTest = tests.item(1);
+ var externalSource = externalTest.firstChild;
+ var externalFrag = getFragment(externalSource);
+ var externalRange = getRange(externalSource, externalFrag);
+
+ baseRange.setEnd(externalRange.endContainer, 0);
+ do_check_eq(baseRange.startContainer, externalRange.endContainer);
+ do_check_eq(baseRange.startOffset, 0);
+ do_check_true(baseRange.collapsed);
+
+ /*
+ // XXX ajvincent if rv == WRONG_DOCUMENT_ERR, return false?
+ do_check_false(baseRange.isPointInRange(startContainer, startOffset));
+ do_check_false(baseRange.isPointInRange(startContainer, startOffset + 1));
+ do_check_false(baseRange.isPointInRange(endContainer, endOffset));
+ */
+
+ // Requested by smaug: A range involving a comment as a document child.
+ doc = parser.parseFromString(" ", "application/xml");
+ do_check_true(doc instanceof C_i.nsIDOMDocument);
+ do_check_eq(doc.childNodes.length, 2);
+ baseRange = doc.createRange();
+ baseRange.setStart(doc.firstChild, 1);
+ baseRange.setEnd(doc.firstChild, 2);
+ var frag = baseRange.extractContents();
+ do_check_eq(frag.childNodes.length, 1);
+ do_check_true(frag.firstChild instanceof C_i.nsIDOMComment);
+ do_check_eq(frag.firstChild.nodeValue, "f");
+
+ /* smaug also requested attribute tests. Sadly, those are not yet supported
+ in ranges - see https://bugzilla.mozilla.org/show_bug.cgi?id=302775.
+ */
+}
+
+function run_test() {
+ run_extract_test();
+ run_miscellaneous_tests();
+}
diff --git a/dom/base/test/unit/test_thirdpartyutil.js b/dom/base/test/unit/test_thirdpartyutil.js
new file mode 100644
index 000000000..2c4ef4745
--- /dev/null
+++ b/dom/base/test/unit/test_thirdpartyutil.js
@@ -0,0 +1,96 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Test ThirdPartyUtil methods. See mozIThirdPartyUtil.
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cu = Components.utils;
+
+Cu.import("resource://gre/modules/NetUtil.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+var prefs = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+
+// Since this test creates a TYPE_DOCUMENT channel via javascript, it will
+// end up using the wrong LoadInfo constructor. Setting this pref will disable
+// the ContentPolicyType assertion in the constructor.
+prefs.setBoolPref("network.loadinfo.skip_type_assertion", true);
+
+var NS_ERROR_INVALID_ARG = Components.results.NS_ERROR_INVALID_ARG;
+
+function do_check_throws(f, result, stack)
+{
+ if (!stack) {
+ try {
+ // We might not have a 'Components' object.
+ stack = Components.stack.caller;
+ } catch (e) {
+ }
+ }
+
+ try {
+ f();
+ } catch (exc) {
+ do_check_eq(exc.result, result);
+ return;
+ }
+ do_throw("expected " + result + " exception, none thrown", stack);
+}
+
+function run_test() {
+ let util = Cc["@mozilla.org/thirdpartyutil;1"].getService(Ci.mozIThirdPartyUtil);
+
+ // Create URIs and channels pointing to foo.com and bar.com.
+ // We will use these to put foo.com into first and third party contexts.
+ let spec1 = "http://foo.com/foo.html";
+ let spec2 = "http://bar.com/bar.html";
+ let uri1 = NetUtil.newURI(spec1);
+ let uri2 = NetUtil.newURI(spec2);
+ const contentPolicyType = Ci.nsIContentPolicy.TYPE_DOCUMENT;
+ let channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true, contentPolicyType});
+ let channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true, contentPolicyType});
+
+ // Create some file:// URIs.
+ let filespec1 = "file://foo.txt";
+ let filespec2 = "file://bar.txt";
+ let fileuri1 = NetUtil.newURI(filespec1);
+ let fileuri2 = NetUtil.newURI(filespec2);
+ let filechannel1 = NetUtil.newChannel({uri: fileuri1, loadUsingSystemPrincipal: true});
+ let filechannel2 = NetUtil.newChannel({uri: fileuri2, loadUsingSystemPrincipal: true});
+
+ // Test isThirdPartyURI.
+ do_check_false(util.isThirdPartyURI(uri1, uri1));
+ do_check_true(util.isThirdPartyURI(uri1, uri2));
+ do_check_true(util.isThirdPartyURI(uri2, uri1));
+ do_check_false(util.isThirdPartyURI(fileuri1, fileuri1));
+ do_check_false(util.isThirdPartyURI(fileuri1, fileuri2));
+ do_check_true(util.isThirdPartyURI(uri1, fileuri1));
+ do_check_throws(function() { util.isThirdPartyURI(uri1, null); },
+ NS_ERROR_INVALID_ARG);
+ do_check_throws(function() { util.isThirdPartyURI(null, uri1); },
+ NS_ERROR_INVALID_ARG);
+ do_check_throws(function() { util.isThirdPartyURI(null, null); },
+ NS_ERROR_INVALID_ARG);
+
+ // We can't test isThirdPartyWindow since we can't really set up a window
+ // hierarchy. We leave that to mochitests.
+
+ // Test isThirdPartyChannel. As above, we can't test the bits that require
+ // a load context or window heirarchy. Because of bug 1259873, we assume
+ // that these are not third-party.
+ do_check_throws(function() { util.isThirdPartyChannel(null); },
+ NS_ERROR_INVALID_ARG);
+ do_check_false(util.isThirdPartyChannel(channel1));
+ do_check_false(util.isThirdPartyChannel(channel1, uri1));
+ do_check_true(util.isThirdPartyChannel(channel1, uri2));
+
+ let httpchannel1 = channel1.QueryInterface(Ci.nsIHttpChannelInternal);
+ httpchannel1.forceAllowThirdPartyCookie = true;
+ do_check_false(util.isThirdPartyChannel(channel1));
+ do_check_false(util.isThirdPartyChannel(channel1, uri1));
+ do_check_true(util.isThirdPartyChannel(channel1, uri2));
+}
+
diff --git a/dom/base/test/unit/test_treewalker.js b/dom/base/test/unit/test_treewalker.js
new file mode 100644
index 000000000..e9aff3435
--- /dev/null
+++ b/dom/base/test/unit/test_treewalker.js
@@ -0,0 +1,26 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function run_test()
+{
+ test_treeWalker_currentNode();
+}
+
+// TEST CODE
+
+function test_treeWalker_currentNode()
+{
+ var XHTMLDocString = '';
+ XHTMLDocString += ' input';
+
+ var doc = ParseXML(XHTMLDocString);
+
+ var body = doc.getElementsByTagName("body")[0];
+ var filter = I.nsIDOMNodeFilter.SHOW_ELEMENT | I.nsIDOMNodeFilter.SHOW_TEXT;
+ var walker = doc.createTreeWalker(body, filter, null);
+ walker.currentNode = body.firstChild;
+ walker.nextNode();
+}
+
diff --git a/dom/base/test/unit/test_xhr_document.js b/dom/base/test/unit/test_xhr_document.js
new file mode 100644
index 000000000..5a090d598
--- /dev/null
+++ b/dom/base/test/unit/test_xhr_document.js
@@ -0,0 +1,42 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cu = Components.utils;
+
+Cu.import("resource://testing-common/httpd.js");
+Cu.import("resource://gre/modules/NetUtil.jsm");
+
+var server = new HttpServer();
+server.start(-1);
+
+var docbody = '';
+
+function handler(metadata, response) {
+ let body = NetUtil.readInputStreamToString(metadata.bodyInputStream,
+ metadata.bodyInputStream.available());
+ response.setStatusLine(metadata.httpVersion, 200, "OK");
+ response.write(body, body.length);
+}
+
+function run_test() {
+ do_test_pending();
+ server.registerPathHandler("/foo", handler);
+
+ var parser = Cc["@mozilla.org/xmlextras/domparser;1"].createInstance(Ci.nsIDOMParser);
+ parser.init();
+ let doc = parser.parseFromString(docbody, "text/html");
+ let xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Ci.nsIXMLHttpRequest);
+ xhr.onload = function() {
+ do_check_eq(xhr.responseText, docbody);
+ server.stop(do_test_finished);
+ };
+ xhr.onerror = function() {
+ do_check_false(false);
+ server.stop(do_test_finished);
+ };
+ xhr.open("POST", "http://localhost:" + server.identity.primaryPort + "/foo", true);
+ xhr.send(doc);
+}
diff --git a/dom/base/test/unit/test_xhr_origin_attributes.js b/dom/base/test/unit/test_xhr_origin_attributes.js
new file mode 100644
index 000000000..5c53771da
--- /dev/null
+++ b/dom/base/test/unit/test_xhr_origin_attributes.js
@@ -0,0 +1,50 @@
+let Cc = Components.classes;
+let Ci = Components.interfaces;
+let Cu = Components.utils;
+
+Cu.import("resource://testing-common/httpd.js");
+
+let server = new HttpServer();
+server.start(-1);
+
+let body = " ";
+
+function handler(request, response) {
+ response.setStatusLine(request.httpVersion, 200, "Ok");
+ response.setHeader("Content-Type", "text/html", false);
+
+ if (!request.hasHeader("Cookie")) {
+ response.setHeader("Set-Cookie", "test", false);
+ ok(true);
+ } else {
+ ok(false);
+ }
+
+ response.bodyOutputStream.write(body, body.length);
+}
+
+function run_test() {
+ do_test_pending();
+ server.registerPathHandler("/foo", handler);
+
+ let xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Ci.nsIXMLHttpRequest);
+ xhr.open("GET", "http://localhost:" + server.identity.primaryPort + "/foo", true);
+ xhr.send(null);
+
+ xhr.onload = function() {
+ // We create another XHR to connect to the same site, but this time we
+ // specify with different origin attributes, which will make the XHR use a
+ // different cookie-jar than the previous one.
+ let xhr2 = Cc['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Ci.nsIXMLHttpRequest);
+ xhr2.open("GET", "http://localhost:" + server.identity.primaryPort + "/foo", true);
+ xhr2.setOriginAttributes({userContextId: 1});
+ xhr2.send(null);
+
+ let loadInfo = xhr2.channel.loadInfo;
+ Assert.equal(loadInfo.originAttributes.userContextId, 1);
+
+ xhr2.onload = function() {
+ server.stop(do_test_finished);
+ }
+ };
+}
diff --git a/dom/base/test/unit/test_xhr_standalone.js b/dom/base/test/unit/test_xhr_standalone.js
new file mode 100644
index 000000000..e1e55f3f5
--- /dev/null
+++ b/dom/base/test/unit/test_xhr_standalone.js
@@ -0,0 +1,21 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Test setting .responseType and .withCredentials is allowed
+// in non-window non-Worker context
+
+function run_test()
+{
+ var xhr = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].
+ createInstance(Components.interfaces.nsIXMLHttpRequest);
+ xhr.open('GET', 'data:,', false);
+ var exceptionThrown = false;
+ try {
+ xhr.responseType = '';
+ xhr.withCredentials = false;
+ } catch (e) {
+ exceptionThrown = true;
+ }
+ do_check_eq(false, exceptionThrown);
+}
diff --git a/dom/base/test/unit/test_xml_parser.js b/dom/base/test/unit/test_xml_parser.js
new file mode 100644
index 000000000..a87c21672
--- /dev/null
+++ b/dom/base/test/unit/test_xml_parser.js
@@ -0,0 +1,48 @@
+function run_test () {
+ for (var i = 0; i < tests.length && tests[i][0]; ++i) {
+ if (!tests[i][0].call()) {
+ do_throw(tests[i][1]);
+ }
+ }
+}
+
+var tests = [
+ [ test1, "Unable to parse basic XML document" ],
+ [ test2, "ParseXML doesn't return nsIDOMDocument" ],
+ [ test3, "ParseXML return value's documentElement is not nsIDOMElement" ],
+ [ test4, "" ],
+ [ test5, "" ],
+ [ test6, "" ],
+ [ null ]
+];
+
+function test1() {
+ return ParseXML(" ");
+}
+
+function test2() {
+ return (ParseXML(" ") instanceof nsIDOMDocument);
+}
+
+function test3() {
+ return (ParseXML(" ").documentElement instanceof nsIDOMElement);
+}
+
+function test4() {
+ var doc = ParseXML(" ");
+ do_check_eq(doc.documentElement.namespaceURI, null);
+ return true;
+}
+
+function test5() {
+ var doc = ParseXML(" ");
+ do_check_eq(doc.documentElement.namespaceURI, null);
+ return true;
+}
+
+function test6() {
+ var doc = ParseXML(" ");
+ do_check_neq(doc.documentElement.namespaceURI, null);
+ do_check_eq(doc.documentElement.namespaceURI, 'ns1');
+ return true;
+}
diff --git a/dom/base/test/unit/test_xml_serializer.js b/dom/base/test/unit/test_xml_serializer.js
new file mode 100644
index 000000000..c74d067a8
--- /dev/null
+++ b/dom/base/test/unit/test_xml_serializer.js
@@ -0,0 +1,374 @@
+
+// The xml serializer uses the default line break of the plateform.
+// So we need to know the value of this default line break, in order
+// to build correctly the reference strings for tests.
+// This variable will contain this value.
+var LB;
+
+function run_test() {
+
+ if (mozinfo.os == "win") {
+ LB = "\r\n";
+ } else {
+ LB = "\n";
+ }
+
+ for (var i = 0; i < tests.length && tests[i]; ++i) {
+ tests[i].call();
+ }
+}
+
+var tests = [
+ test1,
+ test2,
+ test3,
+ test4,
+ test5,
+ test6,
+ test7,
+ test8,
+ test9,
+ test10,
+ null
+];
+
+function testString(str) {
+ do_check_eq(roundtrip(str), str);
+}
+
+function test1() {
+ // Basic round-tripping which we expect to hand back the same text
+ // as we passed in (not strictly required for correctness in some of
+ // those cases, but best for readability of serializer output)
+ testString(' ');
+ testString(' ');
+ testString(' ');
+ testString(' ');
+ testString(' ')
+ testString(' ')
+ testString(' ')
+ testString(' ')
+ testString(' ')
+ testString(' ')
+ testString(' ')
+}
+
+function test2() {
+ // Test setting of "xmlns" attribute in the null namespace
+
+ // XXXbz are these tests needed? What should happen here? These
+ // may be bogus.
+
+ // Setting random "xmlns" attribute
+ var doc = ParseXML(' ');
+ doc.documentElement.setAttribute("xmlns", "ns2");
+ do_check_serialize(doc);
+}
+
+function test3() {
+ // Test basic appending of kids. Again, we're making assumptions
+ // about how our serializer will serialize simple DOMs.
+ var doc = ParseXML(' ');
+ var root = doc.documentElement;
+ var child = doc.createElementNS("ns2", "child");
+ root.appendChild(child);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' ');
+
+ doc = ParseXML(' ');
+ root = doc.documentElement;
+ child = doc.createElementNS("ns2", "prefix:child");
+ root.appendChild(child);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' ');
+
+ doc = ParseXML(' ');
+ root = doc.documentElement;
+ child = doc.createElementNS("ns2", "prefix:child");
+ root.appendChild(child);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' '+
+ ' ');
+
+}
+
+function test4() {
+ // setAttributeNS tests
+
+ var doc = ParseXML(' ');
+ var root = doc.documentElement;
+ root.setAttributeNS("ns1", "prefix:local", "val");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' ');
+
+ doc = ParseXML(' ');
+ root = doc.documentElement;
+ root.setAttributeNS("ns1", "local", "val");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' ');
+
+ doc = ParseXML(' ');
+ root = doc.documentElement;
+ root.setAttributeNS("ns2", "local", "val");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' ');
+
+ // Handling of prefix-generation for non-null-namespace attributes
+ // which have the same namespace as the current default namespace
+ // (bug 301260).
+ doc = ParseXML(' ');
+ root = doc.documentElement;
+ root.setAttributeNS("ns1", "local", "val");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' ');
+
+ // Tree-walking test
+ doc = ParseXML(''+
+ ''+
+ ' ');
+ root = doc.documentElement;
+ // Have to QI here -- no classinfo flattening in xpcshell, apparently
+ var node = root.firstChild.firstChild.QueryInterface(nsIDOMElement);
+ node.setAttributeNS("ns4", "l1", "v1");
+ node.setAttributeNS("ns4", "p2:l2", "v2");
+ node.setAttributeNS("", "l3", "v3");
+ node.setAttributeNS("ns3", "l4", "v4");
+ node.setAttributeNS("ns3", "p5:l5", "v5");
+ node.setAttributeNS("ns3", "a:l6", "v6");
+ node.setAttributeNS("ns2", "l7", "v7");
+ node.setAttributeNS("ns2", "p8:l8", "v8");
+ node.setAttributeNS("ns2", "b:l9", "v9");
+ node.setAttributeNS("ns2", "a:l10", "v10");
+ node.setAttributeNS("ns1", "a:l11", "v11");
+ node.setAttributeNS("ns1", "b:l12", "v12");
+ node.setAttributeNS("ns1", "l13", "v13");
+ do_check_serialize(doc);
+ // Note: we end up with "a2" as the prefix on "l11" and "l12" because we use
+ // "a1" earlier, and discard it in favor of something we get off the
+ // namespace stack, apparently
+ do_check_eq(SerializeXML(doc),
+ ''+
+ ''+
+ ' ');
+}
+
+function test5() {
+ // Handling of kids in the null namespace when the default is a
+ // different namespace (bug 301260).
+ var doc = ParseXML(' ')
+ var child = doc.createElement('child');
+ doc.documentElement.appendChild(child);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' ');
+}
+
+function test6() {
+ // Handling of not using a namespace prefix (or default namespace!)
+ // that's not bound to our namespace in our scope (bug 301260).
+ var doc = ParseXML(' ');
+ var root = doc.documentElement;
+ var child1 = doc.createElementNS("ns2", "prefix:child1");
+ var child2 = doc.createElementNS("ns1", "prefix:child2");
+ child1.appendChild(child2);
+ root.appendChild(child1);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ''+
+ ' ');
+
+ doc = ParseXML(' ');
+ root = doc.documentElement;
+ child1 = root.firstChild;
+ child2 = doc.createElementNS("ns1", "prefix:child2");
+ child1.appendChild(child2);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ''+
+ ' ');
+
+ doc = ParseXML(''+
+ ' ');
+ root = doc.documentElement;
+ child1 = root.firstChild;
+ child2 = doc.createElementNS("ns1", "prefix:child2");
+ child1.appendChild(child2);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ''+
+ ' ');
+
+
+ doc = ParseXML(' ');
+ root = doc.documentElement;
+ child1 = doc.createElementNS("ns2", "child1");
+ child2 = doc.createElementNS("ns1", "child2");
+ child1.appendChild(child2);
+ root.appendChild(child1);
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ ' '+
+ ' ');
+}
+
+function test7() {
+ // Handle xmlns attribute declaring a default namespace on a non-namespaced
+ // element (bug 326994).
+ var doc = ParseXML(' ')
+ var root = doc.documentElement;
+ root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
+ "http://www.w3.org/1999/xhtml");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc), ' ');
+
+ doc = ParseXML(' ')
+ root = doc.documentElement;
+ root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
+ "http://www.w3.org/1999/xhtml");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc), ' ');
+
+ doc = ParseXML('' +
+ ' ')
+ root = doc.documentElement;
+
+ // No interface flattening in xpcshell
+ var child1 = root.firstChild.QueryInterface(nsIDOMElement);
+ child1.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
+ "http://www.w3.org/1999/xhtml");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ '' +
+ ' ');
+
+ doc = ParseXML('' +
+ '' +
+ ' ' +
+ ' ')
+ root = doc.documentElement;
+ // No interface flattening in xpcshell
+ child1 = root.firstChild.QueryInterface(nsIDOMElement);
+ var child2 = child1.firstChild.QueryInterface(nsIDOMElement);
+ child1.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
+ "http://www.w3.org/1999/xhtml");
+ child2.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "");
+ do_check_serialize(doc);
+ do_check_eq(SerializeXML(doc),
+ '' +
+ ' ');
+}
+
+function test8() {
+ // Test behavior of serializing with a given charset.
+ var str1 = ''+LB+' ';
+ var str2 = ''+LB+' ';
+ var doc1 = ParseXML(str1);
+ var doc2 = ParseXML(str2);
+
+ var p = Pipe();
+ DOMSerializer().serializeToStream(doc1, p.outputStream, "ISO-8859-1");
+ p.outputStream.close();
+ do_check_eq(ScriptableInput(p).read(-1), str1);
+
+ p = Pipe();
+ DOMSerializer().serializeToStream(doc2, p.outputStream, "ISO-8859-1");
+ p.outputStream.close();
+ do_check_eq(ScriptableInput(p).read(-1), str1);
+
+ p = Pipe();
+ DOMSerializer().serializeToStream(doc1, p.outputStream, "UTF8");
+ p.outputStream.close();
+ do_check_eq(ScriptableInput(p).read(-1), str2);
+
+ p = Pipe();
+ DOMSerializer().serializeToStream(doc2, p.outputStream, "UTF8");
+ p.outputStream.close();
+ do_check_eq(ScriptableInput(p).read(-1), str2);
+}
+
+function test9() {
+ // Test behavior of serializing between given charsets, using
+ // ISO-8859-1-representable text.
+ var contents = '' +
+ '\u00BD + \u00BE == \u00BD\u00B2 + \u00BC + \u00BE' +
+ ' ';
+ var str1 = ''+ LB + contents;
+ var str2 = ''+ LB + contents;
+ var str3 = ''+ LB + contents;
+ var doc1 = ParseXML(str1);
+ var doc2 = ParseXML(str2);
+ var doc3 = ParseXML(str3);
+
+ checkSerialization(doc1, "ISO-8859-1", str1);
+ checkSerialization(doc2, "ISO-8859-1", str1);
+ checkSerialization(doc3, "ISO-8859-1", str1);
+
+ checkSerialization(doc1, "UTF8", str2);
+ checkSerialization(doc2, "UTF8", str2);
+ checkSerialization(doc3, "UTF8", str2);
+
+ checkSerialization(doc1, "UTF-16", str3);
+ checkSerialization(doc2, "UTF-16", str3);
+ checkSerialization(doc3, "UTF-16", str3);
+}
+
+function test10() {
+ // Test behavior of serializing between given charsets, using
+ // Unicode characters (XXX but only BMP ones because I don't know
+ // how to create one with non-BMP characters, either with JS strings
+ // or using DOM APIs).
+ var contents = '' +
+ 'AZaz09 \u007F ' + // U+000000 to U+00007F
+ '\u0080 \u0398 \u03BB \u0725 ' + // U+000080 to U+0007FF
+ '\u0964 \u0F5F \u20AC \uFFFB' + // U+000800 to U+00FFFF
+ ' ';
+ var str1 = ''+ LB + contents;
+ var str2 = ''+ LB + contents;
+ var doc1 = ParseXML(str1);
+ var doc2 = ParseXML(str2);
+
+ checkSerialization(doc1, "UTF8", str1);
+ checkSerialization(doc2, "UTF8", str1);
+
+ checkSerialization(doc1, "UTF-16", str2);
+ checkSerialization(doc2, "UTF-16", str2);
+}
+
+function checkSerialization(doc, toCharset, expectedString) {
+ var p = Pipe();
+ DOMSerializer().serializeToStream(doc, p.outputStream, toCharset);
+ p.outputStream.close();
+
+ var cin = C["@mozilla.org/intl/converter-input-stream;1"]
+ .createInstance(I.nsIConverterInputStream);
+ cin.init(p.inputStream, toCharset, 1024, 0x0);
+
+ // compare the first expectedString.length characters for equality
+ var outString = {};
+ var count = cin.readString(expectedString.length, outString);
+ do_check_true(count == expectedString.length);
+ do_check_true(outString.value == expectedString);
+
+ // if there's anything more in the stream, it's a bug
+ do_check_eq(0, cin.readString(1, outString));
+ do_check_eq(outString.value, "");
+}
diff --git a/dom/base/test/unit/test_xmlserializer.js b/dom/base/test/unit/test_xmlserializer.js
new file mode 100644
index 000000000..8c6020a70
--- /dev/null
+++ b/dom/base/test/unit/test_xmlserializer.js
@@ -0,0 +1,112 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function xmlEncode(aFile, aFlags, aCharset) {
+ if(aFlags == undefined) aFlags = 0;
+ if(aCharset == undefined) aCharset = "UTF-8";
+
+ return do_parse_document(aFile, "text/xml").then(doc => {
+ var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/xml"]
+ .createInstance(nsIDocumentEncoder);
+ encoder.setCharset(aCharset);
+ encoder.init(doc, "text/xml", aFlags);
+ return encoder.encodeToString();
+ });
+}
+
+function run_test()
+{
+ var result, expected;
+ const de = Components.interfaces.nsIDocumentEncoder;
+
+ xmlEncode("1_original.xml", de.OutputLFLineBreak).then(result => {
+ expected = loadContentFile("1_result.xml");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("2_original.xml", de.OutputLFLineBreak).then(result => {
+ expected = loadContentFile("2_result_1.xml");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("2_original.xml", de.OutputCRLineBreak).then(result => {
+ expected = expected.replace(/\n/g, "\r");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("2_original.xml", de.OutputLFLineBreak | de.OutputCRLineBreak).then(result => {
+ expected = expected.replace(/\r/mg, "\r\n");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("2_original.xml", de.OutputLFLineBreak | de.OutputFormatted).then(result => {
+ expected = loadContentFile("2_result_2.xml");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("2_original.xml", de.OutputLFLineBreak | de.OutputFormatted | de.OutputWrap).then(result => {
+ expected = loadContentFile("2_result_3.xml");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("2_original.xml", de.OutputLFLineBreak | de.OutputWrap).then(result => {
+ expected = loadContentFile("2_result_4.xml");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("3_original.xml", de.OutputLFLineBreak | de.OutputFormatted | de.OutputWrap).then(result => {
+ expected = loadContentFile("3_result.xml");
+ do_check_eq(expected, result);
+ });
+
+ xmlEncode("3_original.xml", de.OutputLFLineBreak | de.OutputWrap).then(result => {
+ expected = loadContentFile("3_result_2.xml");
+ do_check_eq(expected, result);
+ });
+
+ // tests on namespaces
+ do_parse_document("4_original.xml", "text/xml").then(run_namespace_tests);
+}
+
+function run_namespace_tests(doc) {
+ const de = Components.interfaces.nsIDocumentEncoder;
+ var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/xml"]
+ .createInstance(nsIDocumentEncoder);
+ encoder.setCharset("UTF-8");
+ encoder.init(doc, "text/xml", de.OutputLFLineBreak);
+
+ result = encoder.encodeToString();
+ expected = loadContentFile("4_result_1.xml");
+ do_check_eq(expected, result);
+
+ encoder.setNode(doc.documentElement.childNodes[9]);
+ result = encoder.encodeToString();
+ expected = loadContentFile("4_result_2.xml");
+ do_check_eq(expected, result);
+
+ encoder.setNode(doc.documentElement.childNodes[7].childNodes[1]);
+ result = encoder.encodeToString();
+ expected = loadContentFile("4_result_3.xml");
+ do_check_eq(expected, result);
+
+ encoder.setNode(doc.documentElement.childNodes[11].childNodes[1]);
+ result = encoder.encodeToString();
+ expected = loadContentFile("4_result_4.xml");
+ do_check_eq(expected, result);
+
+ encoder.setCharset("UTF-8");
+ // it doesn't support this flags
+ encoder.init(doc, "text/xml", de.OutputLFLineBreak | de.OutputFormatted | de.OutputWrap);
+ encoder.setWrapColumn(40);
+ result = encoder.encodeToString();
+ expected = loadContentFile("4_result_5.xml");
+ do_check_eq(expected, result);
+
+ encoder.init(doc, "text/xml", de.OutputLFLineBreak | de.OutputWrap);
+ encoder.setWrapColumn(40);
+ result = encoder.encodeToString();
+ expected = loadContentFile("4_result_6.xml");
+ do_check_eq(expected, result);
+}
diff --git a/dom/base/test/unit/xpcshell.ini b/dom/base/test/unit/xpcshell.ini
new file mode 100644
index 000000000..201b53d91
--- /dev/null
+++ b/dom/base/test/unit/xpcshell.ini
@@ -0,0 +1,55 @@
+[DEFAULT]
+head = head_utilities.js
+tail =
+support-files =
+ 1_original.xml
+ 1_result.xml
+ 2_original.xml
+ 2_result_1.xml
+ 2_result_2.xml
+ 2_result_3.xml
+ 2_result_4.xml
+ 3_original.xml
+ 3_result.xml
+ 3_result_2.xml
+ 4_original.xml
+ 4_result_1.xml
+ 4_result_2.xml
+ 4_result_3.xml
+ 4_result_4.xml
+ 4_result_5.xml
+ 4_result_6.xml
+ empty_document.xml
+ isequalnode_data.xml
+ nodelist_data_1.xml
+ nodelist_data_2.xul
+ test_delete_range.xml
+
+[test_bloburi.js]
+[test_bug553888.js]
+[test_bug737966.js]
+[test_error_codes.js]
+run-sequentially = Hardcoded 4444 port.
+# Bug 1018414: hardcoded localhost doesn't work properly on some OS X installs
+skip-if = os == 'mac'
+[test_isequalnode.js]
+head = head_xml.js
+[test_nodelist.js]
+head = head_xml.js
+[test_normalize.js]
+head = head_xml.js
+[test_range.js]
+head = head_xml.js
+[test_thirdpartyutil.js]
+[test_treewalker.js]
+head = head_xml.js
+[test_xhr_document.js]
+[test_xhr_standalone.js]
+[test_xhr_origin_attributes.js]
+[test_xml_parser.js]
+head = head_xml.js
+[test_xml_serializer.js]
+head = head_xml.js
+[test_xmlserializer.js]
+[test_cancelPrefetch.js]
+[test_chromeutils_base64.js]
diff --git a/dom/base/test/unit_ipc/test_bug553888_wrap.js b/dom/base/test/unit_ipc/test_bug553888_wrap.js
new file mode 100644
index 000000000..3f16a1e4a
--- /dev/null
+++ b/dom/base/test/unit_ipc/test_bug553888_wrap.js
@@ -0,0 +1,4 @@
+function run_test()
+{
+ run_test_in_child("../unit/test_bug553888.js");
+}
\ No newline at end of file
diff --git a/dom/base/test/unit_ipc/test_xhr_document_ipc.js b/dom/base/test/unit_ipc/test_xhr_document_ipc.js
new file mode 100644
index 000000000..1f65969b2
--- /dev/null
+++ b/dom/base/test/unit_ipc/test_xhr_document_ipc.js
@@ -0,0 +1,3 @@
+function run_test() {
+ run_test_in_child("../unit/test_xhr_document.js");
+}
diff --git a/dom/base/test/unit_ipc/xpcshell.ini b/dom/base/test/unit_ipc/xpcshell.ini
new file mode 100644
index 000000000..d05d300cf
--- /dev/null
+++ b/dom/base/test/unit_ipc/xpcshell.ini
@@ -0,0 +1,10 @@
+[DEFAULT]
+head =
+tail =
+skip-if = toolkit == 'android'
+support-files =
+ !/dom/base/test/unit/test_bug553888.js
+ !/dom/base/test/unit/test_xhr_document.js
+
+[test_bug553888_wrap.js]
+[test_xhr_document_ipc.js]
diff --git a/dom/base/test/variable_style_sheet.sjs b/dom/base/test/variable_style_sheet.sjs
new file mode 100644
index 000000000..def6465ef
--- /dev/null
+++ b/dom/base/test/variable_style_sheet.sjs
@@ -0,0 +1,19 @@
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "text/css", false);
+
+ var accessCount;
+ var state = getState("varSSAccessCount");
+ if (!state) {
+ setState("varSSAccessCount", "0");
+ accessCount = 0;
+ } else {
+ setState("varSSAccessCount", (parseInt(state) + 1).toString());
+ accessCount = parseInt(state) + 1;
+ }
+
+ response.write("#content { background-color: rgb(" +
+ (accessCount % 256) +
+ ", 0, 0); }");
+}
diff --git a/dom/base/test/viewport_helpers.js b/dom/base/test/viewport_helpers.js
new file mode 100644
index 000000000..8ad9d2b39
--- /dev/null
+++ b/dom/base/test/viewport_helpers.js
@@ -0,0 +1,3 @@
+function scaleRatio(scale) {
+ return {"set": [["layout.css.devPixelsPerPx", "" + scale]]};
+}
diff --git a/dom/base/test/w3element_traversal.svg b/dom/base/test/w3element_traversal.svg
new file mode 100644
index 000000000..22540b464
--- /dev/null
+++ b/dom/base/test/w3element_traversal.svg
@@ -0,0 +1,70 @@
+">
+]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ &tree;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/websocket_helpers.js b/dom/base/test/websocket_helpers.js
new file mode 100644
index 000000000..46cf765d7
--- /dev/null
+++ b/dom/base/test/websocket_helpers.js
@@ -0,0 +1,66 @@
+var current_test = 0;
+
+function shouldNotOpen(e) {
+ var ws = e.target;
+ ok(false, "onopen shouldn't be called on test " + ws._testNumber + "!");
+}
+
+function shouldCloseCleanly(e) {
+ var ws = e.target;
+ ok(e.wasClean, "the ws connection in test " + ws._testNumber + " should be closed cleanly");
+}
+
+function shouldCloseNotCleanly(e) {
+ var ws = e.target;
+ ok(!e.wasClean, "the ws connection in test " + ws._testNumber + " shouldn't be closed cleanly");
+}
+
+function ignoreError(e) {
+}
+
+function CreateTestWS(ws_location, ws_protocol) {
+ var ws;
+
+ try {
+ if (ws_protocol == undefined) {
+ ws = new WebSocket(ws_location);
+ } else {
+ ws = new WebSocket(ws_location, ws_protocol);
+ }
+
+ ws._testNumber = current_test;
+ ok(true, "Created websocket for test " + ws._testNumber +"\n");
+
+ ws.onerror = function(e) {
+ ok(false, "onerror called on test " + e.target._testNumber + "!");
+ }
+
+ } catch (e) {
+ throw e;
+ }
+
+ return ws;
+}
+
+function forcegc() {
+ SpecialPowers.forceGC();
+ SpecialPowers.gc();
+}
+
+function feedback() {
+ $("feedback").innerHTML = "executing test: " + (current_test+1) + " of " + tests.length + " tests.";
+}
+
+function finish() {
+ SimpleTest.finish();
+}
+
+function doTest() {
+ if (current_test >= tests.length) {
+ finish();
+ return;
+ }
+
+ feedback();
+ tests[current_test++]().then(doTest);
+}
diff --git a/dom/base/test/websocket_hybi/file_binary-frames_wsh.py b/dom/base/test/websocket_hybi/file_binary-frames_wsh.py
new file mode 100644
index 000000000..656d0e189
--- /dev/null
+++ b/dom/base/test/websocket_hybi/file_binary-frames_wsh.py
@@ -0,0 +1,18 @@
+from mod_pywebsocket import common
+from mod_pywebsocket import stream
+
+
+def web_socket_do_extra_handshake(request):
+ pass
+
+
+def web_socket_transfer_data(request):
+ messages_to_send = ['Hello, world!', '', all_distinct_bytes()]
+ for message in messages_to_send:
+ # FIXME: Should use better API to send binary messages when pywebsocket supports it.
+ header = stream.create_header(common.OPCODE_BINARY, len(message), 1, 0, 0, 0, 0)
+ request.connection.write(header + message)
+
+
+def all_distinct_bytes():
+ return ''.join([chr(i) for i in xrange(256)])
diff --git a/dom/base/test/websocket_hybi/file_check-binary-messages_wsh.py b/dom/base/test/websocket_hybi/file_check-binary-messages_wsh.py
new file mode 100644
index 000000000..024e3f4d0
--- /dev/null
+++ b/dom/base/test/websocket_hybi/file_check-binary-messages_wsh.py
@@ -0,0 +1,21 @@
+from mod_pywebsocket import common
+from mod_pywebsocket import msgutil
+
+
+def web_socket_do_extra_handshake(request):
+ pass # Always accept.
+
+
+def web_socket_transfer_data(request):
+ expected_messages = ['Hello, world!', '', all_distinct_bytes()]
+
+ for test_number, expected_message in enumerate(expected_messages):
+ message = msgutil.receive_message(request)
+ if type(message) == str and message == expected_message:
+ msgutil.send_message(request, 'PASS: Message #%d.' % test_number)
+ else:
+ msgutil.send_message(request, 'FAIL: Message #%d: Received unexpected message: %r' % (test_number, message))
+
+
+def all_distinct_bytes():
+ return ''.join([chr(i) for i in xrange(256)])
diff --git a/dom/base/test/websocket_hybi/mochitest.ini b/dom/base/test/websocket_hybi/mochitest.ini
new file mode 100644
index 000000000..21d61c8c8
--- /dev/null
+++ b/dom/base/test/websocket_hybi/mochitest.ini
@@ -0,0 +1,13 @@
+[DEFAULT]
+support-files =
+ file_binary-frames_wsh.py
+ file_check-binary-messages_wsh.py
+
+[test_receive-arraybuffer.html]
+skip-if = toolkit == 'android'
+[test_receive-blob.html]
+skip-if = toolkit == 'android'
+[test_send-arraybuffer.html]
+skip-if = toolkit == 'android'
+[test_send-blob.html]
+skip-if = toolkit == 'android'
diff --git a/dom/base/test/websocket_hybi/test_receive-arraybuffer.html b/dom/base/test/websocket_hybi/test_receive-arraybuffer.html
new file mode 100644
index 000000000..0bd1cfefc
--- /dev/null
+++ b/dom/base/test/websocket_hybi/test_receive-arraybuffer.html
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/websocket_hybi/test_receive-blob.html b/dom/base/test/websocket_hybi/test_receive-blob.html
new file mode 100644
index 000000000..cd8beceec
--- /dev/null
+++ b/dom/base/test/websocket_hybi/test_receive-blob.html
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/websocket_hybi/test_send-arraybuffer.html b/dom/base/test/websocket_hybi/test_send-arraybuffer.html
new file mode 100644
index 000000000..4db0746fb
--- /dev/null
+++ b/dom/base/test/websocket_hybi/test_send-arraybuffer.html
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/websocket_hybi/test_send-blob.html b/dom/base/test/websocket_hybi/test_send-blob.html
new file mode 100644
index 000000000..291883cd7
--- /dev/null
+++ b/dom/base/test/websocket_hybi/test_send-blob.html
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dom/base/test/websocket_tests.js b/dom/base/test/websocket_tests.js
new file mode 100644
index 000000000..e62896507
--- /dev/null
+++ b/dom/base/test/websocket_tests.js
@@ -0,0 +1,1244 @@
+// test1: client tries to connect to a http scheme location;
+function test1() {
+ return new Promise(function(resolve, reject) {
+ try {
+ var ws = CreateTestWS("http://mochi.test:8888/tests/dom/base/test/file_websocket");
+ ok(false, "test1 failed");
+ } catch (e) {
+ ok(true, "test1 failed");
+ }
+
+ resolve();
+ });
+}
+
+// test2: assure serialization of the connections;
+// this test expects that the serialization list to connect to the proxy
+// is empty.
+function test2() {
+ return new Promise(function(resolve, reject) {
+ var waitTest2Part1 = true;
+ var waitTest2Part2 = true;
+
+ var ws1 = CreateTestWS("ws://sub2.test2.example.com/tests/dom/base/test/file_websocket", "test-2.1");
+ var ws2 = CreateTestWS("ws://sub2.test2.example.com/tests/dom/base/test/file_websocket", "test-2.2");
+
+ var ws2CanConnect = false;
+
+ function maybeFinished() {
+ if (!waitTest2Part1 && !waitTest2Part2) {
+ resolve();
+ }
+ }
+
+ ws1.onopen = function() {
+ ok(true, "ws1 open in test 2");
+ ws2CanConnect = true;
+ ws1.close();
+ }
+
+ ws1.onclose = function(e) {
+ waitTest2Part1 = false;
+ maybeFinished();
+ }
+
+ ws2.onopen = function() {
+ ok(ws2CanConnect, "shouldn't connect yet in test-2!");
+ ws2.close();
+ }
+
+ ws2.onclose = function(e) {
+ waitTest2Part2 = false;
+ maybeFinished();
+ }
+ });
+}
+
+// test3: client tries to connect to an non-existent ws server;
+function test3() {
+ return new Promise(function(resolve, reject) {
+ var hasError = false;
+ var ws = CreateTestWS("ws://this.websocket.server.probably.does.not.exist");
+
+ ws.onopen = shouldNotOpen;
+
+ ws.onerror = function (e) {
+ hasError = true;
+ }
+
+ ws.onclose = function(e) {
+ shouldCloseNotCleanly(e);
+ ok(hasError, "rcvd onerror event");
+ is(e.code, 1006, "test-3 close code should be 1006 but is:" + e.code);
+ resolve();
+ }
+ });
+}
+
+// test4: client tries to connect using a relative url;
+function test4() {
+ return new Promise(function(resolve, reject) {
+ try {
+ var ws = CreateTestWS("file_websocket");
+ ok(false, "test-4 failed");
+ } catch (e) {
+ ok(true, "test-4 failed");
+ }
+
+ resolve();
+ });
+}
+
+// test5: client uses an invalid protocol value;
+function test5() {
+ return new Promise(function(resolve, reject) {
+ try {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "");
+ ok(false, "couldn't accept an empty string in the protocol parameter");
+ } catch (e) {
+ ok(true, "couldn't accept an empty string in the protocol parameter");
+ }
+
+ try {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "\n");
+ ok(false, "couldn't accept any not printable ASCII character in the protocol parameter");
+ } catch (e) {
+ ok(true, "couldn't accept any not printable ASCII character in the protocol parameter");
+ }
+
+ try {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test 5");
+ ok(false, "U+0020 not acceptable in protocol parameter");
+ } catch (e) {
+ ok(true, "U+0020 not acceptable in protocol parameter");
+ }
+
+ resolve();
+ });
+}
+
+// test6: counter and encoding check;
+function test6() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-6");
+ var counter = 1;
+
+ ws.onopen = function() {
+ ws.send(counter);
+ }
+
+ ws.onmessage = function(e) {
+ if (counter == 5) {
+ is(e.data, "あいうえお", "test-6 counter 5 data ok");
+ ws.close();
+ } else {
+ is(parseInt(e.data), counter+1, "bad counter");
+ counter += 2;
+ ws.send(counter);
+ }
+ }
+
+ ws.onclose = function(e) {
+ shouldCloseCleanly(e);
+ resolve();
+ }
+ });
+}
+
+// test7: onmessage event origin property check
+function test7() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://sub2.test2.example.org/tests/dom/base/test/file_websocket", "test-7");
+ var gotmsg = false;
+
+ ws.onopen = function() {
+ ok(true, "test 7 open");
+ }
+
+ ws.onmessage = function(e) {
+ ok(true, "test 7 message");
+ is(e.origin, "ws://sub2.test2.example.org", "onmessage origin set to ws:// host");
+ gotmsg = true;
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ ok(gotmsg, "recvd message in test 7 before close");
+ shouldCloseCleanly(e);
+ resolve();
+ }
+ });
+}
+
+// test8: client calls close() and the server sends the close frame (with no
+// code or reason) in acknowledgement;
+function test8() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-8");
+
+ ws.onopen = function() {
+ is(ws.protocol, "test-8", "test-8 subprotocol selection");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ shouldCloseCleanly(e);
+ // We called close() with no close code: so pywebsocket will also send no
+ // close code, which translates to code 1005
+ is(e.code, 1005, "test-8 close code has wrong value:" + e.code);
+ is(e.reason, "", "test-8 close reason has wrong value:" + e.reason);
+ resolve();
+ }
+ });
+}
+
+// test9: client closes the connection before the ws connection is established;
+function test9() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://test2.example.org/tests/dom/base/test/file_websocket", "test-9");
+
+ ws._receivedErrorEvent = false;
+
+ ws.onopen = shouldNotOpen;
+
+ ws.onerror = function(e) {
+ ws._receivedErrorEvent = true;
+ }
+
+ ws.onclose = function(e) {
+ ok(ws._receivedErrorEvent, "Didn't received the error event in test 9.");
+ shouldCloseNotCleanly(e);
+ resolve();
+ }
+
+ ws.close();
+ });
+}
+
+// test10: client sends a message before the ws connection is established;
+function test10() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://sub1.test1.example.com/tests/dom/base/test/file_websocket", "test-10");
+
+ ws.onclose = function(e) {
+ shouldCloseCleanly(e);
+ resolve();
+ }
+
+ try {
+ ws.send("client data");
+ ok(false, "Couldn't send data before connecting!");
+ } catch (e) {
+ ok(true, "Couldn't send data before connecting!");
+ }
+
+ ws.onopen = function()
+ {
+ ok(true, "test 10 opened");
+ ws.close();
+ }
+ });
+}
+
+// test11: a simple hello echo;
+function test11() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-11");
+ is(ws.readyState, 0, "create bad readyState in test-11!");
+
+ ws.onopen = function() {
+ is(ws.readyState, 1, "open bad readyState in test-11!");
+ ws.send("client data");
+ }
+
+ ws.onmessage = function(e) {
+ is(e.data, "server data", "bad received message in test-11!");
+ ws.close(1000, "Have a nice day");
+
+ // this ok() is disabled due to a race condition - it state may have
+ // advanced through 2 (closing) and into 3 (closed) before it is evald
+ // ok(ws.readyState == 2, "onmessage bad readyState in test-11!");
+ }
+
+ ws.onclose = function(e) {
+ is(ws.readyState, 3, "onclose bad readyState in test-11!");
+ shouldCloseCleanly(e);
+ is(e.code, 1000, "test 11 got wrong close code: " + e.code);
+ is(e.reason, "Have a nice day", "test 11 got wrong close reason: " + e.reason);
+ resolve();
+ }
+ });
+}
+
+// test12: client sends a message containing unpaired surrogates
+function test12() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-12");
+
+ ws.onopen = function() {
+ try {
+ // send an unpaired surrogate
+ ws._gotMessage = false;
+ ws.send("a\ud800b");
+ ok(true, "ok to send an unpaired surrogate");
+ } catch (e) {
+ ok(false, "shouldn't fail any more when sending an unpaired surrogate!");
+ }
+ }
+
+ ws.onmessage = function(msg) {
+ is(msg.data, "SUCCESS", "Unpaired surrogate in UTF-16 not converted in test-12");
+ ws._gotMessage = true;
+ // Must support unpaired surrogates in close reason, too
+ ws.close(1000, "a\ud800b");
+ }
+
+ ws.onclose = function(e) {
+ is(ws.readyState, 3, "onclose bad readyState in test-12!");
+ ok(ws._gotMessage, "didn't receive message!");
+ shouldCloseCleanly(e);
+ is(e.code, 1000, "test 12 got wrong close code: " + e.code);
+ is(e.reason, "a\ufffdb", "test 11 didn't get replacement char in close reason: " + e.reason);
+ resolve();
+ }
+ });
+}
+
+// test13: server sends an invalid message;
+function test13() {
+ return new Promise(function(resolve, reject) {
+ // previous versions of this test counted the number of protocol errors
+ // returned, but the protocol stack typically closes down after reporting a
+ // protocol level error - trying to resync is too dangerous
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-13");
+ ws._timesCalledOnError = 0;
+
+ ws.onerror = function() {
+ ws._timesCalledOnError++;
+ }
+
+ ws.onclose = function(e) {
+ ok(ws._timesCalledOnError > 0, "no error events");
+ resolve();
+ }
+ });
+}
+
+// test14: server sends the close frame, it doesn't close the tcp connection
+// and it keeps sending normal ws messages;
+function test14() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-14");
+
+ ws.onmessage = function() {
+ ok(false, "shouldn't received message after the server sent the close frame");
+ }
+
+ ws.onclose = function(e) {
+ shouldCloseCleanly(e);
+ resolve();
+ };
+ });
+}
+
+// test15: server closes the tcp connection, but it doesn't send the close
+// frame;
+function test15() {
+ return new Promise(function(resolve, reject) {
+ /*
+ * DISABLED: see comments for test-15 case in file_websocket_wsh.py
+ */
+ resolve();
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-15");
+ ws.onclose = function(e) {
+ shouldCloseNotCleanly(e);
+ resolve();
+ }
+
+ // termination of the connection might cause an error event if it happens in OPEN
+ ws.onerror = function() {
+ }
+ });
+}
+
+// test16: client calls close() and tries to send a message;
+function test16() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-16");
+
+ ws.onopen = function() {
+ ws.close();
+ ok(!ws.send("client data"), "shouldn't send message after calling close()");
+ }
+
+ ws.onmessage = function() {
+ ok(false, "shouldn't send message after calling close()");
+ }
+
+ ws.onerror = function() {
+ }
+
+ ws.onclose = function() {
+ resolve();
+ }
+ });
+}
+
+// test17: see bug 572975 - all event listeners set
+function test17() {
+ return new Promise(function(resolve, reject) {
+ var status_test17 = "not started";
+
+ var test17func = function() {
+ var local_ws = new WebSocket("ws://sub1.test2.example.org/tests/dom/base/test/file_websocket", "test-17");
+ status_test17 = "started";
+
+ local_ws.onopen = function(e) {
+ status_test17 = "opened";
+ e.target.send("client data");
+ forcegc();
+ };
+
+ local_ws.onerror = function() {
+ ok(false, "onerror called on test " + current_test + "!");
+ };
+
+ local_ws.onmessage = function(e) {
+ ok(e.data == "server data", "Bad message in test-17");
+ status_test17 = "got message";
+ forcegc();
+ };
+
+ local_ws.onclose = function(e) {
+ ok(status_test17 == "got message", "Didn't got message in test-17!");
+ shouldCloseCleanly(e);
+ status_test17 = "closed";
+ forcegc();
+ resolve();
+ };
+
+ window._test17 = null;
+ forcegc();
+ }
+
+ window._test17 = test17func;
+ window._test17();
+ });
+}
+
+// The tests that expects that their websockets neither open nor close MUST
+// be in the end of the tests, i.e. HERE, in order to prevent blocking the other
+// tests.
+
+// test18: client tries to connect to an http resource;
+function test18() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket_http_resource.txt");
+ ws.onopen = shouldNotOpen;
+ ws.onerror = ignoreError;
+ ws.onclose = function(e)
+ {
+ shouldCloseNotCleanly(e);
+ resolve();
+ }
+ });
+}
+
+// test19: server closes the tcp connection before establishing the ws
+// connection;
+function test19() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-19");
+ ws.onopen = shouldNotOpen;
+ ws.onerror = ignoreError;
+ ws.onclose = function(e)
+ {
+ shouldCloseNotCleanly(e);
+ resolve();
+ }
+ });
+}
+
+// test20: see bug 572975 - only on error and onclose event listeners set
+function test20() {
+ return new Promise(function(resolve, reject) {
+ var test20func = function() {
+ var local_ws = new WebSocket("ws://sub1.test1.example.org/tests/dom/base/test/file_websocket", "test-20");
+
+ local_ws.onerror = function() {
+ ok(false, "onerror called on test " + current_test + "!");
+ }
+
+ local_ws.onclose = function(e) {
+ ok(true, "test 20 closed despite gc");
+ resolve();
+ }
+
+ local_ws = null;
+ window._test20 = null;
+ forcegc();
+ }
+
+ window._test20 = test20func;
+ window._test20();
+ });
+}
+
+// test21: see bug 572975 - same as test 17, but delete strong event listeners
+// when receiving the message event;
+function test21() {
+ return new Promise(function(resolve, reject) {
+ var test21func = function() {
+ var local_ws = new WebSocket("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-21");
+ var received_message = false;
+
+ local_ws.onopen = function(e) {
+ e.target.send("client data");
+ forcegc();
+ e.target.onopen = null;
+ forcegc();
+ }
+
+ local_ws.onerror = function() {
+ ok(false, "onerror called on test " + current_test + "!");
+ }
+
+ local_ws.onmessage = function(e) {
+ is(e.data, "server data", "Bad message in test-21");
+ received_message = true;
+ forcegc();
+ e.target.onmessage = null;
+ forcegc();
+ }
+
+ local_ws.onclose = function(e) {
+ shouldCloseCleanly(e);
+ ok(received_message, "close transitioned through onmessage");
+ resolve();
+ }
+
+ local_ws = null;
+ window._test21 = null;
+ forcegc();
+ }
+
+ window._test21 = test21func;
+ window._test21();
+ });
+}
+
+// test22: server takes too long to establish the ws connection;
+function test22() {
+ return new Promise(function(resolve, reject) {
+ const pref_open = "network.websocket.timeout.open";
+ SpecialPowers.setIntPref(pref_open, 5);
+
+ var ws = CreateTestWS("ws://sub2.test2.example.org/tests/dom/base/test/file_websocket", "test-22");
+
+ ws.onopen = shouldNotOpen;
+ ws.onerror = ignoreError;
+
+ ws.onclose = function(e) {
+ shouldCloseNotCleanly(e);
+ resolve();
+ }
+
+ SpecialPowers.clearUserPref(pref_open);
+ });
+}
+
+// test23: should detect WebSocket on window object;
+function test23() {
+ return new Promise(function(resolve, reject) {
+ ok("WebSocket" in window, "WebSocket should be available on window object");
+ resolve();
+ });
+}
+
+// test24: server rejects sub-protocol string
+function test24() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-does-not-exist");
+
+ ws.onopen = shouldNotOpen;
+ ws.onclose = function(e) {
+ shouldCloseNotCleanly(e);
+ resolve();
+ }
+
+ ws.onerror = function() {
+ }
+ });
+}
+
+// test25: ctor with valid empty sub-protocol array
+function test25() {
+ return new Promise(function(resolve, reject) {
+ var prots=[];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ // This test errors because the server requires a sub-protocol, but
+ // the test just wants to ensure that the ctor doesn't generate an
+ // exception
+ ws.onerror = ignoreError;
+ ws.onopen = shouldNotOpen;
+
+ ws.onclose = function(e) {
+ is(ws.protocol, "", "test25 subprotocol selection");
+ ok(true, "test 25 protocol array close");
+ resolve();
+ }
+ });
+}
+
+// test26: ctor with invalid sub-protocol array containing 1 empty element
+function test26() {
+ return new Promise(function(resolve, reject) {
+ var prots=[""];
+
+ try {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+ ok(false, "testing empty element sub protocol array");
+ } catch (e) {
+ ok(true, "testing empty sub element protocol array");
+ }
+
+ resolve();
+ });
+}
+
+// test27: ctor with invalid sub-protocol array containing an empty element in
+// list
+function test27() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test27", ""];
+
+ try {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+ ok(false, "testing empty element mixed sub protocol array");
+ } catch (e) {
+ ok(true, "testing empty element mixed sub protocol array");
+ }
+
+ resolve();
+ });
+}
+
+// test28: ctor using valid 1 element sub-protocol array
+function test28() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test28"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 28 protocol array open");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ is(ws.protocol, "test28", "test28 subprotocol selection");
+ ok(true, "test 28 protocol array close");
+ resolve();
+ }
+ });
+}
+
+// test29: ctor using all valid 5 element sub-protocol array
+function test29() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test29a", "test29b"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 29 protocol array open");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 29 protocol array close");
+ resolve();
+ }
+ });
+}
+
+// test30: ctor using valid 1 element sub-protocol array with element server
+// will reject
+function test30() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-does-not-exist"];
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = shouldNotOpen;
+
+ ws.onclose = function(e) {
+ shouldCloseNotCleanly(e);
+ resolve();
+ }
+
+ ws.onerror = function() {
+ }
+ });
+}
+
+// test31: ctor using valid 2 element sub-protocol array with 1 element server
+// will reject and one server will accept
+function test31() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-does-not-exist", "test31"];
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 31 protocol array open");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ is(ws.protocol, "test31", "test31 subprotocol selection");
+ ok(true, "test 31 protocol array close");
+ resolve();
+ }
+ });
+}
+
+// test32: ctor using invalid sub-protocol array that contains duplicate items
+function test32() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test32","test32"];
+
+ try {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+ ok(false, "testing duplicated element sub protocol array");
+ } catch (e) {
+ ok(true, "testing duplicated sub element protocol array");
+ }
+
+ resolve();
+ });
+}
+
+// test33: test for sending/receiving custom close code (but no close reason)
+function test33() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test33"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 33 open");
+ ws.close(3131); // pass code but not reason
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 33 close");
+ shouldCloseCleanly(e);
+ is(e.code, 3131, "test 33 got wrong close code: " + e.code);
+ is(e.reason, "", "test 33 got wrong close reason: " + e.reason);
+ resolve();
+ }
+ });
+}
+
+// test34: test for receiving custom close code and reason
+function test34() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-34"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 34 open");
+ ws.close();
+ }
+
+ ws.onclose = function(e)
+ {
+ ok(true, "test 34 close");
+ ok(e.wasClean, "test 34 closed cleanly");
+ is(e.code, 1001, "test 34 custom server code");
+ is(e.reason, "going away now", "test 34 custom server reason");
+ resolve();
+ }
+ });
+}
+
+// test35: test for sending custom close code and reason
+function test35() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-35a");
+
+ ws.onopen = function(e) {
+ ok(true, "test 35a open");
+ ws.close(3500, "my code");
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 35a close");
+ ok(e.wasClean, "test 35a closed cleanly");
+ var wsb = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-35b");
+
+ wsb.onopen = function(e) {
+ ok(true, "test 35b open");
+ wsb.close();
+ }
+
+ wsb.onclose = function(e) {
+ ok(true, "test 35b close");
+ ok(e.wasClean, "test 35b closed cleanly");
+ is(e.code, 3501, "test 35 custom server code");
+ is(e.reason, "my code", "test 35 custom server reason");
+ resolve();
+ }
+ }
+ });
+}
+
+// test36: negative test for sending out of range close code
+function test36() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-36"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 36 open");
+
+ try {
+ ws.close(13200);
+ ok(false, "testing custom close code out of range");
+ } catch (e) {
+ ok(true, "testing custom close code out of range");
+ ws.close(3200);
+ }
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 36 close");
+ ok(e.wasClean, "test 36 closed cleanly");
+ resolve();
+ }
+ });
+}
+
+// test37: negative test for too long of a close reason
+function test37() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-37"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 37 open");
+
+ try {
+ ws.close(3100,"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123");
+ ok(false, "testing custom close reason out of range");
+ } catch (e) {
+ ok(true, "testing custom close reason out of range");
+ ws.close(3100,"012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012");
+ }
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 37 close");
+ ok(e.wasClean, "test 37 closed cleanly");
+
+ var wsb = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-37b");
+
+ wsb.onopen = function(e) {
+ // now test that a rejected close code and reason dont persist
+ ok(true, "test 37b open");
+ try {
+ wsb.close(3101,"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123");
+ ok(false, "testing custom close reason out of range 37b");
+ } catch (e) {
+ ok(true, "testing custom close reason out of range 37b");
+ wsb.close();
+ }
+ }
+
+ wsb.onclose = function(e) {
+ ok(true, "test 37b close");
+ ok(e.wasClean, "test 37b closed cleanly");
+
+ var wsc = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-37c");
+
+ wsc.onopen = function(e) {
+ ok(true, "test 37c open");
+ wsc.close();
+ }
+
+ wsc.onclose = function(e) {
+ isnot(e.code, 3101, "test 37c custom server code not present");
+ is(e.reason, "", "test 37c custom server reason not present");
+ resolve();
+ }
+ }
+ }
+ });
+}
+
+// test38: ensure extensions attribute is defined
+function test38() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-38"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 38 open");
+ isnot(ws.extensions, undefined, "extensions attribute defined");
+ // is(ws.extensions, "deflate-stream", "extensions attribute deflate-stream");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 38 close");
+ resolve();
+ }
+ });
+}
+
+// test39: a basic wss:// connectivity test
+function test39() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-39"];
+
+ var ws = CreateTestWS("wss://example.com/tests/dom/base/test/file_websocket", prots);
+ status_test39 = "started";
+
+ ws.onopen = function(e) {
+ status_test39 = "opened";
+ ok(true, "test 39 open");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 39 close");
+ is(status_test39, "opened", "test 39 did open");
+ resolve();
+ }
+ });
+}
+
+// test40: negative test for wss:// with no cert
+function test40() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-40"];
+
+ var ws = CreateTestWS("wss://nocert.example.com/tests/dom/base/test/file_websocket", prots);
+
+ status_test40 = "started";
+ ws.onerror = ignoreError;
+
+ ws.onopen = function(e) {
+ status_test40 = "opened";
+ ok(false, "test 40 open");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 40 close");
+ is(status_test40, "started", "test 40 did not open");
+ resolve();
+ }
+ });
+}
+
+// test41: HSTS
+function test41() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://example.com/tests/dom/base/test/file_websocket", "test-41a", 1);
+
+ ws.onopen = function(e) {
+ ok(true, "test 41a open");
+ is(ws.url, "ws://example.com/tests/dom/base/test/file_websocket",
+ "test 41a initial ws should not be redirected");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 41a close");
+
+ // establish a hsts policy for example.com
+ var wsb = CreateTestWS("wss://example.com/tests/dom/base/test/file_websocket", "test-41b", 1);
+
+ wsb.onopen = function(e) {
+ ok(true, "test 41b open");
+ wsb.close();
+ }
+
+ wsb.onclose = function(e) {
+ ok(true, "test 41b close");
+
+ // try ws:// again, it should be done over wss:// now due to hsts
+ var wsc = CreateTestWS("ws://example.com/tests/dom/base/test/file_websocket", "test-41c");
+
+ wsc.onopen = function(e) {
+ ok(true, "test 41c open");
+ is(wsc.url, "wss://example.com/tests/dom/base/test/file_websocket",
+ "test 41c ws should be redirected by hsts to wss");
+ wsc.close();
+ }
+
+ wsc.onclose = function(e) {
+ ok(true, "test 41c close");
+
+ // clean up the STS state
+ const Ci = SpecialPowers.Ci;
+ var loadContext = SpecialPowers.wrap(window)
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+ var flags = 0;
+ if (loadContext.usePrivateBrowsing)
+ flags |= Ci.nsISocketProvider.NO_PERMANENT_STORAGE;
+ SpecialPowers.cleanUpSTSData("http://example.com", flags);
+ resolve();
+ }
+ }
+ }
+ });
+}
+
+// test42: non-char utf-8 sequences
+function test42() {
+ return new Promise(function(resolve, reject) {
+ // test some utf-8 non-characters. They should be allowed in the
+ // websockets context. Test via round trip echo.
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-42");
+ var data = ["U+FFFE \ufffe",
+ "U+FFFF \uffff",
+ "U+10FFFF \udbff\udfff"];
+ var index = 0;
+
+ ws.onopen = function() {
+ ws.send(data[0]);
+ ws.send(data[1]);
+ ws.send(data[2]);
+ }
+
+ ws.onmessage = function(e) {
+ is(e.data, data[index], "bad received message in test-42! index="+index);
+ index++;
+ if (index == 3) {
+ ws.close();
+ }
+ }
+
+ ws.onclose = function(e) {
+ resolve();
+ }
+ });
+}
+
+// test43: Test setting binaryType attribute
+function test43() {
+ return new Promise(function(resolve, reject) {
+ var prots=["test-43"];
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", prots);
+
+ ws.onopen = function(e) {
+ ok(true, "test 43 open");
+ // Test binaryType setting
+ ws.binaryType = "arraybuffer";
+ ws.binaryType = "blob";
+ ws.binaryType = ""; // illegal
+ is(ws.binaryType, "blob");
+ ws.binaryType = "ArrayBuffer"; // illegal
+ is(ws.binaryType, "blob");
+ ws.binaryType = "Blob"; // illegal
+ is(ws.binaryType, "blob");
+ ws.binaryType = "mcfoofluu"; // illegal
+ is(ws.binaryType, "blob");
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "test 43 close");
+ resolve();
+ }
+ });
+}
+
+// test44: Test sending/receving binary ArrayBuffer
+function test44() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-44");
+ is(ws.readyState, 0, "bad readyState in test-44!");
+ ws.binaryType = "arraybuffer";
+
+ ws.onopen = function() {
+ is(ws.readyState, 1, "open bad readyState in test-44!");
+ var buf = new ArrayBuffer(3);
+ // create byte view
+ var view = new Uint8Array(buf);
+ view[0] = 5;
+ view[1] = 0; // null byte
+ view[2] = 7;
+ ws.send(buf);
+ }
+
+ ws.onmessage = function(e) {
+ ok(e.data instanceof ArrayBuffer, "Should receive an arraybuffer!");
+ var view = new Uint8Array(e.data);
+ ok(view.length == 2 && view[0] == 0 && view[1] ==4, "testing Reply arraybuffer" );
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ is(ws.readyState, 3, "onclose bad readyState in test-44!");
+ shouldCloseCleanly(e);
+ resolve();
+ }
+ });
+}
+
+// test45: Test sending/receving binary Blob
+function test45() {
+ return new Promise(function(resolve, reject) {
+ function test45Real(blobFile) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-45");
+ is(ws.readyState, 0, "bad readyState in test-45!");
+ // ws.binaryType = "blob"; // Don't need to specify: blob is the default
+
+ ws.onopen = function() {
+ is(ws.readyState, 1, "open bad readyState in test-45!");
+ ws.send(blobFile);
+ }
+
+ var test45blob;
+
+ ws.onmessage = function(e) {
+ test45blob = e.data;
+ ok(test45blob instanceof Blob, "We should be receiving a Blob");
+
+ ws.close();
+ }
+
+ ws.onclose = function(e) {
+ is(ws.readyState, 3, "onclose bad readyState in test-45!");
+ shouldCloseCleanly(e);
+
+ // check blob contents
+ var reader = new FileReader();
+ reader.onload = function(event) {
+ is(reader.result, "flob", "response should be 'flob': got '"
+ + reader.result + "'");
+ }
+
+ reader.onerror = function(event) {
+ testFailed("Failed to read blob: error code = " + reader.error.code);
+ }
+
+ reader.onloadend = function(event) {
+ resolve();
+ }
+
+ reader.readAsBinaryString(test45blob);
+ }
+ }
+
+ SpecialPowers.createFiles([{name: "testBlobFile", data: "flob"}],
+ function(files) {
+ test45Real(files[0]);
+ },
+ function(msg) {
+ testFailed("Failed to create file for test45: " + msg);
+ resolve();
+ });
+ });
+}
+
+// test46: Test that we don't dispatch incoming msgs once in CLOSING state
+function test46() {
+ return new Promise(function(resolve, reject) {
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-46");
+ is(ws.readyState, 0, "create bad readyState in test-46!");
+
+ ws.onopen = function() {
+ is(ws.readyState, 1, "open bad readyState in test-46!");
+ ws.close()
+ is(ws.readyState, 2, "close must set readyState to 2 in test-46!");
+ }
+
+ ws.onmessage = function(e) {
+ ok(false, "received message after calling close in test-46!");
+ }
+
+ ws.onclose = function(e) {
+ is(ws.readyState, 3, "onclose bad readyState in test-46!");
+ shouldCloseCleanly(e);
+ resolve();
+ }
+ });
+}
+
+// test47: Make sure onerror/onclose aren't called during close()
+function test47() {
+ return new Promise(function(resolve, reject) {
+ var hasError = false;
+ var ws = CreateTestWS("ws://another.websocket.server.that.probably.does.not.exist");
+
+ ws.onopen = shouldNotOpen;
+
+ ws.onerror = function (e) {
+ is(ws.readyState, 3, "test-47: readyState should be CLOSED(3) in onerror: got "
+ + ws.readyState);
+ ok(!ws._withinClose, "onerror() called during close()!");
+ hasError = true;
+ }
+
+ ws.onclose = function(e) {
+ shouldCloseNotCleanly(e);
+ ok(hasError, "test-47: should have called onerror before onclose");
+ is(ws.readyState, 3, "test-47: readyState should be CLOSED(3) in onclose: got "
+ + ws.readyState);
+ ok(!ws._withinClose, "onclose() called during close()!");
+ is(e.code, 1006, "test-47 close code should be 1006 but is:" + e.code);
+ resolve();
+ }
+
+ // Call close before we're connected: throws error
+ // Make sure we call onerror/onclose asynchronously
+ ws._withinClose = 1;
+ ws.close(3333, "Closed before we were open: error");
+ ws._withinClose = 0;
+ is(ws.readyState, 2, "test-47: readyState should be CLOSING(2) after close(): got "
+ + ws.readyState);
+ });
+}
+
+// test48: see bug 1227136 - client calls close() from onopen() and waits until
+// WebSocketChannel::mSocketIn is nulled out on socket thread.
+function test48() {
+ return new Promise(function(resolve, reject) {
+ const pref_close = "network.websocket.timeout.close";
+ SpecialPowers.setIntPref(pref_close, 1);
+
+ var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-48");
+
+ ws.onopen = function() {
+ ws.close();
+
+ var date = new Date();
+ var curDate = null;
+ do {
+ curDate = new Date();
+ } while(curDate-date < 1500);
+
+ }
+
+ ws.onclose = function(e) {
+ ok(true, "ws close in test 48");
+ resolve();
+ }
+
+ SpecialPowers.clearUserPref(pref_close);
+ });
+}
diff --git a/dom/base/test/wholeTexty-helper.xml b/dom/base/test/wholeTexty-helper.xml
new file mode 100644
index 000000000..779a54c8b
--- /dev/null
+++ b/dom/base/test/wholeTexty-helper.xml
@@ -0,0 +1,6 @@
+
+">
+ ]>
+&foobar;
diff --git a/dom/base/test/worker_postMessages.js b/dom/base/test/worker_postMessages.js
new file mode 100644
index 000000000..968ec209a
--- /dev/null
+++ b/dom/base/test/worker_postMessages.js
@@ -0,0 +1,33 @@
+function test_workers() {
+ onmessage = function(e) {
+ postMessage(e.data, e.ports);
+ }
+}
+
+function test_broadcastChannel() {
+ var bc = new BroadcastChannel('postMessagesTest_inWorkers');
+ bc.onmessage = function(e) {
+ postMessage(e.data);
+ }
+}
+
+function test_messagePort(port) {
+ port.onmessage = function(e) {
+ postMessage(e.data, e.ports);
+ }
+}
+
+onmessage = function(e) {
+ if (e.data == 'workers') {
+ test_workers();
+ postMessage('ok');
+ } else if (e.data == 'broadcastChannel') {
+ test_broadcastChannel();
+ postMessage('ok');
+ } else if (e.data == 'messagePort') {
+ test_messagePort(e.ports[0]);
+ postMessage('ok');
+ } else {
+ postMessage('ko');
+ }
+}
--
cgit v1.2.3