Skip to content

Commit

Permalink
Bug 863246 - Fix test failures r=Gijs
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 8tUr27zvs8z
  • Loading branch information
Chung-Sheng Fu committed Jul 19, 2017
1 parent 414b93a commit e4f770c
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ var whitelist = [
{file: "resource://gre/modules/accessibility/AccessFu.jsm"},
// Bug 1351637
{file: "resource://gre/modules/sdk/bootstrap.js"},

];

whitelist = new Set(whitelist.filter(item =>
Expand Down Expand Up @@ -478,7 +477,8 @@ function findChromeUrlsFromArray(array, prefix) {

// Only keep strings that look like real chrome or resource urls.
if (/chrome:\/\/[a-zA-Z09 -]+\/(content|skin|locale)\//.test(string) ||
/resource:\/\/gre.*\.[a-z]+/.test(string))
/resource:\/\/gre.*\.[a-z]+/.test(string) ||
string.startsWith("resource://content-accessible/"))
gReferencesFromCode.add(string);
}
}
Expand Down Expand Up @@ -540,6 +540,8 @@ add_task(async function checkAllTheFiles() {
let devtoolsPrefixes = ["chrome://webide/",
"chrome://devtools",
"resource://devtools/",
"resource://devtools-client-jsonview/",
"resource://devtools-client-shared/",
"resource://app/modules/devtools",
"resource://gre/modules/devtools"];
let chromeFiles = [];
Expand Down
60 changes: 34 additions & 26 deletions browser/base/content/test/static/browser_parsable_css.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let whitelist = [
{sourceName: /devtools\/client\/debugger\/new\/debugger.css/i,
isFromDevTools: true},
// Reps uses cross-browser CSS.
{sourceName: /devtools\/client\/shared\/components\/reps\/reps.css/i,
{sourceName: /devtools-client-shared\/components\/reps\/reps.css/i,
isFromDevTools: true},
// PDFjs is futureproofing its pseudoselectors, and those rules are dropped.
{sourceName: /web\/viewer\.css$/i,
Expand Down Expand Up @@ -288,41 +288,49 @@ add_task(async function checkAllTheCSS() {
// Wait for all manifest to be parsed
await Promise.all(manifestPromises);

// We build a list of promises that get resolved when their respective
// files have loaded and produced no errors.
let allPromises = [];

// filter out either the devtools paths or the non-devtools paths:
let isDevtools = SimpleTest.harnessParameters.subsuite == "devtools";
let devtoolsPathBits = ["webide", "devtools"];
uris = uris.filter(uri => isDevtools == devtoolsPathBits.some(path => uri.spec.includes(path)));

for (let uri of uris) {
let linkEl = doc.createElement("link");
let loadCSS = chromeUri => new Promise(resolve => {
let linkEl, onLoad, onError;
onLoad = e => {
processCSSRules(linkEl.sheet);
resolve();
linkEl.removeEventListener("load", onLoad);
linkEl.removeEventListener("error", onError);
};
onError = e => {
ok(false, "Loading " + linkEl.getAttribute("href") + " threw an error!");
resolve();
linkEl.removeEventListener("load", onLoad);
linkEl.removeEventListener("error", onError);
};
linkEl = doc.createElement("link");
linkEl.setAttribute("rel", "stylesheet");
allPromises.push(new Promise(resolve => {
let onLoad = (e) => {
processCSSRules(linkEl.sheet);
resolve();
linkEl.removeEventListener("load", onLoad);
linkEl.removeEventListener("error", onError);
};
let onError = (e) => {
ok(false, "Loading " + linkEl.getAttribute("href") + " threw an error!");
resolve();
linkEl.removeEventListener("load", onLoad);
linkEl.removeEventListener("error", onError);
};
linkEl.addEventListener("load", onLoad);
linkEl.addEventListener("error", onError);
linkEl.setAttribute("type", "text/css");
let chromeUri = convertToCodeURI(uri.spec);
linkEl.setAttribute("href", chromeUri + kPathSuffix);
}));
linkEl.setAttribute("type", "text/css");
linkEl.addEventListener("load", onLoad);
linkEl.addEventListener("error", onError);
linkEl.setAttribute("href", chromeUri + kPathSuffix);
doc.head.appendChild(linkEl);
});

// We build a list of promises that get resolved when their respective
// files have loaded and produced no errors.
const kInContentCommonCSS = "chrome://global/skin/in-content/common.css";
let allPromises = uris.map((uri) => convertToCodeURI(uri.spec))
.filter((uri) => uri !== kInContentCommonCSS);

// Make sure chrome://global/skin/in-content/common.css is loaded before other
// stylesheets in order to guarantee the --in-content variables can be
// correctly referenced.
if (allPromises.length !== uris.length) {
await loadCSS(kInContentCommonCSS);
}

// Wait for all the files to have actually loaded:
allPromises = allPromises.map(loadCSS);
await Promise.all(allPromises);

// Check if all the files referenced from CSS actually exist.
Expand Down
7 changes: 6 additions & 1 deletion caps/tests/mochitest/test_bug292789.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@
}

// Start off the script src test, and have it start the img tests when complete.
testScriptSrc(runImgTest);
// Temporarily allow content to access all resource:// URIs.
SpecialPowers.pushPrefEnv({
set: [
["security.all_resource_uri_content_accessible", true]
]
}, () => testScriptSrc(runImgTest));
</script>
</pre>
</body>
Expand Down
25 changes: 20 additions & 5 deletions devtools/shared/platform/content/test/test_clipboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
"use strict";
var exports = {}
</script>

<script type="application/javascript"
src="resource://devtools/shared/platform/content/clipboard.js"></script>

</head>
<body onload="do_tests()">
<body onload="pre_do_tests()">
<script type="application/javascript">
"use strict";

Expand All @@ -31,6 +27,25 @@
copyString(RESULT);
}

async function pre_do_tests() {
// Temporarily allow content to access all resource:// URIs.
await SpecialPowers.pushPrefEnv({
set: [
["security.all_resource_uri_content_accessible", true]
]
});

// Load script.
await (() => new Promise((resolve) => {
var script = document.createElement("script");
script.onload = resolve;
script.src = "resource://devtools/shared/platform/content/clipboard.js";
document.head.appendChild(script);
}))();

do_tests();
}

function do_tests() {
let elt = document.querySelector("#key");
elt.addEventListener("keydown", doCopy);
Expand Down
7 changes: 5 additions & 2 deletions dom/security/test/mixedcontentblocker/test_bug803225.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@

//Cycle through 4 different preference settings.
function changePrefs(callback) {
let newPrefs = [["security.mixed_content.block_display_content", settings[counter][0]],
["security.mixed_content.block_active_content", settings[counter][1]]];
let newPrefs = [
["security.all_resource_uri_content_accessible", true], // Temporarily allow content to access all resource:// URIs.
["security.mixed_content.block_display_content", settings[counter][0]],
["security.mixed_content.block_active_content", settings[counter][1]]
];

SpecialPowers.pushPrefEnv({"set": newPrefs}, function () {
blockDisplay = SpecialPowers.getBoolPref("security.mixed_content.block_display_content");
Expand Down
2 changes: 1 addition & 1 deletion parser/htmlparser/tests/reftest/bug482921-1-ref.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
<span id></span><span>&lt;<span class="start-tag">html</span>&gt;</span>
<span id></span><span>&lt;<span class="start-tag">head</span>&gt;</span>
<span id></span><span>&lt;<span class="start-tag">title</span>&gt;</span><span>Title</span><span>&lt;/<span class="end-tag">title</span>&gt;</span>
Expand Down
2 changes: 1 addition & 1 deletion parser/htmlparser/tests/reftest/bug482921-2-ref.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span id></span><span class="pi">&lt;?foo bar?&gt;</span>
<span id></span><span>&lt;<span class="start-tag">html</span>&gt;</span>
<span id></span><span>&lt;<span class="start-tag">head</span>&gt;</span>
Expand Down
2 changes: 1 addition & 1 deletion parser/htmlparser/tests/reftest/bug535530-2-ref.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
<span id></span>XX<span class="error">&amp;</span>XX
<span id></span>XX<span class="error">&amp;</span>nXX
<span id></span>XX<span class="error">&amp;</span>noXX
Expand Down
2 changes: 1 addition & 1 deletion parser/htmlparser/tests/reftest/bug704667-1-ref.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="error comment">&lt;!--&gt;</span> <span class="error comment">&lt;!X&gt;</span>
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="error comment">&lt;!--&gt;</span> <span class="error comment">&lt;!X&gt;</span>
<span id></span>
</pre>
<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
2 changes: 1 addition & 1 deletion parser/htmlparser/tests/reftest/bug731234-1-ref.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
<span id></span></span><span>&lt;<span class="start-tag">body</span>&gt;</span><span>
<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span> &gt;</span><span>X
Expand Down
2 changes: 1 addition & 1 deletion parser/htmlparser/tests/reftest/bug910588-1-ref.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="highlight" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span>&lt;<span class="start-tag">table</span>&gt;</span><span></span><span title="Start tag “input” seen in “table”." class="error">&lt;<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>&gt;</span><span></span><span>&lt;/<span class="end-tag">table</span>&gt;</span><span>
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span>&lt;<span class="start-tag">table</span>&gt;</span><span></span><span title="Start tag “input” seen in “table”." class="error">&lt;<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>&gt;</span><span></span><span>&lt;/<span class="end-tag">table</span>&gt;</span><span>
<span id="line2"></span></span></pre></body></html>

0 comments on commit e4f770c

Please sign in to comment.