@@ -11,6 +11,12 @@ var testData = [
11
11
action : "http://example.com/search?oe=utf-8" ,
12
12
param : "q" ,
13
13
} ,
14
+ {
15
+ desc : "With Unicode Query String" ,
16
+ action : "http://example.com/searching" ,
17
+ param : "q" ,
18
+ testHiddenUnicode : true ,
19
+ } ,
14
20
] ;
15
21
16
22
add_task ( async function ( ) {
@@ -20,7 +26,7 @@ add_task(async function () {
20
26
21
27
let count = 0 ;
22
28
for ( let method of [ "GET" , "POST" ] ) {
23
- for ( let { desc, action, param } of testData ) {
29
+ for ( let { desc, action, param, testHiddenUnicode = false } of testData ) {
24
30
info ( `Running ${ method } keyword test '${ desc } '` ) ;
25
31
let id = `keyword-form-${ count ++ } ` ;
26
32
let contextMenu = document . getElementById ( "contentAreaContextMenu" ) ;
@@ -31,7 +37,7 @@ add_task(async function () {
31
37
32
38
await SpecialPowers . spawn (
33
39
tab . linkedBrowser ,
34
- [ { action, param, method, id } ] ,
40
+ [ { action, param, method, id, testHiddenUnicode } ] ,
35
41
async function ( args ) {
36
42
let doc = content . document ;
37
43
let form = doc . createElement ( "form" ) ;
@@ -42,6 +48,12 @@ add_task(async function () {
42
48
element . setAttribute ( "type" , "text" ) ;
43
49
element . setAttribute ( "name" , args . param ) ;
44
50
form . appendChild ( element ) ;
51
+ if ( args . testHiddenUnicode ) {
52
+ form . insertAdjacentHTML (
53
+ "beforeend" ,
54
+ `<input name="utf8✓" type="hidden" value="✓">`
55
+ ) ;
56
+ }
45
57
doc . body . appendChild ( form ) ;
46
58
}
47
59
) ;
@@ -63,17 +75,31 @@ add_task(async function () {
63
75
data . spec . endsWith ( `${ param } =%s` ) ,
64
76
`Check expected url for field named ${ param } and action ${ action } `
65
77
) ;
78
+ if ( testHiddenUnicode ) {
79
+ ok (
80
+ data . spec . includes ( `utf8%E2%9C%93=%E2%9C%93` ) ,
81
+ `Check the unicode param is correctly encoded`
82
+ ) ;
83
+ }
66
84
} else {
67
85
is (
68
86
data . spec ,
69
87
url ,
70
88
`Check expected url for field named ${ param } and action ${ action } `
71
89
) ;
72
- is (
73
- data . postData ,
74
- `${ param } %3D%25s` ,
75
- `Check expected POST data for field named ${ param } and action ${ action } `
76
- ) ;
90
+ if ( testHiddenUnicode ) {
91
+ is (
92
+ data . postData ,
93
+ `utf8%u2713%3D%u2713&q%3D%25s` ,
94
+ `Check expected POST data for field named ${ param } and action ${ action } `
95
+ ) ;
96
+ } else {
97
+ is (
98
+ data . postData ,
99
+ `${ param } %3D%25s` ,
100
+ `Check expected POST data for field named ${ param } and action ${ action } `
101
+ ) ;
102
+ }
77
103
}
78
104
79
105
let popupHiddenPromise = BrowserTestUtils . waitForEvent (
0 commit comments