Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undef error upon reuse of F.open #250

Open
kdillon opened this issue Oct 22, 2019 · 0 comments
Open

undef error upon reuse of F.open #250

kdillon opened this issue Oct 22, 2019 · 0 comments

Comments

@kdillon
Copy link
Collaborator

kdillon commented Oct 22, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant