undef error upon reuse of F.open
- Dominant language
- JavaScript
- Stars
- 571
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
It seems to me that a block like below should work:
```
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();
});
})
}
```
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
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the loop with QUnit, F.open, F.add, F.wait, and F.win.close, then inspect the funcunit.js stack locations around urlWithoutHash, isCurrentPage, and Function._open. Verify that reusing F.open after closing the first window no longer raises the undefined replace error and opens the next page.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100