cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject [1/9] adds support for all browsers
Date Wed, 22 May 2013 17:31:55 GMT
Updated Branches:
  refs/heads/master 80ca5c76f -> da06b4940


http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/client/weinre/browser-support-check.js
----------------------------------------------------------------------
diff --git a/weinre.web/client/weinre/browser-support-check.js b/weinre.web/client/weinre/browser-support-check.js
new file mode 100644
index 0000000..dba38fe
--- /dev/null
+++ b/weinre.web/client/weinre/browser-support-check.js
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+var iSupported = false;
+
+if (navigator.userAgent.match(/webkit/i)) {
+    iSupported = true;
+} else if (navigator.userAgent.match(/MSIE/i)) {
+    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+    iSupported = re.exec(navigator.userAgent) !== null && parseFloat(RegExp.$1) >=
10;
+} else if (navigator.userAgent.match(/Firefox/i)) {
+	var re = new RegExp("Firefox/([0-9]{1,}[\.0-9]{0,})");
+	iSupported = re.exec(navigator.userAgent) !== null && parseFloat(RegExp.$1) >=
18;
+}
+
+if (!iSupported) {
+    alert("It seems your browser or its version is not supported. This web page is designed
to work in webkit-based browsers, latest InternetExplorer and Firefox")
+}

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/client/weinre/check-for-webkit.js
----------------------------------------------------------------------
diff --git a/weinre.web/client/weinre/check-for-webkit.js b/weinre.web/client/weinre/check-for-webkit.js
deleted file mode 100644
index 1b66a5f..0000000
--- a/weinre.web/client/weinre/check-for-webkit.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-if (!navigator.userAgent.match(/webkit/i)) {
-    alert("This web page is only designed to work in WebKit-based browsers.  Sorry.  Best
of luck.")
-}

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/client/weinre/hacks.js
----------------------------------------------------------------------
diff --git a/weinre.web/client/weinre/hacks.js b/weinre.web/client/weinre/hacks.js
index 6f0290b..b0927ee 100644
--- a/weinre.web/client/weinre/hacks.js
+++ b/weinre.web/client/weinre/hacks.js
@@ -41,3 +41,95 @@ function fixToolbarItem() {
 }
 
 })();
+
+// __proto__ inheritance support; Weinre client classes only
+(function () {
+
+    var hasProto = "__proto__" in Object.prototype;
+
+    if (!hasProto) {
+        Object.defineProperty(Object.prototype, '__proto__', {set : function(value){
+            var tmpFunc = new Function();
+            tmpFunc.prototype = Object.create(value);
+
+            function copyProperties(a, b) {
+                var d;
+                for (var i in b) {
+                    d = Object.getOwnPropertyDescriptor(b, i);
+
+                    if (d &&(d.get || d.set)) {
+                        Object.defineProperty(a, i, d);
+                    } else {
+                        a[i] = b[i];
+                    }
+                }
+                return a;
+            }
+
+            function findProtoOwner(root, proto, depth){
+
+                if (depth > 1) return;
+
+                var props = Object.getOwnPropertyNames(root),
+                    prop,
+                    d;
+
+                for (var i = props.length; i--;) {
+                    prop = props[i];
+
+                    d = Object.getOwnPropertyDescriptor(root, prop);
+
+                    if (d && (d.get || d.set))  continue;
+
+                    if (typeof(root[prop]) === 'function' && root[prop].prototype
=== proto) {
+                        return root[prop];
+                    }
+
+                    if (root[prop] && root[prop].prototype instanceof WebInspector.Object)
{
+                        var owner = findProtoOwner(root[prop], proto, depth+1);
+
+                        if (owner) return owner;
+                    }
+                }
+            }
+
+            copyProperties(tmpFunc.prototype, this);
+
+            // hack to be able to redefine object prototype; we can't do it another way
+            // because we have prototype as 'this' here only
+            var owner = findProtoOwner (window.WebInspector, this, 0);
+
+            if (owner) {
+                owner.prototype = new tmpFunc();
+                owner.prototype.proto = value;
+            }
+
+        }, get : function(){
+            return this.proto;
+        }});
+    }
+})();
+
+//if (!Object.prototype.__defineGetter__) {
+//    Object.prototype.__defineGetter__ = function (key, fn) {
+//        Object.defineProperty(this, key, {get: fn});
+//    }
+//}
+//
+//if (!Object.prototype.__defineSetter__) {
+//    Object.prototype.__defineSetter__ = function (key, fn) {
+//        Object.defineProperty(this, key, {set: fn, configurable: true, writable : true});
+//    }
+//}
+
+// hack for not existing scrollIntoViewIfNeeded
+if (!HTMLElement.prototype.scrollIntoViewIfNeeded){
+    HTMLElement.prototype.scrollIntoViewIfNeeded = function(alignWithTop) {
+		return this.scrollIntoView(alignWithTop);
+	};
+}
+
+// hack for not existing setBaseAndExtent
+if (!Selection.prototype.setBaseAndExtent){
+    Selection.prototype.setBaseAndExtent = Selection.prototype.selectAllChildren;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/modules/weinre/client/Client.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/client/Client.coffee b/weinre.web/modules/weinre/client/Client.coffee
index 54422a4..dfc0d88 100644
--- a/weinre.web/modules/weinre/client/Client.coffee
+++ b/weinre.web/modules/weinre/client/Client.coffee
@@ -90,6 +90,7 @@ module.exports = class Client
         WebInspector.currentPanel = panel
 
         toolButtonsToHide = [ 'scripts' ]
+        toolButtonsToHide.push 'resources', 'network', 'timeline', 'profiles', 'audits' if
navigator.userAgent.match(/MSIE/i)
         for toolButtonToHide in toolButtonsToHide
             continue unless WebInspector.panels[toolButtonToHide]
             continue unless WebInspector.panels[toolButtonToHide].toolbarItem

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/modules/weinre/client/RemotePanel.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/client/RemotePanel.coffee b/weinre.web/modules/weinre/client/RemotePanel.coffee
index f191ee7..8f730f5 100644
--- a/weinre.web/modules/weinre/client/RemotePanel.coffee
+++ b/weinre.web/modules/weinre/client/RemotePanel.coffee
@@ -30,10 +30,10 @@ WebInspector.Panel.prototype.constructor = WebInspector.Panel
 #-------------------------------------------------------------------------------
 module.exports = class RemotePanel extends WebInspector.Panel
 
-    RemotePanel::__defineGetter__("toolbarItemClass", -> "remote")
-    RemotePanel::__defineGetter__("toolbarItemLabel", -> "Remote")
-    RemotePanel::__defineGetter__("statusBarItems", -> [])
-    RemotePanel::__defineGetter__("defaultFocusedElement", -> @contentElement)
+    Object.defineProperty RemotePanel::, "toolbarItemClass", get: -> "remote"
+    Object.defineProperty RemotePanel::, "toolbarItemLabel", get: -> "Remote"
+    Object.defineProperty RemotePanel::, "statusBarItems", get: -> []
+    Object.defineProperty RemotePanel::, "defaultFocusedElement", get: -> @contentElement
 
     constructor: ->
         super "remote"

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/modules/weinre/common/HookLib.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/common/HookLib.coffee b/weinre.web/modules/weinre/common/HookLib.coffee
index 4780dc3..3e5d27c 100644
--- a/weinre.web/modules/weinre/common/HookLib.coffee
+++ b/weinre.web/modules/weinre/common/HookLib.coffee
@@ -72,7 +72,10 @@ class HookSite
             return
         else
             hookedFunction   = getHookedFunction(@target, this)
-            object[property] = hookedFunction
+            #In IE we should not override standard storage functions because IE does it incorrectly
- all values that set as
+            # storage properties (e.g. localStorage.setItem = function()[...]) are cast to
String.
+            # That leads to "Function expected" exception when any of overridden function
is called.
+            object[property] = hookedFunction  unless navigator.userAgent.match(/MSIE/i)
and (object is localStorage or object is sessionStorage)
 
     #---------------------------------------------------------------------------
     addHooks: (hooks) ->

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/modules/weinre/common/WebSocketXhr.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/common/WebSocketXhr.coffee b/weinre.web/modules/weinre/common/WebSocketXhr.coffee
index 50ead99..6e10488 100644
--- a/weinre.web/modules/weinre/common/WebSocketXhr.coffee
+++ b/weinre.web/modules/weinre/common/WebSocketXhr.coffee
@@ -195,7 +195,10 @@ module.exports = class WebSocketXhr
         if null == handler
             throw new Ex(arguments, "handler must not be null")
 
-        xhr = new XMLHttpRequest()
+        # Fix for XMLHttpRequest issue in Cordova for WP8 - Cordova overrides standard XMLHttpRequest
object but
+        # overriden object causes dropping connections between target and server, so we should
use Original
+        # XMLHttpRequest that is stored in XMLHttpRequest.noConflict.
+        xhr = (if XMLHttpRequest.noConflict then new XMLHttpRequest.noConflict() else new
XMLHttpRequest())
         xhr.httpSocket = this
         xhr.httpSocketHandler = handler
         xhr.onreadystatechange = _xhrEventHandler

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/modules/weinre/target/ElementHighlighter.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/ElementHighlighter.coffee b/weinre.web/modules/weinre/target/ElementHighlighter.coffee
index 991e9c1..3dae1ed 100644
--- a/weinre.web/modules/weinre/target/ElementHighlighter.coffee
+++ b/weinre.web/modules/weinre/target/ElementHighlighter.coffee
@@ -78,18 +78,18 @@ getMetricsForElement = (element) ->
 
       metrics.width         = element.offsetWidth
       metrics.height        = element.offsetHeight
-      metrics.marginLeft    = fromPx(cStyle["margin-left"])
-      metrics.marginRight   = fromPx(cStyle["margin-right"])
-      metrics.marginTop     = fromPx(cStyle["margin-top"])
-      metrics.marginBottom  = fromPx(cStyle["margin-bottom"])
-      metrics.borderLeft    = fromPx(cStyle["border-left-width"])
-      metrics.borderRight   = fromPx(cStyle["border-right-width"])
-      metrics.borderTop     = fromPx(cStyle["border-top-width"])
-      metrics.borderBottom  = fromPx(cStyle["border-bottom-width"])
-      metrics.paddingLeft   = fromPx(cStyle["padding-left"])
-      metrics.paddingRight  = fromPx(cStyle["padding-right"])
-      metrics.paddingTop    = fromPx(cStyle["padding-top"])
-      metrics.paddingBottom = fromPx(cStyle["padding-bottom"])
+      metrics.marginLeft    = fromPx(cStyle["margin-left"] || cStyle["marginLeft"])
+      metrics.marginRight   = fromPx(cStyle["margin-right"] || cStyle["marginRight"])
+      metrics.marginTop     = fromPx(cStyle["margin-top"] || cStyle["marginTop"])
+      metrics.marginBottom  = fromPx(cStyle["margin-bottom"] || cStyle["marginBottom"])
+      metrics.borderLeft    = fromPx(cStyle["border-left-width"] || cStyle["borderLeftWidth"])
+      metrics.borderRight   = fromPx(cStyle["border-right-width"] || cStyle["borderRightWidth"])
+      metrics.borderTop     = fromPx(cStyle["border-top-width"] || cStyle["borderTopWidth"])
+      metrics.borderBottom  = fromPx(cStyle["border-bottom-width"] || cStyle["borderBottomWidth"])
+      metrics.paddingLeft   = fromPx(cStyle["padding-left"] || cStyle["paddingLeft"])
+      metrics.paddingRight  = fromPx(cStyle["padding-right"] || cStyle["paddingRight"])
+      metrics.paddingTop    = fromPx(cStyle["padding-top"] || cStyle["paddingTop"])
+      metrics.paddingBottom = fromPx(cStyle["padding-bottom"] || cStyle["paddingBottom"])
 
       metrics.x -= metrics.marginLeft
       metrics.y -= metrics.marginTop

http://git-wip-us.apache.org/repos/asf/cordova-weinre/blob/4992e917/weinre.web/modules/weinre/target/Target.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Target.coffee b/weinre.web/modules/weinre/target/Target.coffee
index 1a2fa52..4999c3a 100644
--- a/weinre.web/modules/weinre/target/Target.coffee
+++ b/weinre.web/modules/weinre/target/Target.coffee
@@ -194,7 +194,7 @@ module.exports = class Target
 
     #---------------------------------------------------------------------------
     setDocument: () ->
-        Weinre.elementHighlighter = ElementHighlighter.create()
+        Weinre.elementHighlighter = ElementHighlighter.create() unless Weinre.elementHighlighter
 
         nodeId   = Weinre.nodeStore.getNodeId(document)
         nodeData = Weinre.nodeStore.getNodeData(nodeId, 2)


Mime
View raw message