Skip to content

undef error upon reuse of F.open  #250

@kdillon

Description

@kdillon

Hi!

It seems to me that a block like below should work:

<script type="text/javascript">
QUnit.config.reorder = false;
F.attach(QUnit);

for (let i = 1; i<=2; i++) {
  QUnit.test("Can open page next to test using relative path " + i, assert => {
    var URL = "./PageNextToTest"+i+".html";
    F.open(URL);
    F.add(() => {
      assert.ok(1);
    });
    F.wait(() => {
      F.win.close();
    });
  })
}
</script>

But we get

TypeError: Cannot read property 'replace' of undefined
at urlWithoutHash (https://localhost:31515/test/tools/javascript/libs/funcunit/funcunit.js:8987:24)
at isCurrentPage (https://localhost:31515/test/tools/javascript/libs/funcunit/funcunit.js:8989:28)
at Function._open (https://localhost:31515/test/tools/javascript/libs/funcunit/funcunit.js:9041:21)
at Object.method (https://localhost:31515/test/tools/javascript/libs/funcunit/funcunit.js:9005:34)
at https://localhost:31515/test/tools/javascript/libs/funcunit/funcunit.js:9585:26

It appears as though the funcunit.win object is not null after the window is closed. It seems reasonable to me that it should be null, but basically upon the 2nd time through, we consider the window to still be open (newpage becomes false), even though there is no child window.

So when we go to use _open, it falls through and looks for a window that already exists. It finds this not-null FuncUnit.win object, tries to parse the URL, and barfs because the URL is undef.

The fix for this could be pretty easy. We could just check the window object. If that is null, we open a new window. If the window object is not-null but has undef url we open a new window.

Thoughts? Thanks

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