I've found a work-around. I haven't tested it much, but it at least 
finishes off the caja.load from my example. I would like to know if my 
solution is suitable (not dangerous to security) and if this is a problem 
that needs to be fixed with Caja itself. 

Here is the work-around:

Take a look at line 27344 of ses-single-frame.js
var divInfo = cajaInt.prepareContainerDiv(div, feralWin, domOpts);

divInfo is what gets passed on to other functions that need to access the 
nodeType and ownerDocument of the property opt_div which is a property of 
divInfo. But opt_div is one level too deep it seems, and therefore its 
nodeType and ownerDocument are one level too deep as well. My work-around 
was to add this line just below the line above:
divInfo.opt_div = divInfo.opt_div[0];
That line assigned opt_div to actually be the element at key value 0, which 
is what I think opt_div is supposed to be anyway. I'm not sure if all of my 
rationale is correct, but it works now, and it would be nice to get this 
fixed so that I don't have to serve up a hacked copy of caja. Thanks!


On Friday, January 30, 2015 at 1:06:38 PM UTC-7, Jordan Last wrote:
>
> When I run caja.load on my own AngularJS directive, I get this 
> error: Uncaught TypeError: Cannot read property 'nodeType' of undefined - 
> line 17047 of ses-single-frame.js?debug=1
>
> HTML:
>
> <div>
> <sm-caja id="cajaElement"></sm-caja>
> </div>
>
> AngularJS directive:
>
> 'use strict';
>
> angular.module('testModule').directive('smCaja', [
> function() {
> return {
> restrict: 'E',
> link: function postLink(scope, element, attrs) {
> caja.initialize(
> {
> cajaServer: '//caja.appspot.com/',
> debug: true,
> maxAcceptableSeverity: 'NO_KNOWN_EXPLOIT_SPEC_VIOLATION'
> });
>  caja.load(element, undefined, function(frame) 
> {
> caja.markFunction(scope.receiveData);
> var tamedReceiveData = caja.tame(scope.receiveData);
>
> frame.code('api/practiceproblem/1', "text/html").api({ transferData: 
> tamedReceiveData }).run(function(result)
> { 
> alert('good job!');
> });
> });
>  scope.receiveData = function(arg1, arg2, arg3, arg4) {
> };
> }
> };
> }
> ]);
>
> I dug into it a little bit, and my sm-caja element has a nodeType property 
> when I inspect it in the Chrome Dev tools debugger, but it is undefined 
> when accessed in the code. The part of the code where the error is 
> occurring looks like it needs a document object, so I tried passing in the 
> $document object into caja.load from my directive code, and I changed the 
> parameters of each function call until I passed the document object down to 
> where the error occurred on line 17047, and set var document = [the 
> document object I passed in from my directive]. But that caused problems at 
> other places in the code with more undefined values. Any help would be 
> appreciated. I'm using build 5707 from the caja.appspot.com servers, and 
> I'm running Chrome Version 38.0.2125.122 (64-bit) on Ubuntu 14.04 LTS
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to