michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: const URL = ROOT + "browser_456342_sample.xhtml"; michael@0: michael@0: /** michael@0: * Bug 456342 - Restore values from non-standard input field types. michael@0: */ michael@0: add_task(function test_restore_nonstandard_input_values() { michael@0: // Add tab with various non-standard input field types. michael@0: let tab = gBrowser.addTab(URL); michael@0: let browser = tab.linkedBrowser; michael@0: yield promiseBrowserLoaded(browser); michael@0: michael@0: // Fill in form values. michael@0: let expectedValue = Math.random(); michael@0: yield setFormElementValues(browser, {value: expectedValue}); michael@0: michael@0: // Remove tab and check collected form data. michael@0: gBrowser.removeTab(tab); michael@0: let undoItems = JSON.parse(ss.getClosedTabData(window)); michael@0: let savedFormData = undoItems[0].state.formdata; michael@0: michael@0: let countGood = 0, countBad = 0; michael@0: for (let id of Object.keys(savedFormData.id)) { michael@0: if (savedFormData.id[id] == expectedValue) { michael@0: countGood++; michael@0: } else { michael@0: countBad++; michael@0: } michael@0: } michael@0: michael@0: for (let exp of Object.keys(savedFormData.xpath)) { michael@0: if (savedFormData.xpath[exp] == expectedValue) { michael@0: countGood++; michael@0: } else { michael@0: countBad++; michael@0: } michael@0: } michael@0: michael@0: is(countGood, 4, "Saved text for non-standard input fields"); michael@0: is(countBad, 0, "Didn't save text for ignored field types"); michael@0: }); michael@0: michael@0: function setFormElementValues(browser, data) { michael@0: return sendMessage(browser, "ss-test:setFormElementValues", data); michael@0: }