Skip to content
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

Fixed an problem about invalid iframe contentWindow (iframe not be prepared as our expectation) #204

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

BorisJineman
Copy link

@BorisJineman BorisJineman commented Oct 18, 2017

Problem:

When I use this library in my complex network environment,
I found a tiny problem, bellow is the reproduce steps,

  1. Set network connection to offline,
    (unplug the network cable and disconnected the wireless network)

  2. Try to use xdomain to retrieve something from internet,
    (it should failed with timeout event, due to its created iframe cannot load the proxy.html page)

  3. Problem phenomenon, There will be an error thrown with message "Invalid calling object" when we call frame.postMessage,
    (It should caused by the object frame is not prepared well or it is retired)
    Thus, the next logic about timeout checking logic will be broken. So the whole timeout trigger logic will not work.

There is a rare situation, but it indeed exists when the network is offline.

I found I cannot reproduce above issue in Chrome and Safari, even in IE browser,
But I can reproduce it in a application hosted Web Browser control.
(I already set the Feature Control Key of the module to 11001, so it should simulate the IE11 Edge)

Solution:

I think this should be a tiny issue, and we could just wait the iframe be loaded in time.
We also have a timeout timer to check whether it is loaded in time, so I think we can just ignore this error,

In this PR, I just added a try to it, thus, the countdown timer of timeout can work, so its trigger logic will be corrected.

@eligrey @mscdex @jpsirois @soncodi @NathanWalker , Could you have a look on this PR and review it?, thanks a lot,

…epared as our expectation)

There is a rare situation, but it indeed exists when the network is offline.
@@ -55,7 +55,7 @@ createSocket = (id, frame) ->
checks = 0
check = =>
# send test message NO ENCODING
frame.postMessage [id, XD_CHECK, {}], "*"
try frame.postMessage [id, XD_CHECK, {}], "*"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is simple, I just added a try at here, to avoid the crashing problem caused by invalid iframe's window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant