1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Merge branch 'EVENT'

This commit is contained in:
Witold Filipczyk 2024-06-03 15:37:22 +02:00
commit e2d240af78
89 changed files with 374 additions and 102 deletions

View File

@ -1167,3 +1167,7 @@ subdir('contrib')
if get_option('doc')
subdir('doc')
endif
if get_option('test')
subdir('test/ecmascript/assert')
endif

View File

@ -228,6 +228,7 @@ CORESTRING_DOM_STRING(data);
CORESTRING_DOM_STRING(dblclick);
CORESTRING_DOM_STRING(defer);
CORESTRING_DOM_STRING(DOMAttrModified);
CORESTRING_DOM_STRING(DOMContentLoaded);
CORESTRING_DOM_STRING(DOMNodeInserted);
CORESTRING_DOM_STRING(DOMNodeInsertedIntoDocument);
CORESTRING_DOM_STRING(DOMSubtreeModified);

View File

@ -604,6 +604,50 @@ dump_xhtml(struct cache_entry *cached, struct document *document, int parse)
}
}
static bool
fire_dom_event(dom_event *event, dom_node *target)
{
dom_exception exc;
bool result;
exc = dom_event_target_dispatch_event(target, event, &result);
if (exc != DOM_NO_ERR) {
return false;
}
return result;
}
/* Copy from netsurf */
int
fire_generic_dom_event(void *t, void *tar, int bubbles, int cancelable)
{
dom_string *typ = (dom_string *)t;
dom_node *target = (dom_node *)tar;
dom_exception exc;
dom_event *evt;
bool result;
exc = dom_event_create(&evt);
if (exc != DOM_NO_ERR) return false;
exc = dom_event_init(evt, typ, bubbles, cancelable);
if (exc != DOM_NO_ERR) {
dom_event_unref(evt);
return false;
}
// NSLOG(netsurf, INFO, "Dispatching '%*s' against %p",
// (int)dom_string_length(type), dom_string_data(type), target);
result = fire_dom_event(evt, target);
dom_event_unref(evt);
return result;
}
int
fire_onload(void *doc)
{
return fire_generic_dom_event(corestring_dom_DOMContentLoaded, doc, false, false);
}
#if 0
void
walk2(struct document *document)

View File

@ -22,6 +22,9 @@ void dump_xhtml(struct cache_entry *cached, struct document *document, int parse
void free_libdom(void);
void debug_dump_xhtml(void *doc);
int fire_generic_dom_event(void *typ, void *target, int bubbles, int cancelable);
int fire_onload(void *doc);
#if 0
void walk2(struct document *document);
void scan_document(struct document_view *doc_view);

View File

@ -12,6 +12,7 @@
#include "document/document.h"
#include "document/libdom/doc.h"
#include "document/libdom/mapa.h"
#include "document/libdom/renderer2.h"
#include "document/view.h"
#include "ecmascript/ecmascript.h"
#include "ecmascript/ecmascript-c.h"
@ -292,6 +293,8 @@ check_for_snippets(struct view_state *vs, struct document_options *options, stru
process_snippets(vs->ecmascript,
&vs->ecmascript->onload_snippets,
&vs->ecmascript->current_onload_snippet);
fire_onload(document->dom);
check_for_rerender(vs->ecmascript, "process_snippets");
}
}

View File

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "elinks.h"

View File

@ -17,6 +17,9 @@
#define DEBUG 0
static int assertions;
static int failed_assertions;
static void
mjs_console_assert(js_State *J)
{
@ -28,12 +31,14 @@ mjs_console_assert(js_State *J)
return;
}
bool res = js_toboolean(J, 1);
assertions++;
if (res) {
js_pushundefined(J);
return;
}
FILE *log = fopen(console_error_filename, "a");
failed_assertions++;
if (!log) {
js_pushundefined(J);
@ -107,7 +112,8 @@ mjs_console_exit(js_State *J)
js_pushundefined(J);
return;
}
program.retval = js_toboolean(J, 1) ? RET_ERROR : RET_OK;
fprintf(stderr, "Assertions: %d, failed assertions: %d\n", assertions, failed_assertions);
program.retval = failed_assertions ? RET_ERROR : RET_OK;
program.terminate = 1;
js_pushundefined(J);
}
@ -129,7 +135,7 @@ mjs_console_init(js_State *J)
addmethod(J, "console.assert", mjs_console_assert, 2);
addmethod(J, "console.log", mjs_console_log, 1);
addmethod(J, "console.error", mjs_console_error, 1);
addmethod(J, "console.exit", mjs_console_exit, 1);
addmethod(J, "console.exit", mjs_console_exit, 0);
addmethod(J, "console.toString", mjs_console_toString, 0);
}
js_defglobal(J, "console", JS_DONTENUM);

View File

@ -915,7 +915,19 @@ mjs_document_addEventListener(js_State *J)
}
js_copy(J, 2);
const char *fun = js_ref(J);
struct el_listener *l;
foreach(l, doc_private->listeners) {
if (strcmp(l->typ, method)) {
continue;
}
if (l->fun == fun) {
mem_free(method);
js_pushundefined(J);
return;
}
}
struct el_listener *n = (struct el_listener *)mem_calloc(1, sizeof(*n));
if (!n) {
@ -1003,7 +1015,7 @@ mjs_document_removeEventListener(js_State *J)
if (exc != DOM_NO_ERR || !typ) {
continue;
}
dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
//dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
dom_string_unref(typ);
js_unref(J, l->fun);
@ -1713,9 +1725,9 @@ document_event_handler(dom_event *event, void *pw)
}
// interpreter->heartbeat = add_heartbeat(interpreter);
struct el_listener *l;
struct el_listener *l, *next;
foreach(l, doc_private->listeners) {
foreachsafe(l, next, doc_private->listeners) {
if (strcmp(l->typ, dom_string_data(typ))) {
continue;
}

View File

@ -2196,7 +2196,19 @@ mjs_element_addEventListener(js_State *J)
}
js_copy(J, 2);
const char *fun = js_ref(J);
struct ele_listener *l;
foreach(l, el_private->listeners) {
if (strcmp(l->typ, method)) {
continue;
}
if (l->fun == fun) {
mem_free(method);
js_pushundefined(J);
return;
}
}
struct ele_listener *n = (struct ele_listener *)mem_calloc(1, sizeof(*n));
if (!n) {
@ -2284,7 +2296,7 @@ mjs_element_removeEventListener(js_State *J)
if (exc != DOM_NO_ERR || !typ) {
continue;
}
dom_event_target_remove_event_listener(el, typ, el_private->listener, false);
//dom_event_target_remove_event_listener(el, typ, el_private->listener, false);
dom_string_unref(typ);
js_unref(J, l->fun);
@ -3325,9 +3337,9 @@ element_event_handler(dom_event *event, void *pw)
}
// interpreter->heartbeat = add_heartbeat(interpreter);
struct ele_listener *l;
struct ele_listener *l, *next;
foreach(l, el_private->listeners) {
foreachsafe(l, next, el_private->listeners) {
if (strcmp(l->typ, dom_string_data(typ))) {
continue;
}

View File

@ -21,6 +21,9 @@
static JSClassID js_console_class_id;
static int assertions;
static int failed_assertions;
static JSValue
js_console_assert(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
{
@ -33,11 +36,13 @@ js_console_assert(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst
return JS_UNDEFINED;
}
bool res = JS_ToBool(ctx, argv[0]);
assertions++;
if (res) {
return JS_UNDEFINED;
}
FILE *log = fopen(console_error_filename, "a");
failed_assertions++;
if (!log) {
return JS_UNDEFINED;
@ -123,7 +128,8 @@ js_console_exit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *a
if (!program.testjs) {
return JS_UNDEFINED;
}
program.retval = JS_ToBool(ctx, argv[0]) ? RET_ERROR : RET_OK;
fprintf(stderr, "Assertions: %d, failed assertions: %d\n", assertions, failed_assertions);
program.retval = failed_assertions ? RET_ERROR : RET_OK;
program.terminate = 1;
return JS_UNDEFINED;
}
@ -143,7 +149,7 @@ static const JSCFunctionListEntry js_console_funcs[] = {
JS_CFUNC_DEF("assert", 2, js_console_assert),
JS_CFUNC_DEF("log", 1, js_console_log),
JS_CFUNC_DEF("error", 1, js_console_error),
JS_CFUNC_DEF("exit", 1, js_console_exit),
JS_CFUNC_DEF("exit", 0, js_console_exit),
JS_CFUNC_DEF("toString", 0, js_console_toString)
};

View File

@ -988,9 +988,19 @@ js_document_addEventListener(JSContext *ctx, JSValueConst this_val, int argc, JS
if (!method) {
return JS_EXCEPTION;
}
JSValue fun = argv[1];
struct document_listener *l;
foreach(l, doc_private->listeners) {
if (strcmp(l->typ, method)) {
continue;
}
if (JS_VALUE_GET_PTR(l->fun) == JS_VALUE_GET_PTR(fun)) {
mem_free(method);
return JS_UNDEFINED;
}
}
struct document_listener *n = (struct document_listener *)mem_calloc(1, sizeof(*n));
if (!n) {
@ -1107,7 +1117,7 @@ js_document_removeEventListener(JSContext *ctx, JSValueConst this_val, int argc,
if (exc != DOM_NO_ERR || !typ) {
continue;
}
dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
//dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
dom_string_unref(typ);
del_from_list(l);
@ -1897,9 +1907,9 @@ document_event_handler(dom_event *event, void *pw)
}
// interpreter->heartbeat = add_heartbeat(interpreter);
struct document_listener *l;
struct document_listener *l, *next;
foreach(l, doc_private->listeners) {
foreachsafe(l, next, doc_private->listeners) {
if (strcmp(l->typ, dom_string_data(typ))) {
continue;
}

View File

@ -2243,9 +2243,19 @@ js_element_addEventListener(JSContext *ctx, JSValueConst this_val, int argc, JSV
if (!method) {
return JS_EXCEPTION;
}
JSValue fun = argv[1];
struct element_listener *l;
foreach(l, el_private->listeners) {
if (strcmp(l->typ, method)) {
continue;
}
if (JS_VALUE_GET_PTR(l->fun) == JS_VALUE_GET_PTR(fun)) {
mem_free(method);
return JS_UNDEFINED;
}
}
struct element_listener *n = (struct element_listener *)mem_calloc(1, sizeof(*n));
if (!n) {
@ -2337,7 +2347,7 @@ js_element_removeEventListener(JSContext *ctx, JSValueConst this_val, int argc,
if (exc != DOM_NO_ERR || !typ) {
continue;
}
dom_event_target_remove_event_listener(el, typ, el_private->listener, false);
//dom_event_target_remove_event_listener(el, typ, el_private->listener, false);
dom_string_unref(typ);
del_from_list(l);
@ -3562,9 +3572,9 @@ element_event_handler(dom_event *event, void *pw)
}
// interpreter->heartbeat = add_heartbeat(interpreter);
struct element_listener *l;
struct element_listener *l, *next;
foreach(l, el_private->listeners) {
foreachsafe(l, next, el_private->listeners) {
if (strcmp(l->typ, dom_string_data(typ))) {
continue;
}

View File

@ -63,10 +63,13 @@ const spidermonkeyFunctionSpec console_funcs[] = {
{ "assert", console_assert, 2 },
{ "log", console_log, 1 },
{ "error", console_error, 1 },
{ "exit", console_exit, 1 },
{ "exit", console_exit, 0 },
{ NULL }
};
static int assertions;
static int failed_assertions;
static bool
console_assert(JSContext *ctx, unsigned int argc, JS::Value *vp)
{
@ -76,11 +79,13 @@ console_assert(JSContext *ctx, unsigned int argc, JS::Value *vp)
if (argc < 1 || !get_opt_bool("ecmascript.enable_console_log", NULL)) {
return true;
}
assertions++;
bool res = jsval_to_boolean(ctx, args[0]);
if (res) {
return true;
}
failed_assertions++;
FILE *log = fopen(console_error_filename, "a");
if (!log) {
@ -161,7 +166,8 @@ console_exit(JSContext *ctx, unsigned int argc, JS::Value *vp)
if (!program.testjs) {
return true;
}
program.retval = args[0].toBoolean() ? RET_ERROR : RET_OK;
fprintf(stderr, "Assertions: %d, failed assertions: %d\n", assertions, failed_assertions);
program.retval = failed_assertions ? RET_ERROR : RET_OK;
program.terminate = 1;
return true;
}

View File

@ -64,6 +64,9 @@
#include "viewer/text/vs.h"
#include <iostream>
#include <map>
static std::map<void *, bool> handler_privates;
struct el_listener {
LIST_HEAD_EL(struct el_listener);
@ -92,6 +95,12 @@ static void document_finalize(JS::GCContext *op, JSObject *obj)
struct document_private *doc_private = JS::GetMaybePtrFromReservedSlot<struct document_private>(obj, 1);
if (doc_private) {
auto h = handler_privates.find(doc_private);
if (h != handler_privates.end()) {
handler_privates.erase(h);
}
struct el_listener *l;
if (doc_private->listener) {
@ -1391,9 +1400,19 @@ document_addEventListener(JSContext *ctx, unsigned int argc, JS::Value *rval)
args.rval().setUndefined();
return true;
}
JS::RootedValue fun(ctx, args[1]);
struct el_listener *l;
foreach(l, doc_private->listeners) {
if (strcmp(l->typ, method)) {
continue;
}
if (l->fun == fun) {
mem_free(method);
args.rval().setUndefined();
return true;
}
}
struct el_listener *n = (struct el_listener *)mem_calloc(1, sizeof(*n));
if (!n) {
@ -1414,6 +1433,7 @@ document_addEventListener(JSContext *ctx, unsigned int argc, JS::Value *rval)
args.rval().setUndefined();
return true;
}
handler_privates[doc_private] = true;
}
dom_string *typ = NULL;
exc = dom_string_create(method, strlen(method), &typ);
@ -1480,7 +1500,6 @@ document_removeEventListener(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
JS::RootedValue fun(ctx, args[1]);
struct el_listener *l;
foreach(l, doc_private->listeners) {
@ -1495,7 +1514,7 @@ document_removeEventListener(JSContext *ctx, unsigned int argc, JS::Value *rval)
if (exc != DOM_NO_ERR || !typ) {
continue;
}
dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
//dom_event_target_remove_event_listener(doc, typ, doc_private->listener, false);
dom_string_unref(typ);
del_from_list(l);
@ -1728,11 +1747,15 @@ document_event_handler(dom_event *event, void *pw)
JSAutoRealm ar(ctx, (JSObject *)interpreter->ac->get());
JS::RootedValue r_val(ctx);
interpreter->heartbeat = add_heartbeat(interpreter);
if (!event) {
return;
}
auto h = handler_privates.find(doc_private);
if (h == handler_privates.end()) {
return;
}
dom_string *typ = NULL;
dom_exception exc = dom_event_get_type(event, &typ);
@ -1741,10 +1764,9 @@ document_event_handler(dom_event *event, void *pw)
}
JSObject *obj_ev = getEvent(ctx, event);
interpreter->heartbeat = add_heartbeat(interpreter);
struct el_listener *l, *next;
struct el_listener *l;
foreach(l, doc_private->listeners) {
foreachsafe(l, next, doc_private->listeners) {
if (strcmp(l->typ, dom_string_data(typ))) {
continue;
}
@ -2328,7 +2350,6 @@ getDocument(JSContext *ctx, void *doc)
init_list(doc_private->listeners);
doc_private->ref_count = 1;
doc_private->doc = doc;
JSObject *el = JS_NewObject(ctx, &document_class);
if (!el) {
@ -2368,7 +2389,6 @@ initDocument(JSContext *ctx, struct ecmascript_interpreter *interpreter, JSObjec
init_list(doc_private->listeners);
doc_private->ref_count = 1;
JS::SetReservedSlot(document_obj, 0, JS::PrivateValue(doc));
JS::SetReservedSlot(document_obj, 1, JS::PrivateValue(doc_private));

View File

@ -3873,7 +3873,18 @@ element_addEventListener(JSContext *ctx, unsigned int argc, JS::Value *rval)
}
char *method = jsval_to_string(ctx, args[0]);
JS::RootedValue fun(ctx, args[1]);
struct ele_listener *l;
foreach(l, el_private->listeners) {
if (strcmp(l->typ, method)) {
continue;
}
if (l->fun == fun) {
mem_free(method);
args.rval().setUndefined();
return true;
}
}
struct ele_listener *n = (struct ele_listener *)mem_calloc(1, sizeof(*n));
if (!n) {
@ -3975,7 +3986,7 @@ element_removeEventListener(JSContext *ctx, unsigned int argc, JS::Value *rval)
if (exc != DOM_NO_ERR || !typ) {
continue;
}
dom_event_target_remove_event_listener(el, typ, el_private->listener, false);
//dom_event_target_remove_event_listener(el, typ, el_private->listener, false);
dom_string_unref(typ);
del_from_list(l);
@ -5407,9 +5418,9 @@ element_event_handler(dom_event *event, void *pw)
JSObject *obj_ev = getEvent(ctx, event);
interpreter->heartbeat = add_heartbeat(interpreter);
struct ele_listener *l;
struct ele_listener *l, *next;
foreach(l, el_private->listeners) {
foreachsafe(l, next, el_private->listeners) {
if (strcmp(l->typ, dom_string_data(typ))) {
continue;
}

View File

@ -76,6 +76,10 @@ check_stdio(LIST_OF(struct string_list_item) *url_list)
{
assert(!remote_session_flags);
if (program.testjs) {
return;
}
/* Should the document be read from stdin? */
if (!isatty(STDIN_FILENO)) {
/* Only start reading from stdin if no URL was given on the

View File

@ -896,7 +896,9 @@ get_ctl_handle(void)
{
static int fd = -1;
if (isatty(0)) return 0;
if (isatty(0)) {
return 0;
}
if (fd < 0) fd = open("/dev/tty", O_RDONLY);
return fd;
}

View File

@ -4,5 +4,5 @@ var url = new URL('https://www.example.com/cats');
console.assert(url.pathname === '/cats', url.pathname);
console.assert(url.protocol === 'https:', url.protocol);
console.assert(url.hostname === 'www.example.com', url.hostname);
console.exit(0);
console.exit();
</script>

View File

@ -0,0 +1,7 @@
#!/bin/sh
d=$(dirname "$0")
for i in $d/*.html; do
readlink -f "$i"
done

View File

@ -2,5 +2,5 @@
console.error("console.assert.html");
console.assert(0 % 2 === 0, "O is not even");
console.assert(1 % 2 === 0, "1 is not even");
console.exit(0);
console.exit();
</script>

View File

@ -8,5 +8,5 @@ e.preventDefault();
console.assert(e.defaultPrevented, 'defaultPrevented true');
console.assert(e.type === 'message', 'message');
console.assert(e.detail.name === 'cat', 'cat');
console.exit(0);
console.exit();
</script>

View File

@ -17,7 +17,7 @@ function myFunction() {
}
console.error("doctype.publicId.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -17,7 +17,7 @@ function myFunction() {
}
console.error("doctype.systemId.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -22,7 +22,7 @@ function myFunction() {
console.error('document.anchors.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -13,7 +13,7 @@ function myFunction() {
console.error('document.baseURI.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>
</html>

View File

@ -25,7 +25,7 @@ function myFunction() {
console.error('document.body.childNodes');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -22,7 +22,7 @@ function myFunction() {
console.error('document.body.children');
myFunction();
console.exit(0);
console.exit();
</script>

View File

@ -17,7 +17,7 @@ function myFunction() {
console.error('document.body.id.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -18,7 +18,7 @@ function myFunction() {
console.error('document.characterSet');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -18,7 +18,7 @@ function myFunction() {
console.error('document.doctype.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -17,7 +17,7 @@ function myFunction() {
console.error('document.documentElement.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -13,7 +13,7 @@ function myFunction() {
console.error('document.documentURI.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>
</html>

View File

@ -16,7 +16,7 @@ function myFunction() {
console.error('document.domain.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -19,7 +19,7 @@ function myFunction() {
console.error('document.getElementsByClassName.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -19,7 +19,7 @@ function myFunction() {
console.error('document.getElementsByName.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -19,7 +19,7 @@ function myFunction() {
console.error('document.getElementsByTagName.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -18,7 +18,7 @@ function myFunction() {
console.error('document.head.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -19,7 +19,7 @@ function myFunction() {
console.error('document.images.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -31,7 +31,7 @@ function myFunction() {
console.error('document.links.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -17,7 +17,7 @@ function myFunction() {
console.error('document.querySelector.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -15,7 +15,7 @@ function myFunction() {
console.error('document.querySelectorAll.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -23,7 +23,7 @@ function myFunction() {
}
console.error('element.appendChild.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -19,7 +19,7 @@ function myFunction() {
console.error('element.attributes.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -22,7 +22,7 @@ function ch()
console.error('element.checked.html');
ch();
console.exit(0);
console.exit();
</script>
<button onclick="ch();">CLICK</button>

View File

@ -16,7 +16,7 @@ function bb()
console.error('element.childElementCount.html');
aa();
bb();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">blabla child element count</button>
<button onclick="return bb()">empty child element count</button>

View File

@ -21,7 +21,7 @@ function bb()
console.error('element.className.html');
aa();
bb();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">Click me!</button>
<button onclick="return bb()">Set className to abc</button>

View File

@ -22,7 +22,7 @@ function myFunction() {
console.error('element.cloneNode.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -18,7 +18,7 @@ console.assert(closes2 != null, 'not null');
closes2 = element.closest("p.test");
console.assert(closes2 === null, 'NULL');
console.exit(0);
console.exit();
</script>
</body>

View File

@ -32,7 +32,7 @@ function myFunction() {
console.error('element.contains.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -24,7 +24,7 @@ function bb()
console.error('element.dir.html');
aa();
bb();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">Click me!</button>
<button onclick="return bb()">blabla.dir = ltr</button>

View File

@ -6,7 +6,7 @@
function ff(ev)
{
console.assert(ev.type === 'message', ev.type);
console.exit(0);
console.exit();
}
var e = new Event('message', { cancelable: true });

View File

@ -14,7 +14,7 @@ function aa()
console.error('element.firstChild.html');
aa();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">Click me!</button>
</body>

View File

@ -14,7 +14,7 @@ function aa()
console.error('element.firstElementChild');
aa();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">blabla firstElementChild outerHTML</button>
</body>

View File

@ -22,7 +22,7 @@ function bb()
console.error('element.getAttribute.html');
aa();
bb();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">blabla rel nofollow</button>
<button onclick="return bb()">ble href null</button>

View File

@ -21,7 +21,7 @@ function myFunction() {
console.error('element.getAttributeNode.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>
</html>

View File

@ -19,7 +19,7 @@ function myFunction() {
console.error('element.getElementByTagName.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -22,7 +22,7 @@ function bb()
console.error('element.hasAttribute.html');
aa();
bb();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">blabla rel true</button>
<button onclick="return bb()">ble href false</button>

View File

@ -15,7 +15,7 @@ function aa()
console.error('element.hasAttributes.html');
aa();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">blabla has attributes</button>
</body>

View File

@ -25,7 +25,7 @@ function myFunction() {
console.error('element.hasChildNodes.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -8,7 +8,7 @@ console.error('element.id.html');
console.assert(document.getElementById('blabla').innerHTML === 'AAAAA', 'AAAAA');
document.getElementsByTagName("A")[0].id = 'test';
console.assert(document.getElementById('test').innerHTML === 'inner', 'inner');
console.exit(0);
console.exit();
</script>
</body>
</html>

View File

@ -25,7 +25,7 @@ function bb()
console.error('element.innerHTML.html');
aa();
bb();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">Click me!</button>
<button onclick="return bb()">innerText test</button>

View File

@ -26,7 +26,7 @@ function myFunction() {
console.error('element.insertBefore.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -30,7 +30,7 @@ function testFunction(x, y, expected) {
console.error('element.isEqualNode.html');
testFunction('myList1', 'myList2', false);
testFunction('myList1', 'myList3', true);
console.exit(0);
console.exit();
</script>
</body>

View File

@ -24,7 +24,7 @@ function myFunction() {
console.error('element.isSameNode.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -22,7 +22,7 @@ function bb()
console.error('element.lang.html');
testaa('en');
bb();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">Click me!</button>
<button onclick="return bb()">Set lang to pl</button>

View File

@ -13,7 +13,7 @@ function aa()
console.error('element.lastChild.html');
aa();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">Click me!</button>
</body>

View File

@ -14,7 +14,7 @@ function aa()
console.error('element.lastElementChild.html');
aa();
console.exit(0);
console.exit();
</script>
<button onclick="return aa()">blabla lastElementChild outerHTML</button>
</body>

View File

@ -28,6 +28,6 @@ console.error('element.matches.html');
// });
// console.assert(counter === 3, 'Three');
console.exit(0);
console.exit();
</script>

View File

@ -20,7 +20,7 @@ function myFunction() {
console.error('element.namedItem.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -25,7 +25,7 @@ function myFunction() {
console.error("element.nextElementSibling.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -25,7 +25,7 @@ function myFunction() {
console.error("element.nextSibling.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -15,7 +15,7 @@ function myFunction() {
}
console.error("element.nodeName.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -15,7 +15,7 @@ function myFunction() {
}
console.error("element.nodeType.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -15,7 +15,7 @@ function myFunction() {
}
console.error("element.nodeValue.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -26,7 +26,7 @@ function bb()
console.error('element.outerHTML.html');
aa();
bb();
console.exit(0);
console.exit();
</script>
</body>
</html>

View File

@ -22,7 +22,7 @@ function myFunction() {
}
console.error("element.parentElement.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -22,7 +22,7 @@ function myFunction() {
}
console.error("element.parentNode.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -24,7 +24,7 @@ function myFunction() {
}
console.error("element.previousElementSibling.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -24,7 +24,7 @@ function myFunction() {
}
console.error("element.previousSibling.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -24,7 +24,7 @@ function myFunction() {
console.error('element.querySelector.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -20,7 +20,7 @@ function myFunction() {
console.error('element.querySelectorAll.html');
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -25,7 +25,7 @@ function myFunction() {
}
console.error("element.setAttribute.html");
myFunction();
console.exit(0);
console.exit();
</script>
</body>

View File

@ -8,5 +8,5 @@ console.assert(!e.defaultPrevented, 'false');
e.preventDefault();
console.assert(e.defaultPrevented, 'true');
console.assert(e.type === 'message', 'message');
console.exit(0);
console.exit();
</script>

View File

@ -3,7 +3,7 @@
function ff(ev)
{
console.assert(ev.type === 'message', ev.type);
console.exit(0);
console.exit();
}
var e = new Event('message', { cancelable: true });

View File

@ -13,5 +13,5 @@ console.assert(e.keyCode === 13, 'ENTER = 13');
var e = new KeyboardEvent('keydown', { cancelable: true, key: "F12" });
console.assert(e.keyCode === 123, e.keyCode);
console.exit(0);
console.exit();
</script>

View File

@ -0,0 +1,91 @@
tofail = [
'console.assert.html',
'document.getElementsByClassName.html',
'document.getElementsByName.html',
'document.head.html',
'element.namedItem.html'
]
took = [
'customEvent.html',
'doctype.publicId.html',
'doctype.systemId.html',
'document.anchors.html',
'document.baseURI.html',
'document.body.childNodes.html',
'document.body.children.html',
'document.body.id.html',
'document.characterSet.html',
'document.doctype.html',
'document.documentElement.html',
'document.documentURI.html',
'document.domain.html',
'document.getElementsByTagName.html',
'document.images.html',
'document.links.html',
'document.querySelectorAll.html',
'document.querySelector.html',
'element.appendChild.html',
'element.attributes.html',
'element.checked.html',
'element.childElementCount.html',
'element.className.html',
'element.cloneNode.html',
'element.closest.html',
'element.contains.html',
'element.dir.html',
'element.eventListener.html',
'element.firstChild.html',
'element.firstElementChild.html',
'element.getAttribute.html',
'element.getAttributeNode.html',
'element.getElementsByTagName.html',
'element.hasAttribute.html',
'element.hasAttributes.html',
'element.hasChildNodes.html',
'element.id.html',
'element.innerHTML.html',
'element.insertBefore.html',
'element.isEqualNode.html',
'element.isSameNode.html',
'element.lang.html',
'element.lastChild.html',
'element.lastElementChild.html',
'element.matches.html',
'element.nextElementSibling.html',
'element.nextSibling.html',
'element.nodeName.html',
'element.nodeType.html',
'element.nodeValue.html',
'element.outerHTML.html',
'element.parentElement.html',
'element.parentNode.html',
'element.previousElementSibling.html',
'element.previousSibling.html',
'element.querySelectorAll.html',
'element.querySelector.html',
'element.setAttribute.html',
'event.html',
'eventListener.html',
'keyboardEvent.html',
'navigator.appCodeName.html',
'nodelist.forEach.html',
'URL.html']
if conf_data.get('CONFIG_ECMASCRIPT')
foreach t: tofail
test(t, elinks, protocol: 'exitcode', is_parallel: true, timeout: 5, should_fail: true, verbose: false, workdir: '/home/witekfl/GIT/elinks/test/ecmascript/assert/',
args: ['--test', '1', '--eval', 'set ecmascript.enable = 1',
'--eval', 'set ecmascript.enable_console_log = 1',
'--eval', 'set ui.sessions.fork_on_start = 0',
'--no-connect', '1',
t])
endforeach
foreach t : took
test(t, elinks, protocol: 'exitcode', is_parallel: true, timeout: 5, should_fail: false, verbose: false, workdir: meson.source_root()+'/test/ecmascript/assert',
args: ['--test', '1', '--eval', 'set ecmascript.enable = 1',
'--eval', 'set ecmascript.enable_console_log = 1',
'--eval', 'set ui.sessions.fork_on_start = 0',
'--no-connect', '1',
t])
endforeach
endif

View File

@ -1,5 +1,5 @@
<script>
console.error("navigator.appCodeName.html");
console.assert(navigator.appCodeName === 'Mozilla', 'Mozilla');
console.exit(0);
console.exit();
</script>

View File

@ -17,6 +17,6 @@ birds.forEach(function(b) {
});
console.assert(counter === 3, counter);
console.exit(0);
console.exit();
</script>

View File

@ -0,0 +1,19 @@
<html>
<head>
<!--<script src="jquery.js"></script>-->
</head>
<body>
<div id="test">A</div>
<script>
function ff()
{
document.removeEventListener("DOMContentLoaded", ff);
alert('Loaded');
}
document.addEventListener("DOMContentLoaded", ff);
//$(document).ready(function(){
// alert('READY');
//});
</script>
</body>
</html>