From: LongXiang Date: Thu, 24 Jan 2013 08:30:47 +0000 (+0800) Subject: Fix Tizen device API access in window.onunload callback X-Git-Tag: 2.1b_release~22^2~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0dd74625018e8e0cdefb3b35429eefca04e84952;p=platform%2Fframework%2Fweb%2Fwrt.git Fix Tizen device API access in window.onunload callback [Issue#] N/A [Problem] Can't access Tizen device APIs in window.onunload callback if current window is replaced by another, like "window.open('new.html', '_self', '', true)". [Cause] Plugin modules are unloaded in didStartProvisionalLoadForFrameCallback, however unload event is sent out after that. [Solution] Save frame context and handle it later in didCommitLoadForFrameCallback. --- diff --git a/src/view/webkit/bundles/wrt-wk2-bundle.cpp b/src/view/webkit/bundles/wrt-wk2-bundle.cpp index 4adab07..239002a 100644 --- a/src/view/webkit/bundles/wrt-wk2-bundle.cpp +++ b/src/view/webkit/bundles/wrt-wk2-bundle.cpp @@ -94,6 +94,7 @@ Bundle::Bundle(WKBundleRef bundle) : m_scale(0), m_encodedBundle(""), m_theme(""), + m_willRemoveContext(NULL), m_encrypted(false), m_resDec(NULL), m_widgetType(WrtDB::APP_TYPE_UNKNOWN) @@ -428,8 +429,7 @@ void Bundle::didStartProvisionalLoadForFrameCallback( } This->m_pageContext[page].erase(i); - - PluginModule::unloadFrame(context); + This->m_willRemoveContext = context; } void Bundle::didRemoveFrameFromHierarchyCallback( @@ -511,6 +511,11 @@ void Bundle::didCommitLoadForFrameCallback( return; } + if (This->m_willRemoveContext) { + PluginModule::unloadFrame(This->m_willRemoveContext); + This->m_willRemoveContext = NULL; + } + JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame); This->m_pageContext[page].insert(context); diff --git a/src/view/webkit/bundles/wrt-wk2-bundle.h b/src/view/webkit/bundles/wrt-wk2-bundle.h index 10c5016..b799c18 100644 --- a/src/view/webkit/bundles/wrt-wk2-bundle.h +++ b/src/view/webkit/bundles/wrt-wk2-bundle.h @@ -73,6 +73,7 @@ class Bundle std::string m_encodedBundle; std::string m_theme; std::set m_loadedContext; + JSGlobalContextRef m_willRemoveContext; bool m_encrypted; WRTDecryptor::ResourceDecryptor *m_resDec; WrtDB::EncryptedFileList m_encryptedFiles;