diff --git a/dom/quota/test/unit/head-shared.js b/dom/quota/test/unit/head-shared.js index 991ead6b6bc6..41fccb2f82d8 100644 --- a/dom/quota/test/unit/head-shared.js +++ b/dom/quota/test/unit/head-shared.js @@ -316,6 +316,12 @@ function getRelativeFile(relativePath, baseFile) { } let file = baseFile.clone(); + + if (Services.appinfo.OS === "WINNT") { + let winFile = file.QueryInterface(Ci.nsILocalFileWin); + winFile.useDOSDevicePathSyntax = true; + } + relativePath.split("/").forEach(function(component) { if (component == "..") { file = file.parent; diff --git a/dom/quota/test/unit/test_validOrigins.js b/dom/quota/test/unit/test_validOrigins.js index ad0d742a1537..8797b9799fff 100644 --- a/dom/quota/test/unit/test_validOrigins.js +++ b/dom/quota/test/unit/test_validOrigins.js @@ -8,29 +8,82 @@ // exception (and potentially MOZ_ASSERT under debug builds). Handling of // obsolete or invalid origins is handled in other test files. async function testSteps() { - const testingURLs = [ + const basePath = "storage/default/"; + const longExampleOriginSubstring = "a".repeat( + 255 - "https://example..com".length + ); + const origins = [ // General - "https://example.com", - "https://smaug----.github.io/", + { + dirName: "https+++example.com", + url: "https://example.com", + }, + { + dirName: "https+++smaug----.github.io", + url: "https://smaug----.github.io/", + }, // About - "about:home", - "about:reader", + { + dirName: "about+home", + url: "about:home", + }, + { + dirName: "about+reader", + url: "about:reader", + }, // IPv6 - "https://[::]", - "https://[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]", - "http://[2010:836B:4179::836B:4179]:80", - "https://[::FFFF:129.144.52.38]", + { + dirName: "https+++[++]", + url: "https://[::]", + }, + { + dirName: "https+++[ffff+ffff+ffff+ffff+ffff+ffff+ffff+ffff]", + url: "https://[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]", + }, + { + dirName: "http+++[2010+836b+4179++836b+4179]", + url: "http://[2010:836B:4179::836B:4179]:80", + }, + { + dirName: "https+++[++ffff+8190+3426]", + url: "https://[::FFFF:129.144.52.38]", + }, + // MAX_PATH on Windows (260); storage/default/https+++example.{a....a}.com + // should have already exceeded the MAX_PATH limitation on Windows. + // There is a limitation (255) for each component on Windows so that we can + // only let the component be 255 chars and expect the wwhole path to be + // greater then 260. + { + dirName: `https+++example.${longExampleOriginSubstring}.com`, + url: `https://example.${longExampleOriginSubstring}.com`, + }, + // EndingWithPeriod + { + dirName: "https+++example.com.", + url: "https://example.com.", + }, ]; - for (let testingURL of testingURLs) { - info("Testing " + testingURL); + for (let origin of origins) { + info(`Testing ${origin.url}`); + try { - let request = initStorageAndOrigin(getPrincipal(testingURL), "default"); + let request = initStorageAndOrigin(getPrincipal(origin.url), "default"); await requestFinished(request); ok(true, "Should not have thrown"); } catch (ex) { ok(false, "Should not have thrown"); } + + let dir = getRelativeFile(basePath + origin.dirName); + ok(dir.exists(), "Origin was created"); + ok( + origin.dirName === dir.leafName, + `Origin ${origin.dirName} was created expectedly` + ); } + + let request = clear(); + await requestFinished(request); }