MCPcopy Index your code
hub / github.com/nodejs/node / WindowTestEnvironment

Function WindowTestEnvironment

test/fixtures/wpt/resources/testharness.js:51–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 * apisample11.html and apisample12.html.
50 */
51 function WindowTestEnvironment() {
52 this.name_counter = 0;
53 this.window_cache = null;
54 this.output_handler = null;
55 this.all_loaded = false;
56 var this_obj = this;
57 this.message_events = [];
58 this.dispatched_messages = [];
59
60 this.message_functions = {
61 start: [add_start_callback, remove_start_callback,
62 function (properties) {
63 this_obj._dispatch("start_callback", [properties],
64 {type: "start", properties: properties});
65 }],
66
67 test_state: [add_test_state_callback, remove_test_state_callback,
68 function(test) {
69 this_obj._dispatch("test_state_callback", [test],
70 {type: "test_state",
71 test: test.structured_clone()});
72 }],
73 result: [add_result_callback, remove_result_callback,
74 function (test) {
75 this_obj.output_handler.show_status();
76 this_obj._dispatch("result_callback", [test],
77 {type: "result",
78 test: test.structured_clone()});
79 }],
80 completion: [add_completion_callback, remove_completion_callback,
81 function (tests, harness_status, asserts) {
82 var cloned_tests = map(tests, function(test) {
83 return test.structured_clone();
84 });
85 this_obj._dispatch("completion_callback", [tests, harness_status],
86 {type: "complete",
87 tests: cloned_tests,
88 status: harness_status.structured_clone(),
89 asserts: asserts.map(assert => assert.structured_clone())});
90 }]
91 };
92
93 on_event(window, 'load', function() {
94 setTimeout(() => {
95 this_obj.all_loaded = true;
96 if (tests.all_done()) {
97 tests.complete();
98 }
99 },0);
100 });
101
102 on_event(window, 'message', function(event) {
103 if (event.data && event.data.type === "getmessages" && event.source) {
104 // A window can post "getmessages" to receive a duplicate of every
105 // message posted by this environment so far. This allows subscribers
106 // from fetch_tests_from_window to 'catch up' to the current state of
107 // this environment.
108 for (var i = 0; i < this_obj.dispatched_messages.length; ++i)

Callers

nothing calls this directly

Calls 7

_dispatchMethod · 0.80
mapFunction · 0.70
on_eventFunction · 0.70
mapMethod · 0.65
setTimeoutFunction · 0.50
completeMethod · 0.45
postMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…