Bug 1496082: Enable ESLint for docshell/test/navigation and docshell/test/unit (automatic fixes only). r=bzbarsky

Enabled ESLint for:

* docshell/test/navigation/**
* docshell/test/unit/**
* docshell/test/unit_ipc/**

Changed .eslintignore to allow for this and ran ./mach eslint --fix on the above directories and checked automatic fixes

Differential Revision: https://phabricator.services.mozilla.com/D9430

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Toby Ward 2018-11-06 14:48:43 +00:00
parent 8a92d6f72c
commit 415ae552bb
48 changed files with 324 additions and 333 deletions

View File

@ -14,7 +14,11 @@ obj*/**
# We ignore all these directories by default, until we get them enabled.
# If you are enabling a directory, please add directory specific exclusions
# below.
docshell/**
docshell/resources/**
docshell/test/browser/**
docshell/test/chrome/**
docshell/test/iframesandbox/**
docshell/test/mochitest/**
extensions/cookie/**
extensions/spellcheck/**
extensions/universalchardet/**

View File

@ -2,26 +2,26 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
//
// Utilities for navigation tests
//
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
var body = "This frame was navigated.";
var target_url = "navigation_target_url.html"
var target_url = "navigation_target_url.html";
var popup_body = "This is a popup";
var target_popup_url = "navigation_target_popup_url.html";
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// Functions that navigate frames
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
function navigateByLocation(wnd) {
try {
wnd.location = target_url;
} catch(ex) {
} catch (ex) {
// We need to keep our finished frames count consistent.
// Oddly, this ends up simulating the behavior of IE7.
window.open(target_url, "_blank", "width=10,height=10");
@ -48,18 +48,18 @@ function navigateByHyperlink(name) {
link.target = name;
link.id = "navigation_hyperlink_" + hyperlink_count++;
document.body.appendChild(link);
sendMouseEvent({type:"click"}, link.id);
sendMouseEvent({type: "click"}, link.id);
}
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// Functions that call into Mochitest framework
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
function isNavigated(wnd, message) {
var result = null;
try {
result = SpecialPowers.wrap(wnd).document.body.innerHTML.trim();
} catch(ex) {
} catch (ex) {
result = ex;
}
is(result, body, message);
@ -69,7 +69,7 @@ function isBlank(wnd, message) {
var result = null;
try {
result = wnd.document.body.innerHTML.trim();
} catch(ex) {
} catch (ex) {
result = ex;
}
is(result, "This is a blank document.", message);
@ -79,7 +79,7 @@ function isAccessible(wnd, message) {
try {
wnd.document.body.innerHTML;
ok(true, message);
} catch(ex) {
} catch (ex) {
ok(false, message);
}
}
@ -88,14 +88,14 @@ function isInaccessible(wnd, message) {
try {
wnd.document.body.innerHTML;
ok(false, message);
} catch(ex) {
} catch (ex) {
ok(true, message);
}
}
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// Functions that require UniversalXPConnect privilege
///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
function xpcEnumerateContentWindows(callback) {
@ -199,7 +199,7 @@ function xpcWaitForFinishedFrames(callback, numFrames) {
// This only gives us UniversalXPConnect for the current stack frame
// We're using setInterval, so the main page's privileges are still normal
xpcEnumerateContentWindows(searchForFinishedFrames);
} catch(ex) {
} catch (ex) {
// We might be accessing windows before they are fully constructed,
// which can throw. We'll find those frames on our next poll().
}

View File

@ -1,5 +1,5 @@
<html><head>
<script> window.addEventListener("pageshow", function(){opener.nextTest();}, false); </script>
<script> window.addEventListener("pageshow", function() { opener.nextTest(); }); </script>
</head><body>
<div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:blue">
<p>This is a very tall blue box.</p>

View File

@ -13,13 +13,13 @@ add_task(async function() {
SpecialPowers.pushPrefEnv({
"set": [
["browser.link.open_newwindow", 2],
]
],
}, resolve);
});
await BrowserTestUtils.withNewTab({
gBrowser,
url: TEST_PAGE
url: TEST_PAGE,
}, async function(browser) {
let openedPromise = BrowserTestUtils.waitForNewWindow();
BrowserTestUtils.synthesizeMouse("a", 0, 0, {}, browser);

View File

@ -30,31 +30,31 @@
let shistory = webNav.sessionHistory;
let testSteps = [
function() {
opener.is(shistory.count, 1, 'check history length');
opener.is(shistory.index, 0, 'check history index');
opener.ok(!webNav.canGoForward, 'check canGoForward');
setTimeout(() => window.location = 'file_bug1300461_back.html', 0);
opener.is(shistory.count, 1, "check history length");
opener.is(shistory.index, 0, "check history index");
opener.ok(!webNav.canGoForward, "check canGoForward");
setTimeout(() => window.location = "file_bug1300461_back.html", 0);
},
function() {
opener.is(shistory.count, 2, 'check history length');
opener.is(shistory.index, 0, 'check history index');
opener.ok(webNav.canGoForward, 'check canGoForward');
opener.is(shistory.count, 2, "check history length");
opener.is(shistory.index, 0, "check history index");
opener.ok(webNav.canGoForward, "check canGoForward");
window.history.forward();
opener.is(shistory.legacySHistory.requestedIndex, 1, 'check requestedIndex');
opener.is(shistory.legacySHistory.requestedIndex, 1, "check requestedIndex");
},
function() {
opener.is(shistory.count, 2, 'check history length');
opener.is(shistory.index, 0, 'check history index');
opener.ok(webNav.canGoForward, 'check canGoForward');
opener.info('file_bug1300461.html tests finished');
opener.is(shistory.count, 2, "check history length");
opener.is(shistory.index, 0, "check history index");
opener.ok(webNav.canGoForward, "check canGoForward");
opener.info("file_bug1300461.html tests finished");
opener.nextTest();
window.close();
}
},
];
function test() {
if (opener) {
opener.info('file_bug1300461.html test ' + opener.testCount);
opener.info("file_bug1300461.html test " + opener.testCount);
testSteps[opener.testCount++]();
}
}

View File

@ -15,13 +15,13 @@
function test() {
if (opener) {
opener.info("file_bug1300461_back.html");
opener.is(shistory.count, 2, 'check history length');
opener.is(shistory.index, 1, 'check history index');
opener.is(shistory.legacySHistory.requestedIndex, -1, 'check requestedIndex');
opener.ok(webNav.canGoBack, 'check canGoBack');
opener.is(shistory.count, 2, "check history length");
opener.is(shistory.index, 1, "check history index");
opener.is(shistory.legacySHistory.requestedIndex, -1, "check requestedIndex");
opener.ok(webNav.canGoBack, "check canGoBack");
if (opener.testCount == 1) {
opener.info('replaceState to redirect.html');
window.history.replaceState({}, '', 'file_bug1300461_redirect.html');
opener.info("replaceState to redirect.html");
window.history.replaceState({}, "", "file_bug1300461_redirect.html");
}
window.history.back();
}

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>Bug 1326251</title>
<script>
const BASE_URL = 'http://mochi.test:8888/tests/docshell/test/navigation/';
const BASE_URL = "http://mochi.test:8888/tests/docshell/test/navigation/";
let testSteps = [
async function() {
// Test 1: Create dynamic iframe with bfcache enabled.
@ -13,35 +13,35 @@
// entries preserved.
window.onunload = null; // enable bfcache
let dynamicFrame = await createDynamicFrame(document);
await loadUriInFrame(document.getElementById('staticFrame'), 'frame1.html');
await loadUriInFrame(document.getElementById('dynamicFrame'), 'frame1.html');
await loadUriInFrame(document.getElementById('staticFrame'), 'frame2.html');
await loadUriInFrame(document.getElementById('dynamicFrame'), 'frame2.html');
opener.is(history.length, 5, 'history.length');
window.location = 'goback.html';
await loadUriInFrame(document.getElementById("staticFrame"), "frame1.html");
await loadUriInFrame(document.getElementById("dynamicFrame"), "frame1.html");
await loadUriInFrame(document.getElementById("staticFrame"), "frame2.html");
await loadUriInFrame(document.getElementById("dynamicFrame"), "frame2.html");
opener.is(history.length, 5, "history.length");
window.location = "goback.html";
},
async function() {
let webNav = SpecialPowers.wrap(window)
.docShell
.QueryInterface(SpecialPowers.Ci.nsIWebNavigation);
let shistory = webNav.sessionHistory;
opener.is(webNav.canGoForward, true, 'canGoForward');
opener.is(shistory.index, 4, 'shistory.index');
opener.is(history.length, 6, 'history.length');
opener.is(document.getElementById('staticFrame').contentWindow.location.href, BASE_URL + 'frame2.html', 'staticFrame location');
opener.is(document.getElementById('dynamicFrame').contentWindow.location.href, BASE_URL + 'frame2.html', 'dynamicFrame location');
opener.is(webNav.canGoForward, true, "canGoForward");
opener.is(shistory.index, 4, "shistory.index");
opener.is(history.length, 6, "history.length");
opener.is(document.getElementById("staticFrame").contentWindow.location.href, BASE_URL + "frame2.html", "staticFrame location");
opener.is(document.getElementById("dynamicFrame").contentWindow.location.href, BASE_URL + "frame2.html", "dynamicFrame location");
// Test 2: Load another page in dynamic iframe, canGoForward should be
// false.
await loadUriInFrame(document.getElementById('dynamicFrame'), 'frame3.html');
opener.is(webNav.canGoForward, false, 'canGoForward');
opener.is(shistory.index, 5, 'shistory.index');
opener.is(history.length, 6, 'history.length');
await loadUriInFrame(document.getElementById("dynamicFrame"), "frame3.html");
opener.is(webNav.canGoForward, false, "canGoForward");
opener.is(shistory.index, 5, "shistory.index");
opener.is(history.length, 6, "history.length");
// Test 3: Navigate to antoher page with bfcache disabled, all dynamic
// iframe entries should be removed.
window.onunload = function(){}; // disable bfcache
window.location = 'goback.html';
window.onunload = function() {}; // disable bfcache
window.location = "goback.html";
},
async function() {
let windowWrap = SpecialPowers.wrap(window);
@ -49,58 +49,58 @@
let shistory = docShell.QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
.sessionHistory;
// Now staticFrame has frame0 -> frame1 -> frame2.
opener.is(docShell.previousEntryIndex, 3, 'docShell.previousEntryIndex');
opener.is(docShell.loadedEntryIndex, 2, 'docShell.loadedEntryIndex');
opener.is(shistory.index, 2, 'shistory.index');
opener.is(history.length, 4, 'history.length');
opener.is(document.getElementById('staticFrame').contentWindow.location.href, BASE_URL + 'frame2.html', 'staticFrame location');
opener.ok(!document.getElementById('dynamicFrame'), 'dynamicFrame should not exist');
opener.is(docShell.previousEntryIndex, 3, "docShell.previousEntryIndex");
opener.is(docShell.loadedEntryIndex, 2, "docShell.loadedEntryIndex");
opener.is(shistory.index, 2, "shistory.index");
opener.is(history.length, 4, "history.length");
opener.is(document.getElementById("staticFrame").contentWindow.location.href, BASE_URL + "frame2.html", "staticFrame location");
opener.ok(!document.getElementById("dynamicFrame"), "dynamicFrame should not exist");
// Test 4: Load a nested frame in the static frame, navigate the inner
// static frame, add a inner dynamic frame and navigate the dynamic
// frame. Then navigate the outer static frame and go back. The inner
// iframe should show the last entry of inner static frame.
let staticFrame = document.getElementById('staticFrame');
staticFrame.width = '320px';
staticFrame.height = '360px';
await loadUriInFrame(staticFrame, 'iframe_static.html');
let innerStaticFrame = staticFrame.contentDocument.getElementById('staticFrame');
await loadUriInFrame(innerStaticFrame, 'frame1.html');
let innerDynamicFrame = await createDynamicFrame(staticFrame.contentDocument, 'frame2.html');
await loadUriInFrame(innerDynamicFrame, 'frame3.html');
let staticFrame = document.getElementById("staticFrame");
staticFrame.width = "320px";
staticFrame.height = "360px";
await loadUriInFrame(staticFrame, "iframe_static.html");
let innerStaticFrame = staticFrame.contentDocument.getElementById("staticFrame");
await loadUriInFrame(innerStaticFrame, "frame1.html");
let innerDynamicFrame = await createDynamicFrame(staticFrame.contentDocument, "frame2.html");
await loadUriInFrame(innerDynamicFrame, "frame3.html");
// staticFrame: frame0 -> frame1 -> frame2 -> iframe_static
// innerStaticFrame: frame0 -> frame1
// innerDynamicFrame: frame2 -> frame3
opener.is(shistory.index, 5, 'shistory.index');
opener.is(history.length, 6, 'history.length');
opener.is(shistory.index, 5, "shistory.index");
opener.is(history.length, 6, "history.length");
// Wait for 2 load events - navigation and goback.
let onloadPromise = awaitOnload(staticFrame, 2);
await loadUriInFrame(staticFrame, 'goback.html');
await loadUriInFrame(staticFrame, "goback.html");
await onloadPromise;
// staticFrame: frame0 -> frame1 -> frame2 -> iframe_static -> goback
// innerStaticFrame: frame0 -> frame1
opener.is(shistory.index, 4, 'shistory.index');
opener.is(history.length, 6, 'history.length');
innerStaticFrame = staticFrame.contentDocument.getElementById('staticFrame');
opener.is(innerStaticFrame.contentDocument.location.href, BASE_URL + 'frame1.html', 'innerStaticFrame location');
opener.ok(!staticFrame.contentDocument.getElementById('dynamicFrame'), 'innerDynamicFrame should not exist');
opener.is(shistory.index, 4, "shistory.index");
opener.is(history.length, 6, "history.length");
innerStaticFrame = staticFrame.contentDocument.getElementById("staticFrame");
opener.is(innerStaticFrame.contentDocument.location.href, BASE_URL + "frame1.html", "innerStaticFrame location");
opener.ok(!staticFrame.contentDocument.getElementById("dynamicFrame"), "innerDynamicFrame should not exist");
// Test 5: Insert and navigate inner dynamic frame again with bfcache
// enabled, and navigate top level window to a special page which will
// evict bfcache then goback. Verify that dynamic entries are correctly
// removed in this case.
window.onunload = null; // enable bfcache
staticFrame.width = '320px';
staticFrame.height = '360px';
innerDynamicFrame = await createDynamicFrame(staticFrame.contentDocument, 'frame2.html');
await loadUriInFrame(innerDynamicFrame, 'frame3.html');
staticFrame.width = "320px";
staticFrame.height = "360px";
innerDynamicFrame = await createDynamicFrame(staticFrame.contentDocument, "frame2.html");
await loadUriInFrame(innerDynamicFrame, "frame3.html");
// staticFrame: frame0 -> frame1 -> frame2 -> iframe_static
// innerStaticFrame: frame0 -> frame1
// innerDynamicFrame: frame2 -> frame3
opener.is(shistory.index, 5, 'shistory.index');
opener.is(history.length, 6, 'history.length');
window.location = 'file_bug1326251_evict_cache.html';
opener.is(shistory.index, 5, "shistory.index");
opener.is(history.length, 6, "history.length");
window.location = "file_bug1326251_evict_cache.html";
},
async function() {
let windowWrap = SpecialPowers.wrap(window);
@ -109,26 +109,26 @@
.sessionHistory;
// staticFrame: frame0 -> frame1 -> frame2 -> iframe_static
// innerStaticFrame: frame0 -> frame1
opener.is(docShell.previousEntryIndex, 5, 'docShell.previousEntryIndex');
opener.is(docShell.loadedEntryIndex, 4, 'docShell.loadedEntryIndex');
opener.is(shistory.index, 4, 'shistory.index');
opener.is(history.length, 6, 'history.length');
let staticFrame = document.getElementById('staticFrame');
let innerStaticFrame = staticFrame.contentDocument.getElementById('staticFrame');
opener.is(innerStaticFrame.contentDocument.location.href, BASE_URL + 'frame1.html', 'innerStaticFrame location');
opener.ok(!staticFrame.contentDocument.getElementById('dynamicFrame'), 'innerDynamicFrame should not exist');
opener.is(docShell.previousEntryIndex, 5, "docShell.previousEntryIndex");
opener.is(docShell.loadedEntryIndex, 4, "docShell.loadedEntryIndex");
opener.is(shistory.index, 4, "shistory.index");
opener.is(history.length, 6, "history.length");
let staticFrame = document.getElementById("staticFrame");
let innerStaticFrame = staticFrame.contentDocument.getElementById("staticFrame");
opener.is(innerStaticFrame.contentDocument.location.href, BASE_URL + "frame1.html", "innerStaticFrame location");
opener.ok(!staticFrame.contentDocument.getElementById("dynamicFrame"), "innerDynamicFrame should not exist");
// Test 6: Insert and navigate inner dynamic frame and then reload outer
// frame. Verify that inner dynamic frame entries are all removed.
staticFrame.width = '320px';
staticFrame.height = '360px';
let innerDynamicFrame = await createDynamicFrame(staticFrame.contentDocument, 'frame2.html');
await loadUriInFrame(innerDynamicFrame, 'frame3.html');
staticFrame.width = "320px";
staticFrame.height = "360px";
let innerDynamicFrame = await createDynamicFrame(staticFrame.contentDocument, "frame2.html");
await loadUriInFrame(innerDynamicFrame, "frame3.html");
// staticFrame: frame0 -> frame1 -> frame2 -> iframe_static
// innerStaticFrame: frame0 -> frame1
// innerDynamicFrame: frame2 -> frame3
opener.is(shistory.index, 5, 'shistory.index');
opener.is(history.length, 6, 'history.length');
opener.is(shistory.index, 5, "shistory.index");
opener.is(history.length, 6, "history.length");
let staticFrameLoadPromise = new Promise(resolve => {
staticFrame.onload = resolve;
});
@ -136,34 +136,34 @@
await staticFrameLoadPromise;
// staticFrame: frame0 -> frame1 -> frame2 -> iframe_static
// innerStaticFrame: frame0 -> frame1
opener.is(shistory.index, 4, 'shistory.index');
opener.is(history.length, 5, 'history.length');
innerStaticFrame = staticFrame.contentDocument.getElementById('staticFrame');
opener.is(innerStaticFrame.contentDocument.location.href, BASE_URL + 'frame1.html', 'innerStaticFrame location');
opener.ok(!staticFrame.contentDocument.getElementById('dynamicFrame'), 'innerDynamicFrame should not exist');
opener.is(shistory.index, 4, "shistory.index");
opener.is(history.length, 5, "history.length");
innerStaticFrame = staticFrame.contentDocument.getElementById("staticFrame");
opener.is(innerStaticFrame.contentDocument.location.href, BASE_URL + "frame1.html", "innerStaticFrame location");
opener.ok(!staticFrame.contentDocument.getElementById("dynamicFrame"), "innerDynamicFrame should not exist");
opener.nextTest();
window.close();
}
},
];
function awaitOnload(frame, occurances=1) {
function awaitOnload(frame, occurances = 1) {
return new Promise(function(resolve, reject) {
let count = 0;
frame.addEventListener('load', function listener(e) {
frame.addEventListener("load", function listener(e) {
if (++count == occurances) {
frame.removeEventListener('load', listener);
frame.removeEventListener("load", listener);
setTimeout(resolve, 0);
}
});
});
}
async function createDynamicFrame(targetDocument, frameSrc='frame0.html') {
let dynamicFrame = targetDocument.createElement('iframe');
async function createDynamicFrame(targetDocument, frameSrc = "frame0.html") {
let dynamicFrame = targetDocument.createElement("iframe");
let onloadPromise = awaitOnload(dynamicFrame);
dynamicFrame.id = 'dynamicFrame';
dynamicFrame.id = "dynamicFrame";
dynamicFrame.src = frameSrc;
let container = targetDocument.getElementById('frameContainer');
let container = targetDocument.getElementById("frameContainer");
container.appendChild(dynamicFrame);
await onloadPromise;
return dynamicFrame;

View File

@ -15,7 +15,7 @@
iframe.onload = function() {
opener.postMessage(iframe.contentWindow.location.href, "*");
};
}
};
}
</script>
</body>

View File

@ -27,6 +27,6 @@
onload = function() {
++loadCount;
opener.is(loadCount, 1, "Should only get one onload");
}
};
</script>
</html>

View File

@ -1 +1 @@
<html><head><meta charset="utf-8"><script>window.addEventListener("pageshow", function(event) { window.opener.postMessage({persisted:event.persisted}, "*"); });</script></head><body contentEditable="true"><p>contentEditable</p></body></html>
<html><head><meta charset="utf-8"><script>window.addEventListener("pageshow", function(event) { window.opener.postMessage({persisted: event.persisted}, "*"); });</script></head><body contentEditable="true"><p>contentEditable</p></body></html>

View File

@ -1 +1 @@
<html><head><meta charset="utf-8"><script>window.addEventListener("pageshow", function(event) { window.opener.postMessage({persisted:event.persisted}, "*"); });</script></head><body><p>designModeDocument</p></body></html>
<html><head><meta charset="utf-8"><script>window.addEventListener("pageshow", function(event) { window.opener.postMessage({persisted: event.persisted}, "*"); });</script></head><body><p>designModeDocument</p></body></html>

View File

@ -16,7 +16,7 @@
}
window.addEventListener("load",
function () {
function() {
var container = document.getElementById("t1");
container.addEventListener("load", dynFrameLoad, true);
container.appendChild(container.appendChild(document.getElementById("i1")));

View File

@ -7,7 +7,7 @@
var isOK = false;
try {
isOK = history.previous != location;
} catch(ex) {
} catch (ex) {
// history.previous should throw if this is the first page in shistory.
isOK = true;
}

View File

@ -29,7 +29,7 @@
opener.isnot(Math.round(window.scrollY), 0, "Should have restored scrolling.");
opener.is(history.scrollRestoration, "auto", "Should have the same scrollRestoration as before reload.");
history.scrollRestoration = "manual";
window.onunload = function() {} // Disable bfcache.
window.onunload = function() {}; // Disable bfcache.
window.location.reload(false);
break;
}
@ -40,7 +40,7 @@
document.getElementById("bottom").scrollIntoView();
window.onunload = null; // Should get bfcache behavior.
opener.setTimeout("SpecialPowers.wrap(testWindow).history.back();", 250);
window.location.href = 'about:blank';
window.location.href = "about:blank";
break;
}
case 4: {
@ -55,9 +55,9 @@
case 5: {
opener.isnot(Math.round(window.scrollY), 0, "Should have scrolled to #hash.");
opener.is(history.scrollRestoration, "manual", "Should have the same scrollRestoration mode as before fragment navigation.");
window.onunload = function() {} // Disable bfcache.
window.onunload = function() {}; // Disable bfcache.
opener.setTimeout("is(SpecialPowers.wrap(testWindow).history.scrollRestoration, 'auto'); SpecialPowers.wrap(testWindow).history.back();", 250);
window.location.href = 'about:blank';
window.location.href = "about:blank";
break;
}
case 6: {
@ -106,13 +106,13 @@
try {
var sr = oldHistoryObject.scrollRestoration;
opener.ok(false, "Should have thrown an exception.");
} catch(ex) {
} catch (ex) {
opener.isnot(ex, null, "Did get an exception");
}
try {
oldHistoryObject.scrollRestoration = "auto";
opener.ok(false, "Should have thrown an exception.");
} catch(ex) {
} catch (ex) {
opener.isnot(ex, null, "Did get an exception");
}
opener.nextTest();

View File

@ -4,7 +4,7 @@
function test() {
try {
frames[0].history.pushState({}, "state", "?pushed");
} catch(ex) {
} catch (ex) {
opener.ok(false, "history.pushState shouldn't throw");
}

View File

@ -8,18 +8,18 @@
<script type="application/javascript">
// make sure to set document.domain to the same domain as the subframe
window.onload = function() {
document.domain = 'mochi.test';
document.domain = "mochi.test";
};
window.addEventListener('message', receiveMessage);
window.addEventListener("message", receiveMessage);
function receiveMessage(event) {
// make sure to get the right start command, otherwise
// let the parent know and fail the test
if (event.data.start !== 'startTest') {
if (event.data.start !== "startTest") {
window.removeEventListener("message", receiveMessage);
window.parent.postMessage({triggeringPrincipalURI: 'false'}, '*');
window.parent.postMessage({triggeringPrincipalURI: "false"}, "*");
}
// click the link to navigate the subframe
document.getElementById('testlink').click();
document.getElementById("testlink").click();
}
</script>

View File

@ -6,9 +6,9 @@
<script type='application/javascript'>
// make sure to set document.domain to same domain as frame 1
window.onload = function() {
document.domain = 'mochi.test';
document.domain = "mochi.test";
// let Frame 1 know that we are ready to run the test
window.parent.parent.frames[0].postMessage({start: 'startTest'}, '*');
window.parent.parent.frames[0].postMessage({start: "startTest"}, "*");
};
</script>
</body>

View File

@ -14,7 +14,7 @@
var referrerURI = document.referrer;
window.parent.parent.postMessage({triggeringPrincipalURI,
loadingPrincipalURI,
referrerURI}, '*');
referrerURI}, "*");
}
</script>
</body>

View File

@ -8,7 +8,7 @@
var target = arguments[0];
var mechanism = arguments[1];
switch(mechanism) {
switch (mechanism) {
case "location":
navigateByLocation(eval(target));
break;

View File

@ -1,5 +1,5 @@
<html><head>
<script> window.addEventListener("pageshow", function(){opener.nextTest();}, false); </script>
<script> window.addEventListener("pageshow", function() { opener.nextTest(); }); </script>
</head><body>
<div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:red">
<p>This is a very tall red box.</p>

View File

@ -6,21 +6,21 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="NavigationUtils.js"></script>
<script>
window.onload = function () {
window.onload = function() {
document.getElementById("link0").href = target_url;
sendMouseEvent({type:"click"}, "link0");
sendMouseEvent({type: "click"}, "link0");
xpcWaitForFinishedFrames(function() {
var array_of_frames = xpcGetFramesByName("window0");
is(array_of_frames.length, 1, "Should only open one window using a fancy hyperlink.");
for (var i=0; i < array_of_frames.length; ++i)
for (var i = 0; i < array_of_frames.length; ++i)
array_of_frames[i].close();
xpcCleanupWindows();
SimpleTest.finish();
}, 1);
}
};
</script>
</head>
<body>

View File

@ -6,12 +6,12 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="NavigationUtils.js"></script>
<script>
window.onload = function () {
window.onload = function() {
document.getElementById("link0").href = target_url;
document.getElementById("link1").href = target_url;
sendMouseEvent({type:"click"}, "link0");
sendMouseEvent({type:"click"}, "link1");
sendMouseEvent({type: "click"}, "link0");
sendMouseEvent({type: "click"}, "link1");
xpcWaitForFinishedFrames(function() {
countAndClose("window0", 1);
@ -20,7 +20,7 @@ window.onload = function () {
xpcCleanupWindows();
SimpleTest.finish();
}, 2);
}
};
function countAndClose(name, expected_count) {
var array_of_frames = xpcGetFramesByName(name);
@ -28,7 +28,7 @@ function countAndClose(name, expected_count) {
"Should only open " + expected_count +
" window(s) with name " + name + " using a fancy hyperlink.");
for (var i=0; i < array_of_frames.length; ++i)
for (var i = 0; i < array_of_frames.length; ++i)
array_of_frames[i].close();
}
</script>

View File

@ -26,7 +26,7 @@ newwindow.onload = function() {
is(newwindow.innerWidth, 200, "window.open has correct width dimensions");
SimpleTest.finish();
newwindow.close();
}
};
</script>
</pre>
</body>

View File

@ -21,20 +21,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
{
// <html><body><p>designModeDocument</p></body></html>
url: "file_bug386782_designmode.html",
name: 'designModeNavigate',
name: "designModeNavigate",
onload(doc) { doc.designMode = "on"; },
expectedBodyBeforeEdit: '<p>designModeDocument</p>',
expectedBodyAfterEdit: '<p>EDITED designModeDocument</p>',
expectedBodyAfterSecondEdit: '<p>EDITED TWICE designModeDocument</p>',
expectedBodyBeforeEdit: "<p>designModeDocument</p>",
expectedBodyAfterEdit: "<p>EDITED designModeDocument</p>",
expectedBodyAfterSecondEdit: "<p>EDITED TWICE designModeDocument</p>",
},
{
// <html><body contentEditable="true"><p>contentEditable</p></body></html>
url: "file_bug386782_contenteditable.html",
name: 'contentEditableNavigate',
expectedBodyBeforeEdit: '<p>contentEditable</p>',
expectedBodyAfterEdit: 'EDITED <br><p>contentEditable</p>',
expectedBodyAfterSecondEdit: 'EDITED TWICE <br><p>contentEditable</p>',
}
name: "contentEditableNavigate",
expectedBodyBeforeEdit: "<p>contentEditable</p>",
expectedBodyAfterEdit: "EDITED <br><p>contentEditable</p>",
expectedBodyAfterSecondEdit: "EDITED TWICE <br><p>contentEditable</p>",
},
];
var gTestNum = -1;
@ -66,10 +66,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
// WARNING: If the following test fails, give the setTimeout() in the onload()
// a bit longer; the doc hasn't had enough time to setup its editor.
is(gTest.window.document.body.innerHTML, gTest.expectedBodyBeforeEdit, "Is doc setup yet");
sendString('EDITED ', gTest.window);
sendString("EDITED ", gTest.window);
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Editing failed.");
gTest.window.location = 'about:blank';
gTest.window.location = "about:blank";
SimpleTest.waitForFocus(goBack, gTest.window);
}
@ -101,7 +101,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
// Check that we can still edit the page.
gTest.window.document.body.focus();
sendString('TWICE ', gTest.window);
sendString("TWICE ", gTest.window);
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterSecondEdit, "Can we still edit?");
gTest.window.close();

View File

@ -37,7 +37,7 @@ function onReload() {
function doTest() {
var bodyElement = window.frames[0].frameElement.contentDocument.body;
bodyElement.focus();
sendString('Still ', window.frames[0].frameElement.contentWindow);
sendString("Still ", window.frames[0].frameElement.contentWindow);
is(bodyElement.innerHTML, "Still contentEditable", "Check we're contentEditable after reload");

View File

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=430723
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
//<![CDATA[
// <![CDATA[
/** Test for Bug 430723 **/
@ -32,47 +32,47 @@ var testNum = 0;
var smoothScrollPref = "general.smoothScroll";
function runTest() {
SpecialPowers.pushPrefEnv({"set":[[smoothScrollPref, false]]}, function(){
SpecialPowers.pushPrefEnv({"set": [[smoothScrollPref, false]]}, function() {
testWindow = window.open(gTallRedBoxURI, "testWindow", "width=300,height=300,location=yes,scrollbars=yes");
});
}
var nextTest =function() {
var nextTest = function() {
testNum++;
switch (testNum) {
case 1: setTimeout(step1, 0); break;
case 2: setTimeout(step2, 0); break;
case 3: setTimeout(step3, 0); break;
};
}
}
};
var step1 =function() {
var step1 = function() {
window.is(String(testWindow.location), gTallRedBoxURI, "Ensure red page loaded.");
// Navigate down and up.
is(testWindow.document.body.scrollTop, 0,
"Page1: Ensure the scrollpane is at the top before we start scrolling.");
testWindow.addEventListener("scroll", function () {
testWindow.addEventListener("scroll", function() {
isnot(testWindow.document.body.scrollTop, 0,
"Page1: Ensure we can scroll down.");
SimpleTest.executeSoon(step1_2);
}, {capture: true, once: true});
sendKey('DOWN', testWindow);
sendKey("DOWN", testWindow);
function step1_2() {
testWindow.addEventListener("scroll", function () {
testWindow.addEventListener("scroll", function() {
is(testWindow.document.body.scrollTop, 0,
"Page1: Ensure we can scroll up, back to the top.");
// Nav to blue box page. This should fire step2.
testWindow.location = gTallBlueBoxURI;
}, {capture: true, once: true});
sendKey('UP', testWindow);
sendKey("UP", testWindow);
}
}
};
var step2 =function() {
var step2 = function() {
window.is(String(testWindow.location), gTallBlueBoxURI, "Ensure blue page loaded.");
// Scroll around a bit.
@ -80,9 +80,9 @@ var step2 =function() {
"Page2: Ensure the scrollpane is at the top before we start scrolling.");
var count = 0;
testWindow.addEventListener("scroll", function () {
testWindow.addEventListener("scroll", function() {
if (++count < 2) {
SimpleTest.executeSoon(function () { sendKey('DOWN', testWindow); });
SimpleTest.executeSoon(function() { sendKey("DOWN", testWindow); });
} else {
testWindow.removeEventListener("scroll", arguments.callee, true);
@ -93,29 +93,29 @@ var step2 =function() {
testWindow.history.back();
}
}, true);
sendKey('DOWN', testWindow);
}
sendKey("DOWN", testWindow);
};
var step3 =function() {
var step3 = function() {
window.is(String(testWindow.location), gTallRedBoxURI,
"Ensure red page restored from history.");
// Check we can still scroll with the keys.
is(testWindow.document.body.scrollTop, 0,
"Page1Again: Ensure scroll pane at top before we scroll.");
testWindow.addEventListener("scroll", function () {
testWindow.addEventListener("scroll", function() {
isnot(testWindow.document.body.scrollTop, 0,
"Page2Again: Ensure we can still scroll.");
testWindow.close();
window.SimpleTest.finish();
}, {capture: true, once: true});
sendKey('DOWN', testWindow);
}
sendKey("DOWN", testWindow);
};
SimpleTest.waitForExplicitFinish();
//]]>
// ]]>
</script>
</pre>
</body>

View File

@ -28,7 +28,7 @@ window.onload = function() {
xpcCleanupWindows();
SimpleTest.finish();
}, 4);
}
};
</script>
</head>
<body>

View File

@ -36,6 +36,7 @@ var policyID = SpecialPowers.wrap(SpecialPowers.Components).ID("{b80e19d0-878f-d
var policyName = "@mozilla.org/testpolicy;1";
var policy = {
// nsISupports implementation
// eslint-disable-next-line mozilla/use-chromeutils-generatedqi.js
QueryInterface: function(iid) {
iid = SpecialPowers.wrap(iid);
if (iid.equals(Ci.nsISupports) ||
@ -46,12 +47,12 @@ var policy = {
},
// nsIFactory implementation
createInstance: function(outer, iid) {
createInstance(outer, iid) {
return this.QueryInterface(iid);
},
// nsIContentPolicy implementation
shouldLoad: function(contentLocation, loadInfo, mimeTypeGuess) {
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
let contentType = loadInfo.externalContentPolicyType;
let context = loadInfo.loadingContext;
@ -79,10 +80,10 @@ var policy = {
return Ci.nsIContentPolicy.REJECT_REQUEST;
},
shouldProcess: function(contentLocation, loadInfo, mimeTypeGuess) {
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
return Ci.nsIContentPolicy.ACCEPT;
}
}
},
};
policy = SpecialPowers.wrapCallbackObject(policy);
componentManager.registerFactory(policyID, "Test content policy", policyName, policy);
@ -91,7 +92,7 @@ categoryManager.addCategoryEntry("content-policy", policyName, policyName, false
SimpleTest.waitForExplicitFinish();
// now everything is set up, let's start the test
document.getElementById("testlink").click()
document.getElementById("testlink").click();
</script>
</body>

View File

@ -13,7 +13,7 @@ if (!navigator.platform.startsWith("Win")) {
SimpleTest.expectAssertions(0, 1);
}
window.onload = function () {
window.onload = function() {
navigateByLocation(frames[0].frames[0]);
navigateByOpen("child1_child0");
navigateByForm("child2_child0");
@ -28,7 +28,7 @@ window.onload = function () {
xpcCleanupWindows();
SimpleTest.finish();
}, 4);
}
};
</script>
</head>
<body>

View File

@ -13,8 +13,8 @@ if (!navigator.platform.startsWith("Win")) {
SimpleTest.expectAssertions(0, 1);
}
window.onload = function () {
//navigateByLocation(window0); // Don't have a handle to the window.
window.onload = function() {
// navigateByLocation(window0); // Don't have a handle to the window.
navigateByOpen("window1");
navigateByForm("window2");
navigateByHyperlink("window3");
@ -24,7 +24,7 @@ window.onload = function () {
is(xpcGetFramesByName("window2").length, 2, "Should not be able to navigate popup's popup by submitting form.");
is(xpcGetFramesByName("window3").length, 2, "Should not be able to navigate popup's popup by targeted hyperlink.");
//opener0.close();
// opener0.close();
opener1.close();
opener2.close();
opener3.close();
@ -32,9 +32,9 @@ window.onload = function () {
xpcCleanupWindows();
SimpleTest.finish();
}, 6);
}
};
//opener0 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window0", "_blank", "width=10,height=10");
// opener0 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window0", "_blank", "width=10,height=10");
opener1 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window1", "_blank", "width=10,height=10");
opener2 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window2", "_blank", "width=10,height=10");
opener3 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window3", "_blank", "width=10,height=10");

View File

@ -13,7 +13,7 @@ if (navigator.platform.startsWith("Linux")) {
SimpleTest.expectAssertions(0, 1);
}
window.onload = function () {
window.onload = function() {
navigateByLocation(window0);
navigateByOpen("window1");
navigateByForm("window2");
@ -33,7 +33,7 @@ window.onload = function () {
xpcCleanupWindows();
SimpleTest.finish();
}, 4);
}
};
var window0 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/blank.html", "window0", "width=10,height=10");
var window1 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/blank.html", "window1", "width=10,height=10");

View File

@ -84,7 +84,7 @@ function testParent() {
window.onload = function() {
testTop();
}
};
</script>
</head>
<body>

View File

@ -25,7 +25,7 @@ var testFiles =
"file_bug462076_3.html", // Dynamic frames after onload
"file_bug508537_1.html", // Dynamic frames and forward-back
"file_document_write_1.html", // Session history + document.write
//"file_static_and_dynamic_1.html",// Static and dynamic frames and forward-back
// "file_static_and_dynamic_1.html",// Static and dynamic frames and forward-back
"file_bug534178.html", // Session history entry clean-up.
"file_fragment_handling_during_load.html",
"file_nested_frames.html",
@ -48,7 +48,7 @@ function nextTest_() {
let nextFile = testFiles.shift();
info("Running " + nextFile);
testWindow = window.open(nextFile, "", "width=360,height=480");
testWindow.onunload = function () { } // to prevent bfcache
testWindow.onunload = function() { }; // to prevent bfcache
} else {
SimpleTest.finish();
}

View File

@ -9,8 +9,8 @@
iframe { width: 90%; height: 50px; }
</style>
<script>
window.onload = function () {
document.getElementById('active').innerHTML =
window.onload = function() {
document.getElementById("active").innerHTML =
'<iframe src="navigate.html#parent.frames[0],location"></iframe>' +
'<iframe src="navigate.html#child1,open"></iframe>' +
'<iframe src="navigate.html#child2,form"></iframe>' +
@ -25,7 +25,7 @@ window.onload = function () {
xpcCleanupWindows();
SimpleTest.finish();
}, 4);
}
};
</script>
</head>
<body>

View File

@ -9,8 +9,8 @@
iframe { width: 90%; height: 50px; }
</style>
<script>
window.onload = function () {
document.getElementById('active').innerHTML =
window.onload = function() {
document.getElementById("active").innerHTML =
'<iframe src="http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#parent.frames[0],location"></iframe>' +
'<iframe src="http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#child1,open"></iframe>' +
'<iframe src="http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#child2,form"></iframe>' +
@ -25,7 +25,7 @@ window.onload = function () {
xpcCleanupWindows();
SimpleTest.finish();
}, 4);
}
};
</script>
</head>
<body>

View File

@ -49,7 +49,7 @@ const LOADING_PRINCIPAL_URI =
var frameA = document.getElementById("framea");
function checkResults() {
frameA.removeEventListener('load', checkResults);
frameA.removeEventListener("load", checkResults);
var channel = SpecialPowers.wrap(frameA.contentWindow).docShell.currentDocumentChannel;
var triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
@ -68,8 +68,8 @@ function checkResults() {
}
function performNavigation() {
frameA.removeEventListener('load', performNavigation);
frameA.addEventListener('load', checkResults);
frameA.removeEventListener("load", performNavigation);
frameA.addEventListener("load", checkResults);
// load Frame B which then navigates Frame A
var frameB = document.getElementById("frameb");
@ -79,7 +79,7 @@ function performNavigation() {
// start the test
SimpleTest.waitForExplicitFinish();
frameA.addEventListener('load', performNavigation);
frameA.addEventListener("load", performNavigation);
</script>
</pre>

View File

@ -35,7 +35,7 @@ const LOADING_PRINCIPAL_URI = TRIGGERING_PRINCIPAL_URI;
var testframe = document.getElementById("testframe");
function checkResults() {
testframe.removeEventListener('load', checkResults);
testframe.removeEventListener("load", checkResults);
var channel = SpecialPowers.wrap(testframe.contentWindow).docShell.currentDocumentChannel;
var triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
@ -54,15 +54,15 @@ function checkResults() {
}
function performNavigation() {
testframe.removeEventListener('load', performNavigation);
testframe.addEventListener('load', checkResults);
testframe.removeEventListener("load", performNavigation);
testframe.addEventListener("load", checkResults);
win = window.open("file_triggeringprincipal_parent_iframe_window_open_nav.html", "testframe");
}
// start the test
SimpleTest.waitForExplicitFinish();
testframe.addEventListener('load', performNavigation);
testframe.addEventListener("load", performNavigation);
</script>
</pre>

View File

@ -50,7 +50,7 @@ httpWin.onload = function() {
httpWin.close();
checkFinish();
}
};
// ----------------------------------------------------------------------------
// Test 2: window.open(javascript:)
@ -71,7 +71,7 @@ jsWin.onload = function() {
jsWin.close();
checkFinish();
}
};
</script>
</pre>

View File

@ -8,62 +8,58 @@ var pref = "browser.fixup.typo.scheme";
var data = [
{
// ttp -> http.
wrong: 'ttp://www.example.com/',
fixed: 'http://www.example.com/',
wrong: "ttp://www.example.com/",
fixed: "http://www.example.com/",
},
{
// htp -> http.
wrong: 'htp://www.example.com/',
fixed: 'http://www.example.com/',
wrong: "htp://www.example.com/",
fixed: "http://www.example.com/",
},
{
// ttps -> https.
wrong: 'ttps://www.example.com/',
fixed: 'https://www.example.com/',
wrong: "ttps://www.example.com/",
fixed: "https://www.example.com/",
},
{
// tps -> https.
wrong: 'tps://www.example.com/',
fixed: 'https://www.example.com/',
wrong: "tps://www.example.com/",
fixed: "https://www.example.com/",
},
{
// ps -> https.
wrong: 'ps://www.example.com/',
fixed: 'https://www.example.com/',
wrong: "ps://www.example.com/",
fixed: "https://www.example.com/",
},
{
// htps -> https.
wrong: 'htps://www.example.com/',
fixed: 'https://www.example.com/',
wrong: "htps://www.example.com/",
fixed: "https://www.example.com/",
},
{
// ile -> file.
wrong: 'ile:///this/is/a/test.html',
fixed: 'file:///this/is/a/test.html',
wrong: "ile:///this/is/a/test.html",
fixed: "file:///this/is/a/test.html",
},
{
// le -> file.
wrong: 'le:///this/is/a/test.html',
fixed: 'file:///this/is/a/test.html',
wrong: "le:///this/is/a/test.html",
fixed: "file:///this/is/a/test.html",
},
{
// Valid should not be changed.
wrong: 'https://example.com/this/is/a/test.html',
fixed: 'https://example.com/this/is/a/test.html',
wrong: "https://example.com/this/is/a/test.html",
fixed: "https://example.com/this/is/a/test.html",
},
{
// Unmatched should not be changed.
wrong: 'whatever://this/is/a/test.html',
fixed: 'whatever://this/is/a/test.html',
wrong: "whatever://this/is/a/test.html",
fixed: "whatever://this/is/a/test.html",
},
];
var len = data.length;
function run_test() {
run_next_test();
}
// Make sure we fix what needs fixing when there is no pref set.
add_task(function test_unset_pref_fixes_typos() {
prefs.clearUserPref(pref);

View File

@ -49,7 +49,7 @@ flagInputs.concat([
flagInputs[0] | flagInputs[1],
flagInputs[1] | flagInputs[2],
flagInputs[0] | flagInputs[2],
flagInputs[0] | flagInputs[1] | flagInputs[2]
flagInputs[0] | flagInputs[1] | flagInputs[2],
]);
/*
@ -205,25 +205,25 @@ var testcases = [ {
input: "[64:ff9b::8.8.8.8]",
fixedURI: "http://[64:ff9b::808:808]/",
alternateURI: "http://[64:ff9b::808:808]/",
protocolChange: true
protocolChange: true,
}, {
input: "[64:ff9b::8.8.8.8]/~moz",
fixedURI: "http://[64:ff9b::808:808]/~moz",
alternateURI: "http://[64:ff9b::808:808]/~moz",
protocolChange: true
protocolChange: true,
}, {
input: "[::1][::1]",
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "[::1][100",
fixedURI: null,
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "[::1]]",
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "1234",
fixedURI: "http://0.0.4.210/",
@ -344,7 +344,7 @@ var testcases = [ {
input: "café.local",
fixedURI: "http://xn--caf-dma.local/",
alternateURI: "http://www.xn--caf-dma.local/",
protocolChange: true
protocolChange: true,
}, {
input: "47.6182,-122.830",
fixedURI: "http://47.6182,-122.830/",
@ -385,38 +385,38 @@ var testcases = [ {
}, {
input: "moz ?.::%27",
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "mozilla.com/?q=search",
fixedURI: "http://mozilla.com/?q=search",
alternateURI: "http://www.mozilla.com/?q=search",
protocolChange: true
protocolChange: true,
}, {
input: "mozilla.com?q=search",
fixedURI: "http://mozilla.com/?q=search",
alternateURI: "http://www.mozilla.com/?q=search",
protocolChange: true
protocolChange: true,
}, {
input: "mozilla.com ?q=search",
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "mozilla.com.?q=search",
fixedURI: "http://mozilla.com./?q=search",
protocolChange: true
protocolChange: true,
}, {
input: "mozilla.com'?q=search",
fixedURI: "http://mozilla.com'/?q=search",
alternateURI: "http://www.mozilla.com'/?q=search",
protocolChange: true
protocolChange: true,
}, {
input: "mozilla.com':search",
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "[mozilla]",
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "':?",
fixedURI: "http://'/?",
@ -435,7 +435,7 @@ var testcases = [ {
}, {
input: "' ?.com",
keywordLookup: true,
protocolChange: true
protocolChange: true,
}, {
input: "?mozilla",
keywordLookup: true,

View File

@ -37,61 +37,61 @@ var isWin = AppConstants.platform == "win";
var data = [
{
// Valid should not be changed.
wrong: 'https://example.com/this/is/a/test.html',
fixed: 'https://example.com/this/is/a/test.html',
wrong: "https://example.com/this/is/a/test.html",
fixed: "https://example.com/this/is/a/test.html",
},
{
// Unrecognized protocols should be changed.
wrong: 'whatever://this/is/a/test.html',
fixed: kSearchEngineURL.replace("{searchTerms}", encodeURIComponent('whatever://this/is/a/test.html')),
wrong: "whatever://this/is/a/test.html",
fixed: kSearchEngineURL.replace("{searchTerms}", encodeURIComponent("whatever://this/is/a/test.html")),
},
// The following tests check that when a user:password is present in the URL
// `user:` isn't treated as an unknown protocol thus leaking the user and
// password to the search engine.
{
wrong: 'user:pass@example.com/this/is/a/test.html',
fixed: 'http://user:pass@example.com/this/is/a/test.html',
wrong: "user:pass@example.com/this/is/a/test.html",
fixed: "http://user:pass@example.com/this/is/a/test.html",
},
{
wrong: 'user@example.com:8080/this/is/a/test.html',
fixed: 'http://user@example.com:8080/this/is/a/test.html',
wrong: "user@example.com:8080/this/is/a/test.html",
fixed: "http://user@example.com:8080/this/is/a/test.html",
},
{
wrong: 'https:pass@example.com/this/is/a/test.html',
fixed: 'https://pass@example.com/this/is/a/test.html',
wrong: "https:pass@example.com/this/is/a/test.html",
fixed: "https://pass@example.com/this/is/a/test.html",
},
{
wrong: 'user:pass@example.com:8080/this/is/a/test.html',
fixed: 'http://user:pass@example.com:8080/this/is/a/test.html',
wrong: "user:pass@example.com:8080/this/is/a/test.html",
fixed: "http://user:pass@example.com:8080/this/is/a/test.html",
},
{
wrong: 'http:user:pass@example.com:8080/this/is/a/test.html',
fixed: 'http://user:pass@example.com:8080/this/is/a/test.html',
wrong: "http:user:pass@example.com:8080/this/is/a/test.html",
fixed: "http://user:pass@example.com:8080/this/is/a/test.html",
},
{
wrong: 'ttp:user:pass@example.com:8080/this/is/a/test.html',
fixed: 'http://user:pass@example.com:8080/this/is/a/test.html',
wrong: "ttp:user:pass@example.com:8080/this/is/a/test.html",
fixed: "http://user:pass@example.com:8080/this/is/a/test.html",
},
{
wrong: 'gobbledygook:user:pass@example.com:8080/this/is/a/test.html',
fixed: 'http://gobbledygook:user%3Apass@example.com:8080/this/is/a/test.html',
wrong: "gobbledygook:user:pass@example.com:8080/this/is/a/test.html",
fixed: "http://gobbledygook:user%3Apass@example.com:8080/this/is/a/test.html",
},
{
wrong: 'user:@example.com:8080/this/is/a/test.html',
fixed: 'http://user@example.com:8080/this/is/a/test.html',
wrong: "user:@example.com:8080/this/is/a/test.html",
fixed: "http://user@example.com:8080/this/is/a/test.html",
},
{
wrong: '//user:pass@example.com:8080/this/is/a/test.html',
fixed: (isWin ? "http:" : "file://") + '//user:pass@example.com:8080/this/is/a/test.html',
wrong: "//user:pass@example.com:8080/this/is/a/test.html",
fixed: (isWin ? "http:" : "file://") + "//user:pass@example.com:8080/this/is/a/test.html",
},
{
wrong: '://user:pass@example.com:8080/this/is/a/test.html',
fixed: 'http://user:pass@example.com:8080/this/is/a/test.html',
wrong: "://user:pass@example.com:8080/this/is/a/test.html",
fixed: "http://user:pass@example.com:8080/this/is/a/test.html",
},
{
wrong: 'whatever://this/is/a@b/test.html',
fixed: kSearchEngineURL.replace("{searchTerms}", encodeURIComponent('whatever://this/is/a@b/test.html')),
wrong: "whatever://this/is/a@b/test.html",
fixed: kSearchEngineURL.replace("{searchTerms}", encodeURIComponent("whatever://this/is/a@b/test.html")),
},
];
@ -101,14 +101,10 @@ var extProtocolSvc = Cc["@mozilla.org/uriloader/external-protocol-service;1"]
if (extProtocolSvc && extProtocolSvc.externalProtocolHandlerExists("mailto")) {
data.push({
wrong: "mailto:foo@bar.com",
fixed: "mailto:foo@bar.com"
fixed: "mailto:foo@bar.com",
});
}
function run_test() {
run_next_test();
}
var len = data.length;
// Make sure we fix what needs fixing
add_task(function test_fix_unknown_schemes() {

View File

@ -1,6 +1,6 @@
function destroy_transient_docshell() {
let windowlessBrowser = Services.appShell.createWindowlessBrowser(false);
windowlessBrowser.docshell.setOriginAttributes({privateBrowsingId : 1});
windowlessBrowser.docshell.setOriginAttributes({privateBrowsingId: 1});
windowlessBrowser.close();
do_test_pending();
do_timeout(0, Cu.forceGC);
@ -8,10 +8,10 @@ function destroy_transient_docshell() {
function run_test() {
var obs = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
Assert.equal(aTopic, "last-pb-context-exited");
do_test_finished();
}
},
};
var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
os.addObserver(obs, "last-pb-context-exited");

View File

@ -3,24 +3,18 @@ var gNotifications = 0;
ChromeUtils.import("resource://gre/modules/Services.jsm");
var observer = {
QueryInterface: function(iid) {
if (Ci.nsIPrivacyTransitionObserver.equals(iid) ||
Ci.nsISupportsWeakReference.equals(iid) ||
Ci.nsISupports.equals(iid))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI(["nsIPrivacyTransitionObserver", "nsISupportsWeakReference"]),
privateModeChanged: function(enabled) {
privateModeChanged(enabled) {
gNotifications++;
}
}
},
};
function run_test() {
let windowlessBrowser = Services.appShell.createWindowlessBrowser(false);
windowlessBrowser.docShell.addWeakPrivacyTransitionObserver(observer);
windowlessBrowser.docShell.setOriginAttributes({privateBrowsingId : 1});
windowlessBrowser.docShell.setOriginAttributes({privateBrowsingId : 0});
windowlessBrowser.docShell.setOriginAttributes({privateBrowsingId: 1});
windowlessBrowser.docShell.setOriginAttributes({privateBrowsingId: 0});
windowlessBrowser.close();
Assert.equal(gNotifications, 2);
}

View File

@ -1,10 +1,10 @@
function run_test() {
var notifications = 0;
var obs = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
Assert.equal(aTopic, "last-pb-context-exited");
notifications++;
}
},
};
var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
os.addObserver(obs, "last-pb-context-exited");