browser/components/sessionstore/test/browser_456342.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial