Fix TCT issue 76/40476/9
authorSeungkeun Lee <sngn.lee@samsung.com>
Thu, 4 Jun 2015 06:46:47 +0000 (15:46 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Mon, 8 Jun 2015 09:02:34 +0000 (18:02 +0900)
 - Test if the UA can skip the preference element without a name attribute.
 - widget preference event was not called due to CustomEvent
 - access element without origin attribute
 - access element with invalid origin value
 - Duplicated preference key was skiped
 - overriding Widget toString method
Change-Id: Id2ab923fc9813e755caeedfb052c4b352bd9a258

src/bundle/widget_module.cc
src/common/resource_manager.cc
src/extension/widget/widget_api.js

index 2ad5d35..77c849e 100755 (executable)
@@ -391,6 +391,11 @@ void WidgetPreferenceDB::Initialize(const ApplicationData* appdata,
   auto& preferences = appdata->widget_info()->preferences();
 
   for (const auto& pref : preferences) {
+    if (pref->Name().empty())
+      continue;
+    if (db->HasKey(kDBPublicSection, pref->Name()))
+      continue;
+
     db->Set(kDBPublicSection,
             pref->Name(),
             pref->Value());
index 60e42eb..cf83e4c 100755 (executable)
@@ -170,6 +170,9 @@ static void GetURLInfo(const std::string& url,
                        std::string* scheme,
                        std::string* domain,
                        std::string* port) {
+  if (url.empty())
+    return;
+
   size_t end_of_scheme = url.find_first_of(':');
   if (end_of_scheme == std::string::npos) {
     end_of_scheme = -1;
@@ -177,6 +180,9 @@ static void GetURLInfo(const std::string& url,
     *scheme = url.substr(0, end_of_scheme);
   }
 
+  if (end_of_scheme+1 == url.length())
+    return;
+
   size_t start_of_domain = url.find_first_not_of('/', end_of_scheme+1);
   size_t end_of_domain = url.find_first_of('/', start_of_domain);
   *domain = url.substr(start_of_domain,
@@ -460,6 +466,8 @@ bool ResourceManager::CheckWARP(const std::string& url) {
   for (auto& allow : warp->access_map()) {
     if (allow.first == "*") {
       return true;
+    } else if (allow.first.empty()) {
+      continue;
     }
     std::string a_scheme, a_domain, a_port;
     GetURLInfo(allow.first, &a_scheme, &a_domain, &a_port);
index 0df73e7..7626e10 100755 (executable)
@@ -1,6 +1,7 @@
 
 var dispatchStorageEvent = function(key, oldValue, newValue) {
-  var evt = new CustomEvent("Storage");
+  var evt = document.createEvent("CustomEvent");
+  evt.initCustomEvent("storage", true, true);
   evt.key = key;
   evt.oldValue = oldValue;
   evt.newValue = newValue;
@@ -64,5 +65,9 @@ function Widget() {
   });
 };
 
+Widget.prototype.toString = function() {
+    return "[object Widget]";
+};
+
 window.widget = new Widget();
 exports = Widget;