This repository has been archived by the owner on Jan 10, 2020. It is now read-only.
forked from apm/yui-caja
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Moore
committed
May 18, 2009
0 parents
commit 86b67ee
Showing
5 changed files
with
484 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cajoled/ | ||
logs/ | ||
.DS_Store | ||
.*.swp | ||
.svn | ||
CVS/ |
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,120 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<script> | ||
|
||
YAHOO.log = cajita.log; | ||
|
||
var L = YAHOO.lang; | ||
|
||
cajita.log('start: ' + navigator.userAgent); | ||
|
||
YAHOO.util.Event.onAvailable("div1", function(e) { | ||
cajita.log(this.id + " available"); | ||
}); | ||
|
||
// @BUG {Caja} no DOMReady event fires | ||
YAHOO.util.Event.onDOMReady(function(e) { | ||
cajita.log("DOMReady"); | ||
}); | ||
|
||
// @BUG {Caja} no window load event fires | ||
YAHOO.util.Event.on(window, "load", function(e) { | ||
cajita.log("YUI window load"); | ||
}); | ||
|
||
window.addEventListener("load", function(e) { | ||
cajita.log("native window load"); | ||
}, false); | ||
|
||
// @BUG {Caja} fake document must do something with event listeners | ||
// to get a number of things to work. | ||
YAHOO.util.Event.on(document, "click", function(e) { | ||
cajita.log("document.click"); | ||
}); | ||
|
||
YAHOO.util.Event.addListener("div1", "click", function(e) { | ||
var target = YAHOO.util.Event.getTarget(e); | ||
cajita.log(target.id + " clicked: " + YAHOO.util.Event.getXY(e)); | ||
}); | ||
|
||
var data = { | ||
a: "data" | ||
}; | ||
|
||
var context = { | ||
a: "context" | ||
}; | ||
|
||
YAHOO.util.Event.on("div2", "click", function(e, data) { | ||
cajita.log("data obj and context adjust: " + data.a + ": " + this.a); | ||
}, data, context); | ||
|
||
cajita.log("isArray []: " + L.isArray([])); | ||
cajita.log("isArray {}: " + L.isArray({})); | ||
|
||
// @KNOWNISSUE HTMLElement collections are arrays in Caja, and not live lists | ||
cajita.log("isArray element collection: " + L.isArray(document.getElementsByTagName('div'))); | ||
|
||
// @KNOWNISSUE arguments collections are arrays in Caja rather than an array-like collection | ||
function(arg1, arg2) { | ||
cajita.log("isArray arguments collection: " + L.isArray(arguments)); | ||
}(1, 2); | ||
|
||
// @BUG {Caja} The user agent string needs to provide the information about | ||
// browser hosting the caja runtime. | ||
cajita.log("UA: " + L.dump(YAHOO.env.ua, 0)); | ||
|
||
var ns = YAHOO.namespace('NEW_NAMESPACE.foo'); | ||
cajita.log("namepace + dump: " + L.dump(YAHOO, 0)); | ||
|
||
cajita.log("Dom.get('div1'): " + YAHOO.util.Dom.get('div1')); | ||
|
||
var Animal = function() { | ||
this.createEvent('myEvent'); | ||
this.subscribe('myEvent', this.handler, 'is an animal'); | ||
}; | ||
|
||
Animal.prototype.handler = function(arg) { | ||
cajita.log('Animal'); | ||
}; | ||
|
||
YAHOO.augment(Animal, YAHOO.util.EventProvider); | ||
|
||
var Dog = function() { | ||
Animal.prototype.constructor.apply(this, arguments); | ||
}; | ||
|
||
YAHOO.extend(Dog, Animal, { | ||
handler: function() { | ||
cajita.log('Dog: ' + arguments); | ||
} | ||
}); | ||
|
||
var Cat = function() { | ||
Animal.prototype.constructor.apply(this, arguments); | ||
}; | ||
|
||
YAHOO.extend(Cat, Animal, { | ||
handler: function() { | ||
cajita.log('Cat: ' + arguments); | ||
} | ||
}); | ||
|
||
var d = new Dog(), c = new Cat(); | ||
|
||
d.fireEvent('myEvent', 'the dog'); | ||
c.fireEvent('myEvent', 'the cat'); | ||
|
||
cajita.log('end'); | ||
|
||
</script> | ||
|
||
<div class="div1">div1</div> | ||
<div class="div2">div2</div> | ||
|
||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
<html> | ||
<head> | ||
<title>YUI/Caja Host Page</title> | ||
|
||
<!-- In ant-lib/com/google/caja/plugin/ --> | ||
<script src="../../google-caja/ant-lib/com/google/caja/plugin/html-sanitizer-minified.js"></script> | ||
|
||
<script src="../../google-caja/ant-www/testbed/cajita.js"></script> | ||
<!-- | ||
--> | ||
<script src="../../google-caja/ant-www/testbed/cajita-debugmode.js"></script> | ||
<script src="../../google-caja/ant-www/testbed/unicode.js"></script> | ||
|
||
<script src="../../google-caja/ant-www/testbed/html-emitter.js"></script> | ||
<script src="../../google-caja/ant-www/testbed/bridal.js"></script> | ||
<script src="../../google-caja/ant-www/testbed/domita.js"></script> | ||
|
||
|
||
<script src="../../google-caja/ant-www/testbed/log-to-console.js"></script> | ||
|
||
<script> | ||
(function(){ | ||
// Give the module a variable into which it can export the valija maker | ||
var imports = ___.copy(___.sharedImports); | ||
___.getNewModuleHandler().setImports(imports); | ||
imports.loader = ___.freeze( | ||
{ provide:___.func(function (v) { valijaMaker = v; }) }); | ||
})(); | ||
</script> | ||
|
||
<!-- In ant-lib/com/google/caja/plugin/ --> | ||
<script src="../../google-caja/ant-www/testbed/valija.co.js"></script> | ||
|
||
</head> | ||
<body> | ||
<div id="gadget___" class="gadget___"></div> | ||
|
||
<script>(function () { | ||
var testImports = ___.copy(___.sharedImports); | ||
testImports.outers = testImports; | ||
var testDomContainer = document.getElementById('gadget___'); | ||
/* | ||
var pseudoWindowLocation = { | ||
href: 'http://zip.example.com:4242/pumpkin.html?q=getit#myanchor', | ||
hash: '#myanchor', | ||
host: 'zip.example.com:4242', | ||
hostname: 'zip.example.com', | ||
pathname: '/pumpkin.html', | ||
port: '4242', | ||
protocol: 'http:', | ||
search: '?q=getit' | ||
}; | ||
*/ | ||
|
||
___.getNewModuleHandler().setImports(testImports); | ||
|
||
attachDocumentStub( | ||
'-gadget___', | ||
{ | ||
rewrite: | ||
function (uri, mimeType) { | ||
if (/\.\/xhrTest.*/.test(uri)) { return uri; } | ||
if (!/^https?:\/\//i.test(uri)) { return null; } | ||
return 'http://gadget-proxy/?url=' + encodeURIComponent(uri) | ||
+ '&mimeType=' + encodeURIComponent(mimeType); | ||
} | ||
}, | ||
testImports, | ||
testDomContainer, | ||
null); | ||
|
||
testImports.htmlEmitter___ = new HtmlEmitter(testDomContainer); | ||
testImports.$v = valijaMaker.CALL___(testImports.outers); | ||
})();</script> | ||
|
||
<script src="../cajoled/utilities.vo.js"></script> | ||
<script src="../cajoled/core_gadget.vo.js"></script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.