diff --git a/src/cache/cache.c b/src/cache/cache.c index 54aae50f3..0795a742a 100644 --- a/src/cache/cache.c +++ b/src/cache/cache.c @@ -103,6 +103,7 @@ get_cache_entry_loading_count(void) struct cache_entry * find_in_cache(struct uri *uri) { + //LOG_JS("%s", uri->data); struct cache_entry *cached; int proxy = (uri->protocol == PROTOCOL_PROXY); diff --git a/src/document/html/parser/general.c b/src/document/html/parser/general.c index 03ed1a6c9..4f66a2e7e 100644 --- a/src/document/html/parser/general.c +++ b/src/document/html/parser/general.c @@ -264,7 +264,10 @@ html_script(struct html_context *html_context, char *a, if (type) { pos = type; - if (!c_strncasecmp(type, "text/", 5)) { + if (!c_strcasecmp(type, "module")){ + mem_free(type); + goto lang; + } else if (!c_strncasecmp(type, "text/", 5)) { pos += 5; } else if (!c_strncasecmp(type, "application/", 12)) { @@ -273,6 +276,7 @@ html_script(struct html_context *html_context, char *a, } else { mem_free(type); not_processed: + LOG_JS("skipping %s", get_attr_val(a, "src", html_context->doc_cp)); /* Permit nested scripts and retreat. */ html_top->invisible++; return; @@ -297,7 +301,7 @@ html_script(struct html_context *html_context, char *a, mem_free(type); } - +lang: /* Check that the script content is ecmascript. The value of the * language attribute can be JavaScript with optional version digits * postfixed (like: ``JavaScript1.1''). diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index cec6bb9a4..74ff42b4c 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -2392,7 +2392,7 @@ html_special(struct html_context *html_context, html_special_type_T c, ...) #ifdef CONFIG_ECMASCRIPT if (document) { struct uri *uri = va_arg(l, struct uri *); - +/* LOG_JS("%s", uri->data); */ add_to_uri_list(&document->ecmascript_imports, uri); } #endif diff --git a/src/document/renderer.c b/src/document/renderer.c index 46aa3d656..1aa22ea44 100644 --- a/src/document/renderer.c +++ b/src/document/renderer.c @@ -197,6 +197,8 @@ render_document(struct view_state *vs, struct document_view *doc_view, vs->doc_view = doc_view; cached = find_in_cache(vs->uri); + + //LOG_JS("%s", vs->uri->data); if (!cached) { INTERNAL("document %s to format not found", struri(vs->uri)); return; diff --git a/src/ecmascript/ecmascript-c.c b/src/ecmascript/ecmascript-c.c index 10a417b62..68087e4ac 100644 --- a/src/ecmascript/ecmascript-c.c +++ b/src/ecmascript/ecmascript-c.c @@ -383,6 +383,7 @@ check_events_for_element(struct ecmascript_interpreter *ecmascript, dom_node *el void ecmascript_reset_state(struct view_state *vs) { + LOG_JS(""); struct form_view *fv; int i; diff --git a/src/ecmascript/ecmascript.c b/src/ecmascript/ecmascript.c index 59ee4e220..7c69ca6fe 100644 --- a/src/ecmascript/ecmascript.c +++ b/src/ecmascript/ecmascript.c @@ -305,12 +305,10 @@ run_jobs(void *data) void check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text) { -#ifdef ECMASCRIPT_DEBUG - fprintf(stderr, "%s:%s %s %d\n", __FILE__, __FUNCTION__, text, interpreter->changed); -#endif + LOG_JS("%s %d", text, interpreter->changed); run_jobs(interpreter); - if (interpreter->changed && !program.testjs) { + if (interpreter->changed) { struct document_view *doc_view = interpreter->vs->doc_view; struct document *document = doc_view->document; struct session *ses = doc_view->session; diff --git a/src/ecmascript/mujs.c b/src/ecmascript/mujs.c index 20638d11c..7deb7641e 100644 --- a/src/ecmascript/mujs.c +++ b/src/ecmascript/mujs.c @@ -179,7 +179,7 @@ mujs_get_interpreter(struct ecmascript_interpreter *interpreter) interpreter->backend_data = ctx; JS_SetContextOpaque(ctx, interpreter); -// JS::SetWarningReporter(ctx, error_reporter); + JS::SetWarningReporter(ctx, error_reporter); JS_SetInterruptHandler(rt, js_heartbeat_callback, interpreter); // JS::RealmOptions options; @@ -267,7 +267,7 @@ mujs_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret) { assert(interpreter); - + LOG_JS("%.100s...", code->source); js_State *J = (js_State *)interpreter->backend_data; interpreter->ret = ret; js_dostring(J, code->source); diff --git a/src/ecmascript/quickjs.c b/src/ecmascript/quickjs.c index bf6ccbe87..761225784 100644 --- a/src/ecmascript/quickjs.c +++ b/src/ecmascript/quickjs.c @@ -371,12 +371,10 @@ error_reporter(struct ecmascript_interpreter *interpreter, JSContext *ctx) set_led_value(ses->status.ecmascript_led, 'J'); #endif - if (!get_opt_bool("ecmascript.error_reporting", ses)) { - return; - } - if (init_string(&f)) { js_dump_error(ctx, &f); + LOG_JS("%s", f); + if (!get_opt_bool("ecmascript.error_reporting", ses)) return; if (!init_string(&msg)) { done_string(&f); @@ -401,6 +399,7 @@ quickjs_eval(struct ecmascript_interpreter *interpreter, // if (!js_module_init_ok) { // return; // } + LOG_JS("%.100s...", code->source); ctx = (JSContext *)interpreter->backend_data; interpreter->heartbeat = add_heartbeat(interpreter); interpreter->ret = ret; diff --git a/src/ecmascript/quickjs.h b/src/ecmascript/quickjs.h index 87cbedf19..e855e5ae0 100644 --- a/src/ecmascript/quickjs.h +++ b/src/ecmascript/quickjs.h @@ -14,7 +14,7 @@ inline int operator<(JSValueConst a, JSValueConst b) extern "C" { #endif -#ifdef ECMASCRIPT_DEBUG +#ifdef ECMASCRIPT_DEBUG_OBJ #define RETURN_JS(obj) \ fprintf(stderr, "%s:%d obj=%p\n", __FILE__, __LINE__, JS_VALUE_GET_PTR(obj)); \ diff --git a/src/ecmascript/quickjs/console.c b/src/ecmascript/quickjs/console.c index e8990842a..36173984f 100644 --- a/src/ecmascript/quickjs/console.c +++ b/src/ecmascript/quickjs/console.c @@ -84,6 +84,7 @@ js_console_log_common(JSContext *ctx, JSValueConst this_val, int argc, JSValueCo if (!str) { return JS_EXCEPTION; } + LOG_JS("%s",str); FILE *f = fopen(log_filename, "a"); if (f) diff --git a/src/ecmascript/quickjs/element.c b/src/ecmascript/quickjs/element.c index 460f84bf7..92fcbcbd3 100644 --- a/src/ecmascript/quickjs/element.c +++ b/src/ecmascript/quickjs/element.c @@ -2051,6 +2051,7 @@ js_element_set_property_textContent(JSContext *ctx, JSValueConst this_val, JSVal dom_node_unref(el); return JS_EXCEPTION; } + LOG_JS("%s",str); dom_string *content = NULL; dom_exception exc = dom_string_create((const uint8_t *)str, len, &content); JS_FreeCString(ctx, str); diff --git a/src/elinks.h b/src/elinks.h index 46acc06ca..03718bec3 100644 --- a/src/elinks.h +++ b/src/elinks.h @@ -25,7 +25,7 @@ * config.h. */ #include "setup.h" -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_MEMLEAK #define DEBUG_MEMLEAK #endif diff --git a/src/main/object.h b/src/main/object.h index be932be99..eb0a2936d 100644 --- a/src/main/object.h +++ b/src/main/object.h @@ -13,7 +13,7 @@ extern "C" { struct elinks_object { int refcount; -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_OBJ char *name; #endif }; @@ -28,7 +28,7 @@ struct object_head { #ifdef DEBUG_REFCOUNT #include "util/error.h" -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_OBJ #define object_lock_debug(obj, info) \ DBG("object %s[%p] lock %s to %d", (obj)->object.name, obj, \ info, (obj)->object.refcount) @@ -40,7 +40,7 @@ struct object_head { #define object_lock_debug(obj, info) #endif /* DEBUG_REFCOUNT */ -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_OBJ #include "util/error.h" #define object_sanity_check(obj) \ do { \ diff --git a/src/main/timer.c b/src/main/timer.c index e71a22155..800ada873 100644 --- a/src/main/timer.c +++ b/src/main/timer.c @@ -156,7 +156,7 @@ install_timer(timer_id_T *id, milliseconds_T delay, void (*func)(void *), void * { struct timer *new_timer, *timer; - assert(id && delay > 0); + assert(id && delay >= 0); #ifdef USE_LIBEVENT char *q = (char *)mem_alloc(sizeof_struct_event + sizeof(struct timer)); diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index 6470f5ea4..7ffd52031 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -885,7 +885,7 @@ int get_output_handle(void) { if (program.testjs) { - return open("/dev/null", O_WRONLY); + // return open("/dev/null", O_WRONLY); } return 1; diff --git a/src/session/session.c b/src/session/session.c index 659618087..ba1610862 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -862,6 +862,7 @@ request_additional_file(struct session *ses, const char *name, struct uri *uri, ftl->pri = pri; ftl->ses = ses; + /* LOG_JS("%s", ftl->uri->data); */ add_to_list(ses->more_files, ftl); return ftl; @@ -892,7 +893,7 @@ process_file_requests(struct session *ses) continue; ftl->req_sent = 1; - + LOG_JS("%s", ftl->uri->data); load_additional_file(ftl, CACHE_MODE_NORMAL); more = 1; } diff --git a/src/session/task.c b/src/session/task.c index 3eb99eb64..f6242f80b 100644 --- a/src/session/task.c +++ b/src/session/task.c @@ -656,7 +656,7 @@ follow_url(struct session *ses, struct uri *uri, char *target, uristring = uri && !uri->post ? get_uri_string(uri, URI_BASE_FRAGMENT) : NULL; - + LOG_JS("%s", uristring); /* Do nothing if we do not have a URI or if it is a POST request * because scripts can corrupt POST requests leading to bad * things happening later on. */ diff --git a/src/setup.h b/src/setup.h index 965db6e40..70a76cd96 100644 --- a/src/setup.h +++ b/src/setup.h @@ -125,6 +125,16 @@ #define FG_POLL_TIME 500 #define TERMINAL_POLL_TIMEOUT 1000 -//#define ECMASCRIPT_DEBUG 1 +#ifdef CONFIG_DEBUG +//#define CONFIG_ASSERT +//#define CONFIG_DEBUG_DUMP +//#define CONFIG_DEBUG_LIST +//#define CONFIG_DEBUG_MEMLEAK +//#define CONFIG_DEBUG_MEMLIST +//#define CONFIG_DEBUG_OBJ +//#define CONFIG_DEBUG_STRING +// #define ECMASCRIPT_DEBUG +//#define ECMASCRIPT_DEBUG_OBJ +#endif #endif diff --git a/src/util/error.c b/src/util/error.c index 9f099fc8a..f9f354bbc 100644 --- a/src/util/error.c +++ b/src/util/error.c @@ -52,6 +52,7 @@ er(int bell, int shall_sleep, const char *fmt, va_list params) int errline; const char *errfile; +const char *errfun; void elinks_debug(const char *fmt, ...) @@ -110,13 +111,13 @@ elinks_internal(const char *fmt, ...) va_start(params, fmt); snprintf(errbuf, sizeof(errbuf), - "\033[1mINTERNAL ERROR\033[0m at %s:%d: %s", - errfile, errline, fmt); + "\033[1mINTERNAL ERROR\033[0m at %s %d %s: %s", + errfile, errline, errfun, fmt); er(1, 1, errbuf, params); va_end(params); -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_DUMP force_dump(); #endif } @@ -191,25 +192,26 @@ done_log(void) loctime); errbuf[len] = '\0'; - fprintf(log_file, "[%-5s %-15s %4s]: Log stopped at %s\n\n\n", + fprintf(log_file, "[%-5s %-15s %4s]: Log stopped at %s\n", "", "", "", errbuf); fclose(log_file); } void -elinks_log(char *msg, char *file, int line, +elinks_log(char *msg, char *file, int line,char*fun, const char *fmt, ...) { static char *log_files = NULL; static char *log_msg = NULL; char errbuf[4096]; + char tbuf[32]; va_list params; + time_t curtime = time(NULL); + struct tm *loctime = localtime(&curtime); if (!log_file) { char *log_name; - time_t curtime = time(NULL); - struct tm *loctime = localtime(&curtime); int len; log_files = getenv("ELINKS_FILES"); @@ -223,8 +225,7 @@ elinks_log(char *msg, char *file, int line, loctime); errbuf[len] = '\0'; - fprintf(log_file, "\n\n[%-5s %-15s %4s]: Log started at %s\n", - "type", "file", "line", errbuf); + fprintf(log_file, "Log started at %s\n",errbuf); atexit(done_log); } @@ -237,8 +238,9 @@ elinks_log(char *msg, char *file, int line, va_start(params, fmt); - snprintf(errbuf, sizeof(errbuf), "[%-5s %-15s %4d]: %s", - msg, file, line, fmt); + strftime(tbuf, sizeof(tbuf), "%T", loctime); + snprintf(errbuf, sizeof(errbuf), "[%s %s %s %d %s]: %s", + tbuf, msg, file, line, fun, fmt); vfprintf(log_file, errbuf, params); fputc('\n', log_file); diff --git a/src/util/error.h b/src/util/error.h index 790cee006..1e2b89321 100644 --- a/src/util/error.h +++ b/src/util/error.h @@ -13,10 +13,14 @@ extern "C" { #endif +#include "main/main.h" + /* This errfile thing is needed, as we don't have var-arg macros in standart, * only as gcc extension :(. */ extern int errline; extern const char *errfile; +extern const char *errfun; + /** @c DBG(format_string) is used for printing of debugging information. It * should not be used anywhere in the official codebase (although it is often @@ -48,7 +52,7 @@ void elinks_error(const char *fmt, ...); * run. It tries to draw user's attention to the error and dumps core if ELinks * is running in the CONFIG_DEBUG mode. */ #undef INTERNAL -#define INTERNAL errfile = __FILE__, errline = __LINE__, elinks_internal +#define INTERNAL errfile = __FILE__, errline = __LINE__, errfun = __FUNCTION__, elinks_internal void elinks_internal(const char *fmt, ...); @@ -74,26 +78,31 @@ void usrerror(const char *fmt, ...); * */ void -elinks_log(char *msg, char *file, int line, +elinks_log(char *msg, char *file, int line,char*, const char *fmt, ...); +#undef LOG_JS +#define LOG_JS(args...) \ +if (program.testjs)\ + elinks_log("js", __FILE__, __LINE__,__FUNCTION__, args) + #undef LOG_ERR #define LOG_ERR(args...) \ - elinks_log("error", __FILE__, __LINE__, args) + elinks_log("error", __FILE__, __LINE__,__FUNCTION__, args) #undef LOG_WARN #define LOG_WARN(args...) \ - elinks_log("warn", __FILE__, __LINE__, args) + elinks_log("warn", __FILE__, __LINE__,__FUBCTION__, args) #undef LOG_INFO #define LOG_INFO(args...) \ - elinks_log("info", __FILE__, __LINE__, args) + elinks_log("info", __FILE__, __LINE__,__FUNCTION__, args) #undef LOG_DBG #define LOG_DBG(args...) \ - elinks_log("debug", __FILE__, __LINE__, args) + elinks_log("debug", __FILE__, __LINE__,__FUNCTION__, args) -#endif +#endif // CONFIG_DEBUG #endif @@ -104,7 +113,7 @@ elinks_log(char *msg, char *file, int line, * recovery path, see below ::if_assert_failed. */ #undef assert -#ifdef CONFIG_FASTMEM +#ifndef CONFIG_ASSERT #define assert(x) /* We don't do anything in CONFIG_FASTMEM mode. */ #else #define assert(x) \ @@ -123,7 +132,7 @@ do { if (!assert_failed && (assert_failed = !(x))) { \ #undef assertm #ifdef HAVE_VARIADIC_MACROS -#ifdef CONFIG_FASTMEM +#ifndef CONFIG_ASSERT #define assertm(x,m...) /* We don't do anything in CONFIG_FASTMEM mode. */ #else #define assertm(x,m...) \ @@ -132,7 +141,7 @@ do { if (!assert_failed && (assert_failed = !(x))) { \ } } while (0) #endif #else /* HAVE_VARIADIC_MACROS */ -#ifdef CONFIG_FASTMEM +#ifndef CONFIG_ASSERT #define assertm elinks_assertm #else #define assertm errfile = __FILE__, errline = __LINE__, elinks_assertm @@ -144,11 +153,11 @@ do { if (!assert_failed && (assert_failed = !(x))) { \ * expression is int (and that's completely fine, I do *NOT* want to see any * stinking assert((int) pointer) ! ;-)), so CONFIG_DEBUG (-Werror) and * !HAVE_VARIADIC_MACROS won't play well together. Hrm. --pasky */ -#ifdef CONFIG_FASTMEM +#ifndef CONFIG_ASSERT static inline #endif void elinks_assertm(int x, const char *fmt, ...) -#ifdef CONFIG_FASTMEM +#ifndef CONFIG_ASSERT { /* We don't do anything in CONFIG_FASTMEM mode. Let's hope that the compiler * will at least optimize out the @x computation. */ @@ -187,7 +196,7 @@ void elinks_assertm(int x, const char *fmt, ...) extern int assert_failed; #undef if_assert_failed -#ifdef CONFIG_FASTMEM +#ifndef CONFIG_ASSERT #define if_assert_failed if (0) /* This should be optimalized away. */ #else #define if_assert_failed if (assert_failed && !(assert_failed = 0)) diff --git a/src/util/memlist.h b/src/util/memlist.h index 145340efa..91f8ded39 100644 --- a/src/util/memlist.h +++ b/src/util/memlist.h @@ -11,7 +11,7 @@ struct memory_list { }; #undef DEBUG_MEMLIST -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_MEMLIST #define DEBUG_MEMLIST #endif diff --git a/src/util/string.h b/src/util/string.h index da57d9efc..602f10881 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -152,7 +152,7 @@ int elinks_isspace(int c); /** String debugging using magic number, it may catch some errors. */ -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG_STRING #define DEBUG_STRING #endif diff --git a/src/viewer/text/draw.c b/src/viewer/text/draw.c index 07b32f8da..36944d5db 100644 --- a/src/viewer/text/draw.c +++ b/src/viewer/text/draw.c @@ -70,6 +70,7 @@ check_document_fragment(struct session *ses, struct document_view *doc_view) /* Omit the leading '#' when calling find_tag. */ vy = find_tag(document, fragment.source + 1, fragment.length - 1); + LOG_JS("%s %d", fragment.source,vy); if (vy == -1) { struct cache_entry *cached = document->cached; diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index af27885c8..244d03f85 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1064,7 +1064,9 @@ goto_link(struct session *ses, struct document_view *doc_view, struct link *link } else uri = get_link_uri(ses, doc_view, link); - if (!uri) return NULL; + // todo fix anchor links again + // if uri->fragmentlen goto anchor + if (!uri || compare_uri(uri,doc_view->vs->uri,URI_BASE)) return NULL; if (link->type == LINK_MAP) { /* TODO: Test reload? */ diff --git a/test/css/styletags.html b/test/css/styletags.html index 52c71d3b1..bdf50096f 100644 --- a/test/css/styletags.html +++ b/test/css/styletags.html @@ -4,7 +4,7 @@ a, h1 { text-decoration: underline } b { font-weight: normal } body, span { background: garbage properties white; } - dt { color: blue; } + dt { color: blue; display:none } dd { font-weight: normal; color: white } h1 { color: green; } h2, img { color: red; } @@ -18,7 +18,7 @@

green / underline

bold / blue .. but doesn't work
normal / white but also doesn't work
-
bold / blue .. but doesn't work
+
bold / blue .. i should be hidden
normal / white but also doesn't work

rgb(100%, 100%, 0) underline / aqua bleh