Skip to content

Instantly share code, notes, and snippets.

@ekashida
Created May 6, 2013 16:57
Show Gist options
  • Save ekashida/5526392 to your computer and use it in GitHub Desktop.
Save ekashida/5526392 to your computer and use it in GitHub Desktop.
[echo/status/404?hack.css] Checking if the onload and onerror events fire for link tags on Android 2.3.4
<!doctype html>
<head>
<style>
#good,
#bad {
font-size: 30px;
width: 300px;
height:150px;
}
</style>
<script src="http://3vnx.localtunnel.com/target/target-script-min.js"></script>
<script src="http://yui.yahooapis.com/3.10.0/build/yui/yui-min.js"></script>
</head>
<body>
<h1>Testing invalid CSS resource "echo/status/404?hack.css" on Android 2.3.4</h1>
<button id="good">VALID CSS</button>
<button id="bad">INVALID CSS</button>
</body>
</html>
YUI().use('node', function (Y) {
Y.one('#good').on('click', function (e) {
var good = Y.Node.create('<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">');
good._node.onerror = function () {
console.log('[FAILURE] onerror should not be called when a valid link resource is specified');
};
good._node.onload = function () {
console.log('[SUCCESS] onload called as expected when a valid link resource is specified');
};
Y.one('head').append(good);
console.log('clicked on good');
});
Y.one('#bad').on('click', function (e) {
var bad = Y.Node.create('<link rel="stylesheet" type="text/css" href="echo/status/404?hack.css">');
bad._node.onerror = function () {
console.log('[SUCCESS] onerror called as expected when an invalid link is specified');
};
bad._node.onload = function () {
console.log('[FAILURE] onload should not be called when an invalid link is specified');
};
Y.one('head').append(bad);
console.log('clicked on bad');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment