Skip to content

'__GeneratorFunction()' visible on globalThis #2374

@rbri

Description

@rbri

The last refactroings leaking the '__GeneratorFunction()' into the properties of the globalThis object

(found while using the current head (277cf99) in HtmlUnit)

Test case:

@Test
public void todo() {
    final String script =
            "var all = [];" +
            "for (var property in this) {" +
            "  if (typeof this[property] == 'function') {" +
            "    all.push(property + '()');" +
            "  } else {" +
            "    all.push(property);" +
            "  }" +
            "}" +
            "all.sort();" +
            "all.join()";

    Utils.runWithAllModes(
        Utils.contextFactoryWithFeatures(),
        cx -> {
            TopLevel scope = cx.initSafeStandardObjects();

            Object result = cx.evaluateString(scope, script, "test_script", 1, null);
            assertEquals("__GeneratorFunction(),all,global,property", result);  // this is wrong __GeneratorFunction() should not be visible here
            return null;
        });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions