') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); [wasm] Fix some failing `System.Runtime.InteropServices.JavaScript.Tests` by pavelsavara · Pull Request #71976 · dotnet/runtime · GitHub
Skip to content

[wasm] Fix some failing System.Runtime.InteropServices.JavaScript.Tests - #71976

Merged
radical merged 2 commits into
dotnet:mainfrom
pavelsavara:wasm_protect_class_names
Jul 12, 2022
Merged

[wasm] Fix some failing System.Runtime.InteropServices.JavaScript.Tests#71976
radical merged 2 commits into
dotnet:mainfrom
pavelsavara:wasm_protect_class_names

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Jul 11, 2022

Copy link
Copy Markdown
Member
  • protect class names from mangling. Fixes:
    • System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportException
    • System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportException
    • See log
[16:44:33] fail: [FAIL] System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportException(value: System.Exception: Test, clazz: "ManagedError")
[16:44:33] info: Assert.Equal() Failure
[16:44:33] info: ↓ (pos 0)
[16:44:33] info: Expected: ManagedError
[16:44:33] info: Actual: jr
[16:44:33] info: ↑ (pos 0)
[16:44:33] info: at System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JsImportTest[Exception](Exception value, Action`1 store1, Func`1 retrieve1, Func`2 echo1, Func`2 throw1, Func`2 identity1, String jsType, String jsClass)
[16:44:33] info: at System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportException(Exception value, String clazz)
[16:44:33] info: at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
[16:44:33] fail: [FAIL] System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportObject(value: Object { }, clazz: "ManagedObject")
[16:44:33] info: Assert.Equal() Failure
[16:44:33] info: ↓ (pos 0)
[16:44:33] info: Expected: ManagedObject
[16:44:33] info: Actual: Rr
[16:44:33] info: ↑ (pos 0)
[16:44:33] info: at System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JsImportTest[Object](Object value, Action`1 store1, Func`1 retrieve1, Func`2 echo1, Func`2 throw1, Func`2 identity1, String jsType, String jsClass)
[16:44:33] info: at System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportObject(Object value, String clazz)
[16:44:33] info: at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)

Fixes#71952

@pavelsavarapavelsavara added this to the 7.0.0 milestone Jul 11, 2022
@pavelsavara
pavelsavara requested review from kg and radicalJuly 11, 2022 21:36
@pavelsavarapavelsavara self-assigned this Jul 11, 2022
@pavelsavara
pavelsavara requested a review from lewing as a code ownerJuly 11, 2022 21:36
@ghost

Copy link
Copy Markdown

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes [FAIL] System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportException
and [FAIL] System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JSImportException

See log

Author:pavelsavara
Assignees:pavelsavara
Labels:

arch-wasm, area-System.Runtime.InteropServices.JavaScript

Milestone:7.0.0

.. failing as:
```
[09:26:02] fail: [FAIL] System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.JsImportObjectArray
[09:26:02] info: System.Runtime.InteropServices.JavaScript.JSException : Error: Assert failed: ES6 module JavaScriptTestHelper was not imported yet, please call JSHost.Import() first.
[09:26:02] info: at mono_wasm_lookup_function (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:131530)
[09:26:02] info: at Object.mono_wasm_bind_js_function (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:129592)
[09:26:02] info: at _mono_wasm_bind_js_function (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:103196)
[09:26:02] info: at do_icall (do_icall (<anonymous>:wasm-function[320]):0x1d48)e
[09:26:02] info: at do_icall_wrapper (do_icall_wrapper (<anonymous>:wasm-function[290]):0x1c89)3
[09:26:02] info: at interp_exec_method (interp_exec_method (<anonymous>:wasm-function[228]):0xe11)9
[09:26:02] info: at interp_runtime_invoke (interp_runtime_invoke (<anonymous>:wasm-function[227]):0xcfe)5
[09:26:02] info: at mono_jit_runtime_invoke (mono_jit_runtime_invoke (<anonymous>:wasm-function[8109]):0x1a141)9
[09:26:02] info: at do_runtime_invoke (do_runtime_invoke (<anonymous>:wasm-function[2050]):0x84c9)3
[09:26:02] info: at mono_runtime_try_invoke (mono_runtime_try_invoke (<anonymous>:wasm-function[2055]):0x852f)b
[09:26:02] info: at mono_runtime_invoke (mono_runtime_invoke (<anonymous>:wasm-function[2082]):0x873b)a
[09:26:02] info: at mono_wasm_invoke_method_ref (mono_wasm_invoke_method_ref (<anonymous>:wasm-function[121]):0x9ce0)
[09:26:02] info: at Module._mono_wasm_invoke_method_ref (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:125660)
[09:26:02] info: at Object.t.<computed> (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:5668)
[09:26:02] info: at _call_method_with_converted_args (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:68736)
[09:26:02] info: at call_method_ref (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:67909)
[09:26:02] info: at /datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:69762
[09:26:02] info: at mono_call_assembly_entry_point (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:69894)
[09:26:02] info: at Object.mono_run_main (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:78650)
[09:26:02] info: at Object.init (test-main.js:495:47)
[09:26:02] info: at Object.onDotnetReady (test-main.js:439:17)
[09:26:02] info: at finalize_startup (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:120653)
[09:26:02] info: at mono_wasm_after_runtime_initialized (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:3:116586)
[09:26:02] info: at callRuntimeCallbacks (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:16200)
[09:26:02] info: at postRun (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:12076)
[09:26:02] info: at doRun (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:144539)
[09:26:02] info: at run (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:144696)
[09:26:02] info: at runCaller (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:144176)
[09:26:02] info: at removeRunDependency (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:12868)
[09:26:02] info: at receiveInstance (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:14757)
[09:26:02] info: at receiveInstantiationResult (/datadisks/disk1/work/98BF08F2/w/A36B0892/e/dotnet.js:12:14878)
[09:26:02] info: at System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunctionImpl(String functionName, String moduleName, ReadOnlySpan`1 signatures)
[09:26:02] info: at System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction(String functionName, String moduleName, ReadOnlySpan`1 signatures)
[09:26:02] info: at System.Runtime.InteropServices.JavaScript.Tests.JavaScriptTestHelper.createData(String name)
[09:26:02] info: at System.Runtime.InteropServices.JavaScript.Tests.JSImportExportTest.MarshalObjectArrayCases()+MoveNext()
[09:26:02] info: at System.Linq.Enumerable.SelectEnumerableIterator`2[[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object[], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
```
This is because the xunit is enumerating the member data before the
static `InitializeAsync` has completed. And this member data calls
`JavaScriptTestHelper.createData("test")` before we are ready.
Fixesdotnet#71952 .
@radical

Copy link
Copy Markdown
Member

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@radicalradical changed the title [wasm] protect class names from mangling[wasm] Fix some failing System.Runtime.InteropServices.JavaScript.TestsJul 11, 2022
Comment threadsrc/mono/wasm/runtime/rollup.config.js
kg
kg approved these changes Jul 11, 2022
@radical

Copy link
Copy Markdown
Member

Failures will be fixed by #71875 .

@radical
radical merged commit 5ab4175 into dotnet:mainJul 12, 2022
@pavelsavara
pavelsavara deleted the wasm_protect_class_names branch July 14, 2022 20:47
@ghostghost locked as resolved and limited conversation to collaborators Aug 14, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

3 participants

@pavelsavara@radical@kg