From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../test/browser_async_duplicate_tab.js | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 browser/components/sessionstore/test/browser_async_duplicate_tab.js (limited to 'browser/components/sessionstore/test/browser_async_duplicate_tab.js') diff --git a/browser/components/sessionstore/test/browser_async_duplicate_tab.js b/browser/components/sessionstore/test/browser_async_duplicate_tab.js new file mode 100644 index 000000000..8696a284f --- /dev/null +++ b/browser/components/sessionstore/test/browser_async_duplicate_tab.js @@ -0,0 +1,78 @@ +"use strict"; + +const URL = "data:text/html;charset=utf-8,clickme"; + +add_task(function* test_duplicate() { + // Create new tab. + let tab = gBrowser.addTab(URL); + let browser = tab.linkedBrowser; + yield promiseBrowserLoaded(browser); + + // Flush to empty any queued update messages. + yield TabStateFlusher.flush(browser); + + // Click the link to navigate, this will add second shistory entry. + yield ContentTask.spawn(browser, null, function* () { + return new Promise(resolve => { + addEventListener("hashchange", function onHashChange() { + removeEventListener("hashchange", onHashChange); + resolve(); + }); + + // Click the link. + content.document.querySelector("a").click(); + }); + }); + + // Duplicate the tab. + let tab2 = ss.duplicateTab(window, tab); + + // Wait until the tab has fully restored. + yield promiseTabRestored(tab2); + yield TabStateFlusher.flush(tab2.linkedBrowser); + + // There should be two history entries now. + let {entries} = JSON.parse(ss.getTabState(tab2)); + is(entries.length, 2, "there are two shistory entries"); + + // Cleanup. + yield promiseRemoveTab(tab2); + yield promiseRemoveTab(tab); +}); + +add_task(function* test_duplicate_remove() { + // Create new tab. + let tab = gBrowser.addTab(URL); + let browser = tab.linkedBrowser; + yield promiseBrowserLoaded(browser); + + // Flush to empty any queued update messages. + yield TabStateFlusher.flush(browser); + + // Click the link to navigate, this will add second shistory entry. + yield ContentTask.spawn(browser, null, function* () { + return new Promise(resolve => { + addEventListener("hashchange", function onHashChange() { + removeEventListener("hashchange", onHashChange); + resolve(); + }); + + // Click the link. + content.document.querySelector("a").click(); + }); + }); + + // Duplicate the tab. + let tab2 = ss.duplicateTab(window, tab); + + // Before the duplication finished, remove the tab. + yield Promise.all([promiseRemoveTab(tab), promiseTabRestored(tab2)]); + yield TabStateFlusher.flush(tab2.linkedBrowser); + + // There should be two history entries now. + let {entries} = JSON.parse(ss.getTabState(tab2)); + is(entries.length, 2, "there are two shistory entries"); + + // Cleanup. + yield promiseRemoveTab(tab2); +}); -- cgit v1.2.3