diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/components/sessionstore/test/browser_pageStyle.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/sessionstore/test/browser_pageStyle.js')
-rw-r--r-- | browser/components/sessionstore/test/browser_pageStyle.js | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_pageStyle.js b/browser/components/sessionstore/test/browser_pageStyle.js new file mode 100644 index 000000000..7abee5d9d --- /dev/null +++ b/browser/components/sessionstore/test/browser_pageStyle.js @@ -0,0 +1,89 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const URL = getRootDirectory(gTestPath) + "browser_pageStyle_sample.html"; +const URL_NESTED = getRootDirectory(gTestPath) + "browser_pageStyle_sample_nested.html"; + +/** + * This test ensures that page style information is correctly persisted. + */ +add_task(function page_style() { + let tab = gBrowser.addTab(URL); + let browser = tab.linkedBrowser; + yield promiseBrowserLoaded(browser); + let sheets = yield getStyleSheets(browser); + + // Enable all style sheets one by one. + for (let [title, disabled] of sheets) { + yield enableStyleSheetsForSet(browser, title); + + let tab2 = gBrowser.duplicateTab(tab); + yield promiseTabRestored(tab2); + + let sheets = yield getStyleSheets(tab2.linkedBrowser); + let enabled = sheets.filter(([title, disabled]) => !disabled); + + if (title.startsWith("fail_")) { + ok(!enabled.length, "didn't restore " + title); + } else { + is(enabled.length, 1, "restored one style sheet"); + is(enabled[0][0], title, "restored correct sheet"); + } + + gBrowser.removeTab(tab2); + } + + // Disable all styles and verify that this is correctly persisted. + yield setAuthorStyleDisabled(browser, true); + + let tab2 = gBrowser.duplicateTab(tab); + yield promiseTabRestored(tab2); + + let authorStyleDisabled = yield getAuthorStyleDisabled(tab2.linkedBrowser); + ok(authorStyleDisabled, "disabled all stylesheets"); + + // Clean up. + gBrowser.removeTab(tab); + gBrowser.removeTab(tab2); +}); + +/** + * This test ensures that page style notification from nested documents are + * received and the page style is persisted correctly. + */ +add_task(function nested_page_style() { + let tab = gBrowser.addTab(URL_NESTED); + let browser = tab.linkedBrowser; + yield promiseBrowserLoaded(browser); + + yield enableSubDocumentStyleSheetsForSet(browser, "alternate"); + yield promiseRemoveTab(tab); + + let [{state: {pageStyle}}] = JSON.parse(ss.getClosedTabData(window)); + let expected = JSON.stringify({children: [{pageStyle: "alternate"}]}); + is(JSON.stringify(pageStyle), expected, "correct pageStyle persisted"); +}); + +function getStyleSheets(browser) { + return sendMessage(browser, "ss-test:getStyleSheets"); +} + +function enableStyleSheetsForSet(browser, name) { + return sendMessage(browser, "ss-test:enableStyleSheetsForSet", name); +} + +function enableSubDocumentStyleSheetsForSet(browser, name) { + return sendMessage(browser, "ss-test:enableSubDocumentStyleSheetsForSet", { + id: "iframe", set: name + }); +} + +function getAuthorStyleDisabled(browser) { + return sendMessage(browser, "ss-test:getAuthorStyleDisabled"); +} + +function setAuthorStyleDisabled(browser, val) { + return sendMessage(browser, "ss-test:setAuthorStyleDisabled", val) +} |