-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"load" event handler is called prematurely for iframe.srcdoc #243
Comments
t2ym
added a commit
that referenced
this issue
Apr 18, 2018
Notes on the Fix
iframe.addEventHandler.call(iframe, 'load', function (event) { /* handler */ });
Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onload').set.call(iframe, function (event) { /* handler */});
|
ACL with the Fix HTMLIFrameElement: {
[S_CHAIN]: () => acl.HTMLElement,
[S_PROTOTYPE]: {
[S_CHAIN]: S_CHAIN,
[S_INSTANCE]: {
[S_CHAIN]: S_CHAIN,
addEventListener: {
[S_DEFAULT]: '---',
'@iframe_contentWindow_accessor': function _iframeAddEventListenerAcl(normalizedThisArg,
normalizedArgs /* ['property', args], ['property', value], etc. */,
aclArgs /* [name, isStatic, isObject, property, opType, context] */,
hookArgs /* [f, thisArg, args, context, newTarget] */,
applyAcl /* for recursive application of ACL */) {
let opType = aclArgs[4];
if (opType === 'x') {
if (normalizedArgs[1] && normalizedArgs[1][0] === 'load') {
if (!normalizedThisArg.src) {
normalizedThisArg.src = emptyDocumentURL;
}
if (hookArgs[0] === '()' || hookArgs[0] === '#()') {
if (hookArgs[1] === normalizedThisArg && hookArgs[2][1][0] === 'load') {
let onloadAttribute = normalizedThisArg.getAttribute('onload');
if (onloadAttribute && onloadAttribute.startsWith('event.target.contentDocument.write(')) {
hookArgs[2][1][0] = 'srcdoc-load';
}
}
}
}
}
return 'r-x'[opTypeMap[opType]] === opType; // equivalent to 'r-x' acl
},
},
onload: {
[S_DEFAULT]: '---',
'@iframe_contentWindow_accessor': function _iframeOnloadAcl(normalizedThisArg,
normalizedArgs /* ['property', args], ['property', value], etc. */,
aclArgs /* [name, isStatic, isObject, property, opType, context] */,
hookArgs /* [f, thisArg, args, context, newTarget] */,
applyAcl /* for recursive application of ACL */) {
let opType = aclArgs[4];
if (opType === 'w') {
if (hookArgs[1] === normalizedThisArg && hookArgs[2][0] === normalizedArgs[0]) {
let onloadAttribute = normalizedThisArg.getAttribute('onload');
if (onloadAttribute && onloadAttribute.startsWith('event.target.contentDocument.write(')) {
hookArgs[2][0] = '_onload'; // dummy to avoid overriding the existing onload event converted from srcdoc
normalizedThisArg.addEventListener('srcdoc-load', hookArgs[2][1]); // Redirect to srcdoc-load
}
}
}
return 'rw-'[opTypeMap[opType]] === opType; // equivalent to 'rw-' acl
},
},
contentDocument: {
[S_DEFAULT]: '---',
'@iframe_contentWindow_accessor': function _iframeContentDocumentAcl(normalizedThisArg,
normalizedArgs /* ['property', args], ['property', value], etc. */,
aclArgs /* [name, isStatic, isObject, property, opType, context] */,
hookArgs /* [f, thisArg, args, context, newTarget] */,
applyAcl /* for recursive application of ACL */) {
let opType = aclArgs[4];
if (!normalizedThisArg.getAttribute('src')) {
return false; // reject on empty src
}
if (this.contentWindow && !this.contentWindow.__hook__) {
return false; // reject on missing hook infrastructure
}
if (opType === 'r') {
let contentWindow = normalizedThisArg.contentWindow;
otherWindowObjects.set(contentWindow.Object, contentWindow);
otherWindowObjectsStatus.set = true;
}
return 'r--'[opTypeMap[opType]] === opType; // equivalent to 'r--' acl
},
},
contentWindow: {
[S_DEFAULT]: '---',
'@iframe_contentWindow_accessor': function _iframeContentWindowAcl(normalizedThisArg,
normalizedArgs /* ['property', args], ['property', value], etc. */,
aclArgs /* [name, isStatic, isObject, property, opType, context] */,
hookArgs /* [f, thisArg, args, context, newTarget] */,
applyAcl /* for recursive application of ACL */) {
let opType = aclArgs[4];
if (!normalizedThisArg.getAttribute('src')) {
return false; // reject on empty src
}
if (this.contentWindow && !this.contentWindow.__hook__) {
return false; // reject on missing hook infrastructure
}
if (opType === 'r') {
let contentWindow = normalizedThisArg[normalizedArgs[0]]
otherWindowObjects.set(contentWindow.Object, contentWindow);
otherWindowObjectsStatus.set = true;
}
return 'r--'[opTypeMap[opType]] === opType; // equivalent to 'r--' acl
},
},
},
},
}, |
20 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"load" event handler is called prematurely for
iframe.srcdoc
Root Cause
empty-document.html
is loaded into aniframe
,"load"
event is dispatched before the content is loaded to theiframe
document via itsonload
handler in its attribute converted fromsrcdoc
Fix
"load"
event handler has to be called on"srcdoc-load"
event from theiframe
documenthook-callback.js
"srcdoc-load"
eventPatterns
Note
onload
attribute handler is called onsrcdoc-load
event as of0.0.233
The text was updated successfully, but these errors were encountered: