1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_456342.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +"use strict"; 1.8 + 1.9 +const URL = ROOT + "browser_456342_sample.xhtml"; 1.10 + 1.11 +/** 1.12 + * Bug 456342 - Restore values from non-standard input field types. 1.13 + */ 1.14 +add_task(function test_restore_nonstandard_input_values() { 1.15 + // Add tab with various non-standard input field types. 1.16 + let tab = gBrowser.addTab(URL); 1.17 + let browser = tab.linkedBrowser; 1.18 + yield promiseBrowserLoaded(browser); 1.19 + 1.20 + // Fill in form values. 1.21 + let expectedValue = Math.random(); 1.22 + yield setFormElementValues(browser, {value: expectedValue}); 1.23 + 1.24 + // Remove tab and check collected form data. 1.25 + gBrowser.removeTab(tab); 1.26 + let undoItems = JSON.parse(ss.getClosedTabData(window)); 1.27 + let savedFormData = undoItems[0].state.formdata; 1.28 + 1.29 + let countGood = 0, countBad = 0; 1.30 + for (let id of Object.keys(savedFormData.id)) { 1.31 + if (savedFormData.id[id] == expectedValue) { 1.32 + countGood++; 1.33 + } else { 1.34 + countBad++; 1.35 + } 1.36 + } 1.37 + 1.38 + for (let exp of Object.keys(savedFormData.xpath)) { 1.39 + if (savedFormData.xpath[exp] == expectedValue) { 1.40 + countGood++; 1.41 + } else { 1.42 + countBad++; 1.43 + } 1.44 + } 1.45 + 1.46 + is(countGood, 4, "Saved text for non-standard input fields"); 1.47 + is(countBad, 0, "Didn't save text for ignored field types"); 1.48 +}); 1.49 + 1.50 +function setFormElementValues(browser, data) { 1.51 + return sendMessage(browser, "ss-test:setFormElementValues", data); 1.52 +}