Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #30 from operasoftware/task_DFL_3042_ev_listener

Task dfl 3042 ev listener
  • Loading branch information...
commit 0ef47637b07b804268177512b3a293288838ef8a 2 parents ee31949 + 912c63c
Christian Krebs chriskr authored
6 src/ecma-debugger/eventlisteners/evlistenertemplates.js
View
@@ -31,7 +31,7 @@
if (ev_rt_list.length > 1)
{
ret.push(["h2",
- ["span", rt && (rt.title || rt.host),
+ ["span", rt && (rt.title || rt.host || rt.short_url),
"data-tooltip", "url-tooltip",
"data-tooltip-text", rt && rt.uri],
"class", "ev-rt-title"]);
@@ -177,7 +177,7 @@
if (script.uri)
{
var is_linked = script.script_type == "linked";
- ret.push("span", str.replace("%s", script.filename + ":" + line_number),
+ ret.push("span", str.replace("%s", script.short_url + ":" + line_number),
"data-tooltip", is_linked && "url-tooltip",
"data-tooltip-text", is_linked && script.uri);
}
@@ -185,7 +185,7 @@
{
var rt = window.runtimes.getRuntime(script.runtime_id);
if (rt)
- ret.push("span", str.replace("%s", rt.filename),
+ ret.push("span", str.replace("%s", rt.short_url),
"data-tooltip", "url-tooltip",
"data-tooltip-text", rt.uri);
else
47 src/scripts/uri.js
View
@@ -20,8 +20,14 @@ var URIPrototype = function(uri_prop_name)
abs_dir // protocol plus hostname plus dir_pathname
path_parts // list of "directories" in pathname
short_distinguisher // the last part of a url that can be used to distinguish it
+
+ The value of uri_prop_name (uri) must be ab absolute URI.
+ For relative URIs the properties have not clear defined values, e.g. "a.b"
+ could be a host or a filename.
*/
+ var DATA_URI_LENGTH_SHORT = 25;
+
[
"hash",
"host",
@@ -51,7 +57,7 @@ var URIPrototype = function(uri_prop_name)
if (pos > -1)
this._filename = this.pathname.slice(pos + 1);
else
- this._filename = this.pathname;
+ this._filename = "";
}
else
this._filename = "";
@@ -106,11 +112,47 @@ var URIPrototype = function(uri_prop_name)
this.__defineGetter__("basename", function()
{
- return this.filename || this.dir_pathname;
+
+ if (this._basename === undefined && (this._is_parsed || this[uri_prop_name]))
+ {
+ if (!this._is_data_uri)
+ {
+ if (this.filename)
+ this._basename = this.filename;
+ else if (this.path_parts.length)
+ this._basename = this.path_parts[this.path_parts.length - 1] + "/";
+ else
+ this._basename = "";
+ }
+ else
+ this._basename = "";
+ }
+
+ return this._basename;
});
this.__defineSetter__("basename", function() {});
+ this.__defineGetter__("short_url", function()
+ {
+ if (this._short_url === undefined && (this._is_parsed || this[uri_prop_name]))
+ {
+ if (this._is_data_uri)
+ {
+ var short_url = this._protocol + this._pathname;
+ this._short_url = short_url.length <= DATA_URI_LENGTH_SHORT
+ ? short_url
+ : short_url.slice(0, DATA_URI_LENGTH_SHORT) + "";
+ }
+ else
+ this._short_url = this.filename || this.basename || this.host;
+ }
+
+ return this._short_url;
+ });
+
+ this.__defineSetter__("short_url", function() {});
+
this.__defineGetter__("abs_dir", function()
{
if (this._abs_dir === undefined && (this._is_parsed || this[uri_prop_name]))
@@ -244,6 +286,7 @@ var URIPrototype = function(uri_prop_name)
else if (this._protocol && !this._is_data_uri)
{
this._host = val;
+ val = "";
}
else
this._host = "";
4 src/ui-strings/ui_strings-en.js
View
@@ -421,7 +421,7 @@ ui_strings.M_VIEW_SUB_LABEL_PARENT_OFFSETS = "Parent Offsets";
ui_strings.S_ANONYMOUS_FUNCTION_NAME = "(anonymous)";
/* DESC: Info in a tooltip that the according listener was set as attribute. */
-ui_strings.S_ATTRIBUTE_LISTENER = "Attribute listener";
+ui_strings.S_ATTRIBUTE_LISTENER = "Event handler";
/* DESC: Generic label for a cancel button */
ui_strings.S_BUTTON_CANCEL = "Cancel";
@@ -685,7 +685,7 @@ ui_strings.S_EVENT_LISTENER_ADDED_IN = "Added in %s";
ui_strings.S_EVENT_LISTENER_SET_AS_MARKUP_ATTR = "Set as markup attribute";
/* DESC: Info in a tooltip that the according listener was set by the event target interface. */
-ui_strings.S_EVENT_TARGET_LISTENER = "Event target listener";
+ui_strings.S_EVENT_TARGET_LISTENER = "Event listener";
/* DESC: Event type for events in the profiler */
ui_strings.S_EVENT_TYPE_CSS_PARSING = "CSS parsing";
71 tests/uri.qunit.html
View
@@ -1,7 +1,8 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html>
<head>
<title>Dragonfly - URI class</title>
+ <meta charset="utf-8">
<link rel="stylesheet" href="qunit/qunit.css" media="screen">
<script src="qunit/qunit.js"></script>
<script src="../src/scripts/uri.js"></script>
@@ -11,7 +12,7 @@
test("uri", function()
-{
+{
var uri = new URI("http://edition.cnn.com/.element/ssi/intl/breaking_news/3.0/banner.html?csiID=csi1#hello");
equal(uri.protocol, "http:");
@@ -27,17 +28,17 @@
deepEqual(uri.path_parts, [".element", "ssi", "intl", "breaking_news", "3.0", "banner.html"]);
equal(uri.short_distinguisher, "banner.html?csiID=csi1#hello");
- var uri = new URI("foo.txt");
+ var uri = new URI("http://a.b.c/foo.txt");
- equal(uri.protocol, "");
- equal(uri.host, "");
- equal(uri.pathname, "foo.txt");
+ equal(uri.protocol, "http:");
+ equal(uri.host, "a.b.c");
+ equal(uri.pathname, "/foo.txt");
equal(uri.search, "");
equal(uri.hash, "");
equal(uri.filename, "foo.txt");
equal(uri.extension, "txt");
- equal(uri.dir_pathname, "");
- equal(uri.abs_dir, "");
+ equal(uri.dir_pathname, "/");
+ equal(uri.abs_dir, "http://a.b.c/");
deepEqual(uri.params, []);
deepEqual(uri.path_parts, ["foo.txt"]);
equal(uri.short_distinguisher, "foo.txt");
@@ -94,7 +95,8 @@
var uri = new URI("http://edition.cnn.com/");
equal(uri.short_distinguisher, "edition.cnn.com");
-
+ equal(uri.pathname, "/");
+
var uri = new URI("data:text/html,<p>?a=b#a");
equal(uri.protocol, "data:");
equal(uri.host, "");
@@ -108,6 +110,57 @@
deepEqual(uri.params, []);
deepEqual(uri.path_parts, []);
equal(uri.short_distinguisher, "data:text/html,<p>?a=b#a");
+
+ var uri = new URI("http://a.b.c");
+ equal(uri.protocol, "http:");
+ equal(uri.host, "a.b.c");
+ equal(uri.pathname, "");
+ equal(uri.dir_pathname, "");
+ equal(uri.abs_dir, "http://a.b.c");
+ equal(uri.basename, "");
+ equal(uri.filename, "");
+ equal(uri.short_url, "a.b.c");
+
+ var uri = new URI("http://a.b.c/a/b/c/");
+ equal(uri.protocol, "http:");
+ equal(uri.host, "a.b.c");
+ equal(uri.pathname, "/a/b/c/");
+ equal(uri.dir_pathname, "/a/b/c/");
+ equal(uri.abs_dir, "http://a.b.c/a/b/c/");
+ equal(uri.basename, "c/");
+ equal(uri.filename, "");
+ equal(uri.short_url, "c/");
+
+ var uri = new URI("http://a.b.c/a/b/c/d");
+ equal(uri.protocol, "http:");
+ equal(uri.host, "a.b.c");
+ equal(uri.pathname, "/a/b/c/d");
+ equal(uri.dir_pathname, "/a/b/c/");
+ equal(uri.abs_dir, "http://a.b.c/a/b/c/");
+ equal(uri.basename, "d");
+ equal(uri.filename, "d");
+ equal(uri.short_url, "d");
+
+ var uri = new URI("data:text/plain,a");
+ equal(uri.protocol, "data:");
+ equal(uri.host, "");
+ equal(uri.pathname, "text/plain,a");
+ equal(uri.dir_pathname, "");
+ equal(uri.abs_dir, "");
+ equal(uri.basename, "");
+ equal(uri.filename, "");
+ equal(uri.short_url, "data:text/plain,a");
+
+ var uri = new URI("data:text/plain,abcdefghijklmnopqrstuvwxyz");
+ equal(uri.protocol, "data:");
+ equal(uri.host, "");
+ equal(uri.pathname, "text/plain,abcdefghijklmnopqrstuvwxyz");
+ equal(uri.dir_pathname, "");
+ equal(uri.abs_dir, "");
+ equal(uri.basename, "");
+ equal(uri.filename, "");
+ equal(uri.short_url, "data:text/plain,abcdefghi…");
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.