Giter VIP home page Giter VIP logo

Comments (2)

krichprollsch avatar krichprollsch commented on August 11, 2024

A test for browsercore:

diff --git a/src/xhr/xhr.zig b/src/xhr/xhr.zig
index 90150e4..cc4c42b 100644
--- a/src/xhr/xhr.zig
+++ b/src/xhr/xhr.zig
@@ -827,4 +827,16 @@ pub fn testExecFn(
         .{ .src = "req4.responseText.length > 64", .ex = "true" },
     };
     try checkCases(js_env, &post);
+
+    var cbk = [_]Case{
+        .{ .src = "const req5 = new XMLHttpRequest()", .ex = "undefined" },
+        .{ .src = "req5.open('GET', 'http://httpbin.io/json')", .ex = "undefined" },
+        .{ .src = "var status = 0; req5.onload = () { status = this.status };", .ex = "undefined" },
+        .{ .src = "req5.send()", .ex = "undefined" },
+
+        // Each case executed waits for all loop callaback calls.
+        // So the url has been retrieved.
+        .{ .src = "status", .ex = "200" },
+    };
+    try checkCases(js_env, &cbk);
 }

from zig-js-runtime.

krichprollsch avatar krichprollsch commented on August 11, 2024

The spec for events says:

Invoke callback with one argument, the value of which is the Event object event, with the callback this value set to event's currentTarget. Let return value be the callback's return value. [WEBIDL]

https://html.spec.whatwg.org/#event-handler-attributes

this in MDN ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this and paragraph about DOM events: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#this_in_dom_event_handlers

When a function is used as an event handler, its this parameter is bound to the DOM element on which the listener is placed (some browsers do not follow this convention for listeners added dynamically with methods other than addEventListener()).

from zig-js-runtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.