forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1699892 - Allow the Firefox Accounts avatar server to use SVG con…
…text properties. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D111169
- Loading branch information
1 parent
430c8d5
commit 9278500
Showing
7 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- | ||
Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ | ||
--> | ||
<style> | ||
img { | ||
-moz-context-properties: fill; | ||
fill: green; | ||
} | ||
</style> | ||
<img src="file_context_fill_fallback_red.svg" style="width: 100px; height: 100px;"/> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
layout/svg/tests/test_context_properties_allowed_domains.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Bug 1699892 - SVG context properties for allowed domains</title> | ||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<script src="/tests/SimpleTest/WindowSnapshot.js"></script> | ||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> | ||
<script> | ||
|
||
/** | ||
* Returns a Promise that resolves when target fires a load event. | ||
*/ | ||
function waitForLoad(target) { | ||
return new Promise(resolve => { | ||
target.addEventListener("load", () => { | ||
if (event.target == target) { | ||
resolve(); | ||
}}, { once: true }); | ||
}); | ||
} | ||
|
||
/** | ||
* Given an iframe, loads src in it, and waits for the load event | ||
* for the iframe to fire. Then it snapshots the iframe and returns | ||
* the snapshot. | ||
* | ||
* src can be a URL starting with http, or is otherwise assumed to be | ||
* a srcdoc string. | ||
*/ | ||
async function loadSrcImageAndSnapshot(frame, src) { | ||
frame.removeAttribute("src"); | ||
frame.removeAttribute("srcdoc"); | ||
|
||
if (!src.startsWith("http")) { | ||
frame.srcdoc = src; | ||
} else { | ||
frame.src = src; | ||
} | ||
await waitForLoad(frame); | ||
return await snapshotWindow(frame, false); | ||
} | ||
|
||
add_task(async () => { | ||
const ALLOWED_DOMAIN = "example.org"; | ||
const DISALLOWED_DOMAIN = "example.com"; | ||
|
||
const CONTEXT_FILL_SVG = "tests/layout/svg/tests/file_context_fill_fallback_red.html"; | ||
const ALLOWED = `http://${ALLOWED_DOMAIN}/${CONTEXT_FILL_SVG}`; | ||
const DISALLOWED = `http://${DISALLOWED_DOMAIN}/${CONTEXT_FILL_SVG}`; | ||
|
||
await SpecialPowers.pushPrefEnv({ | ||
set: [["svg.context-properties.content.allowed-domains", ALLOWED_DOMAIN]] | ||
}); | ||
|
||
let frame = document.getElementById("frame"); | ||
|
||
// When the context properties are allowed, we expect a green square. When they are | ||
// not allowed, we expected a red square. | ||
|
||
let redReference = await loadSrcImageAndSnapshot( | ||
frame, | ||
`<div style="width: 100px; height: 100px; background: red"></div>` | ||
); | ||
|
||
let greenReference = await loadSrcImageAndSnapshot( | ||
frame, | ||
`<div style="width: 100px; height: 100px; background: green"></div>` | ||
); | ||
|
||
let allowedSnapshot = await loadSrcImageAndSnapshot(frame, ALLOWED); | ||
let disallowedSnapshot = await loadSrcImageAndSnapshot(frame, DISALLOWED); | ||
|
||
let result = compareSnapshots(redReference, greenReference, false); | ||
ok(result[0], "First, ensure that red and green do not match."); | ||
|
||
result = compareSnapshots(allowedSnapshot, greenReference, true); | ||
ok(result[0], "The allowed domain should show green."); | ||
|
||
result = compareSnapshots(disallowedSnapshot, redReference, true); | ||
ok(result[0], "The disallowed domain should show red."); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<iframe id="frame"></iframe> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters