Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/tests/policy.js

Issue 29324570: Noissue - Fix SVG unit tests (Closed)
Patch Set: Created Aug. 25, 2015, 11:50 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/tests/policy.js
===================================================================
--- a/chrome/content/tests/policy.js
+++ b/chrome/content/tests/policy.js
@@ -60,16 +60,18 @@
let publickey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl/wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ";
/**
* Content:
* /test\0127.0.0.1:1234\0Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0
*/
let adblockkey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALZc50pEXnz9TSRozwM04rryuaXl/wgUFqV9FHq8HDlkdKvRU0hXhb/AKrSpCJ0NCxHtal1l/kHYlHG9e7Ev6+MCAwEAAQ==_gM4C/j8KkD2byPeP+THXk1GbLTUm5y+5jbdhcMtnzPMgImIfge0dGCtfU9cxLpe8BnqnEGNhTxpuu4pZxjOHYQ==";
+ let dispatchReadyEvent = "document.dispatchEvent(new CustomEvent('abp:frameready', {bubbles: true}));";
+
let tests = [
[
"HTML image with relative URL",
'<img src="test.gif">',
"http://127.0.0.1:1234/test.gif", "image", false, false
],
[
"HTML image with absolute URL",
@@ -97,17 +99,17 @@
'<script>' +
'window.addEventListener("DOMContentLoaded", function()' +
'{' +
'var div = document.getElementById("insert");' +
'div.innerHTML = \'<input type="image" id="image" src="test.gif">\';' +
'var image = document.getElementById("image");' +
'image.onload = image.onerror = function ()' +
'{' +
- 'document.dispatchEvent(new CustomEvent("abp:frameready", {bubbles: true}));' +
+ dispatchReadyEvent +
'};' +
'}, false);' +
'</script>',
"http://127.0.0.1:1234/test.gif", "image", false, true
],
[
"CSS background-image",
'<div style="background-image: url(test.gif)"></div>',
@@ -212,29 +214,28 @@
'}' +
'catch(e){}' +
'</script>',
"http://127.0.0.1:1234/test.xml", "xmlhttprequest", false, false
],
[
"Web worker",
'<script>' +
- 'var e = new CustomEvent(\'abp:frameready\', {bubbles: true});' +
'try' +
'{' +
'var worker = new Worker("test.js");' +
'worker.onerror = function(event)' +
'{' +
'event.preventDefault();' +
- 'document.dispatchEvent(e);' +
+ dispatchReadyEvent +
'};' +
'}' +
- 'catch (x)' +
+ 'catch (e)' +
'{' +
- 'document.dispatchEvent(e);' +
+ dispatchReadyEvent +
'}' +
'</script>',
"http://127.0.0.1:1234/test.js", "script", false, true
],
];
if (window.navigator.mimeTypes["application/x-shockwave-flash"] && window.navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
{
@@ -304,23 +305,24 @@
defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$~document"));
if (stage == 5)
defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document,sitekey=" + publickey));
if (!explicitEvent)
{
if (body.indexOf("2000/svg") >= 0)
{
- // SVG image: add an onload attribute to the document element
- body = body.replace(/(<svg\b)/, '$1 onload="this.dispatchEvent(new CustomEvent(\'abp:frameready\', {bubbles: true}));"');
+ // SVG image: add an onload attribute to the document element and keep
+ // polling until the document is really loaded.
+ body = body.replace(/(<svg\b)/, '$1 onload="if (document.readyState != \'complete\') setTimeout(arguments.callee.bind(this), 0); else ' + dispatchReadyEvent + '"');
}
else
{
// HTML data: wrap it into a <body> tag
- body = '<body onload="this.dispatchEvent(new CustomEvent(\'abp:frameready\', {bubbles: true}));">' + body + '</body>';
+ body = '<body onload="' + dispatchReadyEvent + '">' + body + '</body>';
}
}
let serverHit = false;
server.registerPathHandler("/test", function(metadata, response)
{
response.setStatusLine("1.1", "200", "OK");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld