Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/core/utils/parse-crossorigin-stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function parseCrossOriginStylesheet(
importedUrls,
isCrossOrigin
) {
if (url == null) {
return Promise.resolve();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am following the pattern of the early return in parseSameOriginStylesheet if rules is falsy, but let me know if a different result should be returned (or if the function should do an early reject instead?)

}

/**
* Add `url` to `importedUrls`
*/
Expand Down
31 changes: 31 additions & 0 deletions test/core/utils/parse-crossorigin-stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,35 @@ describe('axe.utils.parseCrossOriginStylesheet', function () {
done();
});
});

it('returns empty results when url is nullish', function (done) {
this.timeout(axe.constants.preload.timeout + 1000);

var importUrl = null;
var options = {
rootNode: document,
shadowId: undefined,
convertDataToStylesheet: convertDataToStylesheet,
rootIndex: 1
};
var priority = [1, 0];
var importedUrls = [];
var isCrossOriginRequest = true;

axe.utils
.parseCrossOriginStylesheet(
importUrl,
options,
priority,
importedUrls,
isCrossOriginRequest
)
.then(function (data) {
assert.isUndefined(data);
done();
})
.catch(function (err) {
done(err);
});
});
});