Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 const URL = ROOT + "browser_456342_sample.xhtml";
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);
17 // Fill in form values.
18 let expectedValue = Math.random();
19 yield setFormElementValues(browser, {value: expectedValue});
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;
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 }
35 for (let exp of Object.keys(savedFormData.xpath)) {
36 if (savedFormData.xpath[exp] == expectedValue) {
37 countGood++;
38 } else {
39 countBad++;
40 }
41 }
43 is(countGood, 4, "Saved text for non-standard input fields");
44 is(countBad, 0, "Didn't save text for ignored field types");
45 });
47 function setFormElementValues(browser, data) {
48 return sendMessage(browser, "ss-test:setFormElementValues", data);
49 }