|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 "use strict"; |
|
5 |
|
6 const URL = ROOT + "browser_456342_sample.xhtml"; |
|
7 |
|
8 /** |
|
9 * Bug 456342 - Restore values from non-standard input field types. |
|
10 */ |
|
11 add_task(function test_restore_nonstandard_input_values() { |
|
12 // Add tab with various non-standard input field types. |
|
13 let tab = gBrowser.addTab(URL); |
|
14 let browser = tab.linkedBrowser; |
|
15 yield promiseBrowserLoaded(browser); |
|
16 |
|
17 // Fill in form values. |
|
18 let expectedValue = Math.random(); |
|
19 yield setFormElementValues(browser, {value: expectedValue}); |
|
20 |
|
21 // Remove tab and check collected form data. |
|
22 gBrowser.removeTab(tab); |
|
23 let undoItems = JSON.parse(ss.getClosedTabData(window)); |
|
24 let savedFormData = undoItems[0].state.formdata; |
|
25 |
|
26 let countGood = 0, countBad = 0; |
|
27 for (let id of Object.keys(savedFormData.id)) { |
|
28 if (savedFormData.id[id] == expectedValue) { |
|
29 countGood++; |
|
30 } else { |
|
31 countBad++; |
|
32 } |
|
33 } |
|
34 |
|
35 for (let exp of Object.keys(savedFormData.xpath)) { |
|
36 if (savedFormData.xpath[exp] == expectedValue) { |
|
37 countGood++; |
|
38 } else { |
|
39 countBad++; |
|
40 } |
|
41 } |
|
42 |
|
43 is(countGood, 4, "Saved text for non-standard input fields"); |
|
44 is(countBad, 0, "Didn't save text for ignored field types"); |
|
45 }); |
|
46 |
|
47 function setFormElementValues(browser, data) { |
|
48 return sendMessage(browser, "ss-test:setFormElementValues", data); |
|
49 } |