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 /dom/browser-element/mochitest/browserElement_PurgeHistory.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 'dom/browser-element/mochitest/browserElement_PurgeHistory.js')
-rw-r--r-- | dom/browser-element/mochitest/browserElement_PurgeHistory.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/browserElement_PurgeHistory.js b/dom/browser-element/mochitest/browserElement_PurgeHistory.js new file mode 100644 index 000000000..4815f03e7 --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_PurgeHistory.js @@ -0,0 +1,87 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Bug 807056 - [Browser] Clear History doesn't clear back/forward history in open tabs +// <iframe mozbrowser>. + +"use strict"; +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); + +var iframe; +function addOneShotIframeEventListener(event, fn) { + function wrapper(e) { + iframe.removeEventListener(event, wrapper); + fn(e); + }; + + iframe.addEventListener(event, wrapper); +} + +function runTest() { + iframe = document.createElement('iframe'); + iframe.setAttribute('mozbrowser', 'true'); + // FIXME: Bug 1270790 + iframe.setAttribute('remote', 'true'); + + addOneShotIframeEventListener('mozbrowserloadend', function() { + SimpleTest.executeSoon(test2); + }); + + iframe.src = browserElementTestHelpers.emptyPage1; + document.body.appendChild(iframe); +} + +function purgeHistory(nextTest) { + var seenCanGoBackResult = false; + var seenCanGoForwardResult = false; + + iframe.purgeHistory().onsuccess = function(e) { + ok(true, "The history has been purged"); + + iframe.getCanGoBack().onsuccess = function(e) { + is(e.target.result, false, "Iframe cannot go back"); + seenCanGoBackResult = true; + maybeRunNextTest(); + }; + + iframe.getCanGoForward().onsuccess = function(e) { + is(e.target.result, false, "Iframe cannot go forward"); + seenCanGoForwardResult = true; + maybeRunNextTest(); + }; + }; + + function maybeRunNextTest() { + if (seenCanGoBackResult && seenCanGoForwardResult) { + nextTest(); + } + } +} + +function test2() { + purgeHistory(test3); +} + +function test3() { + addOneShotIframeEventListener('mozbrowserloadend', function() { + purgeHistory(test4); + }); + + SimpleTest.executeSoon(function() { + iframe.src = browserElementTestHelpers.emptyPage2; + }); +} + +function test4() { + addOneShotIframeEventListener('mozbrowserlocationchange', function(e) { + is(e.detail.url, browserElementTestHelpers.emptyPage3); + purgeHistory(SimpleTest.finish); + }); + + SimpleTest.executeSoon(function() { + iframe.src = browserElementTestHelpers.emptyPage3; + }); +} + +addEventListener('testready', runTest); |