diff --git a/browser/base/content/test/general/browser_newWindowDrop.js b/browser/base/content/test/general/browser_newWindowDrop.js index ead01a42d406..03b70b00e7ab 100644 --- a/browser/base/content/test/general/browser_newWindowDrop.js +++ b/browser/base/content/test/general/browser_newWindowDrop.js @@ -41,10 +41,10 @@ add_task(async function single_url() { await dropText("mochi.test/first", ["http://www.mochi.test/first"]); }); add_task(async function single_javascript() { - await dropText("javascript:'bad'", ["javascript:'bad'"]); + await dropText("javascript:'bad'", ["about:blank"]); }); add_task(async function single_javascript_capital() { - await dropText("jAvascript:'bad'", ["javascript:'bad'"]); + await dropText("jAvascript:'bad'", ["about:blank"]); }); add_task(async function single_url2() { await dropText("mochi.test/second", ["http://www.mochi.test/second"]); @@ -65,7 +65,7 @@ add_task(async function multiple_urls() { }); add_task(async function multiple_urls_javascript() { await dropText("javascript:'bad1'\nmochi.test/3", [ - "javascript:'bad1'", + "about:blank", "http://www.mochi.test/3", ]); }); diff --git a/browser/components/urlbar/tests/browser/browser_keywordBookmarklets.js b/browser/components/urlbar/tests/browser/browser_keywordBookmarklets.js index 4f10a3f997f8..0e6dde78f894 100644 --- a/browser/components/urlbar/tests/browser/browser_keywordBookmarklets.js +++ b/browser/components/urlbar/tests/browser/browser_keywordBookmarklets.js @@ -7,7 +7,7 @@ add_task(async function setup() { let bm = await PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid, title: "bookmarklet", - url: "javascript:'%s'%20", + url: "javascript:'%sx'%20", }); await PlacesUtils.keywords.insert({ keyword: "bm", url: bm.url }); registerCleanupFunction(async function() { @@ -20,47 +20,47 @@ add_task(async function setup() { gURLBar.value = "bm"; gURLBar.focus(); EventUtils.synthesizeKey("KEY_Enter"); - return "javascript:''%20"; + return "x"; }, function() { info("Type keyword with searchstring and immediately press enter"); gURLBar.value = "bm a"; gURLBar.focus(); EventUtils.synthesizeKey("KEY_Enter"); - return "javascript:'a'%20"; + return "ax"; }, async function() { info("Search keyword, then press enter"); await promiseAutocompleteResultPopup("bm"); let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); - Assert.equal(result.title, "javascript:'' ", "Check title"); + Assert.equal(result.title, "javascript:'x' ", "Check title"); EventUtils.synthesizeKey("KEY_Enter"); - return "javascript:''%20"; + return "x"; }, async function() { info("Search keyword with searchstring, then press enter"); await promiseAutocompleteResultPopup("bm a"); let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); - Assert.equal(result.title, "javascript:'a' ", "Check title"); + Assert.equal(result.title, "javascript:'ax' ", "Check title"); EventUtils.synthesizeKey("KEY_Enter"); - return "javascript:'a'%20"; + return "ax"; }, async function() { await promiseAutocompleteResultPopup("bm"); let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); - Assert.equal(result.title, "javascript:'' ", "Check title"); + Assert.equal(result.title, "javascript:'x' ", "Check title"); let element = UrlbarTestUtils.getSelectedRow(window); EventUtils.synthesizeMouseAtCenter(element, {}); - return "javascript:''%20"; + return "x"; }, async function() { info("Search keyword with searchstring, then click"); await promiseAutocompleteResultPopup("bm a"); let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); - Assert.equal(result.title, "javascript:'a' ", "Check title"); + Assert.equal(result.title, "javascript:'ax' ", "Check title"); let element = UrlbarTestUtils.getSelectedRow(window); EventUtils.synthesizeMouseAtCenter(element, {}); - return "javascript:'a'%20"; + return "ax"; }, ]; for (let testFn of testFns) { @@ -78,10 +78,15 @@ async function do_test(loadFn) { let originalPrincipalURI = await getPrincipalURI(browser); let promise = BrowserTestUtils.waitForContentEvent(browser, "pageshow"); - let expectedUrl = await loadFn(); + const expectedTextContent = await loadFn(); info("Awaiting pageshow event"); await promise; - Assert.equal(gBrowser.currentURI.spec, expectedUrl); + // URI should not change when we run a javascript: URL. + Assert.equal(gBrowser.currentURI.spec, "about:blank"); + const textContent = await ContentTask.spawn(browser, [], function() { + return content.document.documentElement.textContent; + }); + Assert.equal(textContent, expectedTextContent); let newPrincipalURI = await getPrincipalURI(browser); Assert.equal( diff --git a/browser/components/urlbar/tests/browser/browser_urlbarCopying.js b/browser/components/urlbar/tests/browser/browser_urlbarCopying.js index ea2fc18ae671..422b44460f3c 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbarCopying.js +++ b/browser/components/urlbar/tests/browser/browser_urlbarCopying.js @@ -200,17 +200,16 @@ var tests = [ copyExpected: "http://example.com/%E3%80%80%E3%80%80", }, - // data: and javsacript: URIs shouldn't be encoded + // Loading of javascript: URI results in previous URI, so if the previous + // entry changes, change this one too! { loadURL: "javascript:('%C3%A9%20%25%50')", - expectedURL: "javascript:('%C3%A9 %25P')", - copyExpected: "javascript:('%C3%A9 %25P')", - }, - { - copyVal: "'%C3%A9 %25P')", - copyExpected: "javascript:(", + expectedLoad: "http://example.com/%E3%80%80%E3%80%80", + expectedURL: "example.com/%E3%80%80%E3%80%80", + copyExpected: "http://example.com/%E3%80%80%E3%80%80", }, + // data: URIs shouldn't be encoded { loadURL: "data:text/html,(%C3%A9%20%25%50)", expectedURL: "data:text/html,(%C3%A9 %25P)", @@ -264,7 +263,8 @@ function runTest(testCase, cb) { if (testCase.loadURL) { info(`Loading : ${testCase.loadURL}\n`); - loadURL(testCase.loadURL, doCheck); + let expectedLoad = testCase.expectedLoad || testCase.loadURL; + loadURL(testCase.loadURL, expectedLoad, doCheck); } else { if (testCase.setURL) { gURLBar.value = testCase.setURL; @@ -323,9 +323,11 @@ function testCopy(copyVal, targetValue, cb) { ); } -function loadURL(aURL, aCB) { +function loadURL(aURL, aExpectedLoad, aCB) { BrowserTestUtils.loadURI(gBrowser.selectedBrowser, aURL); - BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, aURL).then( - aCB - ); + BrowserTestUtils.browserLoaded( + gBrowser.selectedBrowser, + false, + aExpectedLoad + ).then(aCB); } diff --git a/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js b/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js index c2498d3dfd32..3cfb1d3c1e8f 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js +++ b/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js @@ -21,6 +21,12 @@ add_task(async function() { }); add_task(async function() { + // The test was originally to check that reloading of a javascript: URL could + // throw an error and empty the URL bar. This situation can no longer happen + // as in bug 836567 we set document.URL to active document's URL on navigation + // to a javascript: URL; reloading after that will simply reload the original + // active document rather than the javascript: URL itself. But we can still + // verify that the URL bar's value is correct. let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); is(gURLBar.value, TEST_URL, "The URL bar should match the URI"); let browserLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser); @@ -28,18 +34,21 @@ add_task(async function() { content.document.querySelector("a").click(); }); await browserLoaded; - ok( - gURLBar.value.startsWith("javascript"), - "The URL bar should have the JS URI" + is( + gURLBar.value, + TEST_URL, + "The URL bar should be the previous active document's URI." ); - // When reloading, the javascript: uri we're using will throw an exception. - // That's deliberate, so we need to tell mochitest to ignore it: await SpecialPowers.spawn(tab.linkedBrowser, [], async function() { // This is sync, so by the time we return we should have changed the URL bar. content.location.reload(); }).catch(e => { // Ignore expected exception. }); - ok(!!gURLBar.value, "URL bar should not be blank."); + is( + gURLBar.value, + TEST_URL, + "The URL bar should still be the previous active document's URI." + ); BrowserTestUtils.removeTab(tab); }); diff --git a/devtools/client/storage/test/browser_storage_cache_error.js b/devtools/client/storage/test/browser_storage_cache_error.js index 881340112734..a55afd9099fe 100644 --- a/devtools/client/storage/test/browser_storage_cache_error.js +++ b/devtools/client/storage/test/browser_storage_cache_error.js @@ -7,9 +7,22 @@ // Test handling errors in CacheStorage add_task(async function() { - await openTabAndSetupStorage(MAIN_DOMAIN + "storage-cache-error.html"); + // Open the URL in a private browsing window. + const win = await BrowserTestUtils.openNewBrowserWindow({ private: true }); + const tab = win.gBrowser.selectedBrowser; + const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal(); + tab.loadURI(MAIN_DOMAIN + "storage-cache-error.html", { + triggeringPrincipal: systemPrincipal, + }); + await BrowserTestUtils.browserLoaded(tab); - const cacheItemId = ["Cache", "javascript:parent.frameContent"]; + // On enumerating cache storages, CacheStorage::Keys would throw a + // DOM security exception. We'd like to verify storage panel still work in + // this case. + const target = await TargetFactory.forTab(win.gBrowser.selectedTab); + await openStoragePanel(null, target); + + const cacheItemId = ["Cache", "http://test2.example.org"]; await selectTreeItem(cacheItemId); ok( @@ -17,5 +30,6 @@ add_task(async function() { `The item ${cacheItemId.join(" > ")} is present in the tree` ); + await BrowserTestUtils.closeWindow(win); await finishTests(); }); diff --git a/devtools/client/storage/test/storage-cache-error.html b/devtools/client/storage/test/storage-cache-error.html index 1ae9dfc6de57..7639bad35471 100644 --- a/devtools/client/storage/test/storage-cache-error.html +++ b/devtools/client/storage/test/storage-cache-error.html @@ -4,17 +4,8 @@ Storage inspector test for handling errors in CacheStorage + - + diff --git a/docshell/test/mochitest/bug123696-subframe.html b/docshell/test/mochitest/bug123696-subframe.html deleted file mode 100644 index 136d0a184cad..000000000000 --- a/docshell/test/mochitest/bug123696-subframe.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - diff --git a/docshell/test/mochitest/mochitest.ini b/docshell/test/mochitest/mochitest.ini index 74077cdcfe26..25d3187711fe 100644 --- a/docshell/test/mochitest/mochitest.ini +++ b/docshell/test/mochitest/mochitest.ini @@ -1,6 +1,5 @@ [DEFAULT] support-files = - bug123696-subframe.html bug404548-subframe.html bug404548-subframe_window.html bug413310-post.sjs @@ -56,13 +55,11 @@ support-files = [test_anchor_scroll_after_document_open.html] [test_bfcache_plus_hash.html] -[test_bug123696.html] [test_bug1422334.html] support-files = bug1422334_redirect.html bug1422334_redirect.html^headers^ !/docshell/test/navigation/blank.html -[test_bug384014.html] [test_bug385434.html] [test_bug387979.html] [test_bug402210.html] diff --git a/docshell/test/mochitest/test_bug123696.html b/docshell/test/mochitest/test_bug123696.html deleted file mode 100644 index 400e09731ee4..000000000000 --- a/docshell/test/mochitest/test_bug123696.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - Test for Bug 123696 - - - - -Mozilla Bug 123696 -

- -

- -
-
-
- - diff --git a/docshell/test/mochitest/test_bug384014.html b/docshell/test/mochitest/test_bug384014.html deleted file mode 100644 index a27d0b24ebec..000000000000 --- a/docshell/test/mochitest/test_bug384014.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Test for Bug 384014 - - - - -Mozilla Bug 384014 -

- -

- -
-
-
- - - diff --git a/testing/web-platform/meta/html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm.ini b/testing/web-platform/meta/html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm.ini deleted file mode 100644 index 78c2fea461f9..000000000000 --- a/testing/web-platform/meta/html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm.ini +++ /dev/null @@ -1,4 +0,0 @@ -[iframe_javascript_url_01.htm] - [javascript: URL creating a document in an about:blank iframe] - expected: FAIL - diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/location_reload_javascript_url.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/location_reload_javascript_url.html new file mode 100644 index 000000000000..737cafbcd3ec --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/location_reload_javascript_url.html @@ -0,0 +1,60 @@ + + + + location_reload_javascript_url + + + + +
+ + + + + + +