Fix Tizen device API access in window.onunload callback
authorLongXiang <xiang.long@intel.com>
Thu, 24 Jan 2013 08:30:47 +0000 (16:30 +0800)
committerGerrit Code Review <gerrit2@kim11>
Wed, 13 Feb 2013 04:39:09 +0000 (13:39 +0900)
[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.

src/view/webkit/bundles/wrt-wk2-bundle.cpp
src/view/webkit/bundles/wrt-wk2-bundle.h

index 4adab07..239002a 100644 (file)
@@ -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);
index 10c5016..b799c18 100644 (file)
@@ -73,6 +73,7 @@ class Bundle
     std::string m_encodedBundle;
     std::string m_theme;
     std::set<JSGlobalContextRef> m_loadedContext;
+    JSGlobalContextRef m_willRemoveContext;
     bool m_encrypted;
     WRTDecryptor::ResourceDecryptor *m_resDec;
     WrtDB::EncryptedFileList m_encryptedFiles;