go.Diagram.fromDiv with Google chrome extension

Hi Team,

I have google chrome extension which has content script as go-debug.js. I want to get diagram object from div so I have called below api in content.

go.Diagram.fromDiv(myDivObject which contains canvas)

It returns null with no exception; If I call same inside page dom context (or with debug console window) – It returns correct diagram object.

I have include go-debug.js in chrome extension and I saw go namespace is there in content script dom context.

Looking forward your help or suggestion to resolve this problem.

You need to execute code (such as go.Diagram.fromDiv(...)) in the page’s context.

Hi

I had used postMessage and try to pass javascript window.go object but It raised error

Uncaught DOMException: Failed to execute ‘postMessage’ on ‘Window’: function da(a,b,c){w.nc(this);this.oC=a;this.Rb=b;this.eH=c} could not be cloned.
at … (:22:10)

Please, help.

I have tried to post from page dom

interestedDiagram = window.go.Diagram.fromDiv(container);

window.postMessage({ type: “FROM_PAGE”, text: “from webpage”, result : objT, domWindow : interestedDiagram }, “*”);

This also gives clone issue

Uncaught DOMException: Failed to execute ‘postMessage’ on ‘Window’: function Dk(a,b,c,d){a/=d/2;return 1>a?c/2aa+b:-c/2*(–a*(a-2)-1)+b} could not be cloned.
at Object.myfun (:23:10)
at :1:5

Please help

I don’t use Google Chrome, so I cannot help you.

But the error message seems to be saying that functions cannot be serialized.