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/base/content/test/general/browser_viewSourceInTabOnViewSource.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/base/content/test/general/browser_viewSourceInTabOnViewSource.js')
-rw-r--r-- | browser/base/content/test/general/browser_viewSourceInTabOnViewSource.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_viewSourceInTabOnViewSource.js b/browser/base/content/test/general/browser_viewSourceInTabOnViewSource.js new file mode 100644 index 000000000..c8f3cdc96 --- /dev/null +++ b/browser/base/content/test/general/browser_viewSourceInTabOnViewSource.js @@ -0,0 +1,55 @@ +function wait_while_tab_is_busy() { + return new Promise(resolve => { + let progressListener = { + onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) { + if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) { + gBrowser.removeProgressListener(this); + setTimeout(resolve, 0); + } + } + }; + gBrowser.addProgressListener(progressListener); + }); +} + +// This function waits for the tab to stop being busy instead of waiting for it +// to load, since the canViewSource change happens at that time. +var with_new_tab_opened = Task.async(function* (options, taskFn) { + let busyPromise = wait_while_tab_is_busy(); + let tab = yield BrowserTestUtils.openNewForegroundTab(options.gBrowser, options.url, false); + yield busyPromise; + yield taskFn(tab.linkedBrowser); + gBrowser.removeTab(tab); +}); + +add_task(function*() { + yield new Promise((resolve) => { + SpecialPowers.pushPrefEnv({"set": [ + ["view_source.tab", true], + ]}, resolve); + }); +}); + +add_task(function* test_regular_page() { + function* test_expect_view_source_enabled(browser) { + ok(!XULBrowserWindow.canViewSource.hasAttribute("disabled"), + "View Source should be enabled"); + } + + yield with_new_tab_opened({ + gBrowser, + url: "http://example.com", + }, test_expect_view_source_enabled); +}); + +add_task(function* test_view_source_page() { + function* test_expect_view_source_disabled(browser) { + ok(XULBrowserWindow.canViewSource.hasAttribute("disabled"), + "View Source should be disabled"); + } + + yield with_new_tab_opened({ + gBrowser, + url: "view-source:http://example.com", + }, test_expect_view_source_disabled); +}); |