Skip to content

Commit

Permalink
Merge pull request magento#5241 from magento-arcticfoxes/MC-17563
Browse files Browse the repository at this point in the history
[arcticfoxes] MC-17563: requirejs/domReady.js can severely delay rendering of content
  • Loading branch information
joanhe authored Jan 23, 2020
2 parents ff08e30 + 40a0f3f commit 0f2bd67
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,30 @@
<group value="search"/>
<group value="mtf_migrated"/>
</annotations>

<before>
<createData entity="_defaultCategory" stepKey="createCategory1"/>
<createData entity="SimpleProduct" stepKey="createProduct1">
<requiredEntity createDataKey="createCategory1"/>
</createData>

<!-- Perform reindex and flush cache -->
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
<magentoCLI command="cache:flush" stepKey="flushCache"/>
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnStorefrontPage1"/>
<waitForPageLoad stepKey="waitForPageLoad1"/>
</before>
<after>
<actionGroup ref="logout" stepKey="logoutOfAdmin1"/>

<deleteData createDataKey="createProduct1" stepKey="deleteSimpleProduct1"/>
<deleteData createDataKey="createCategory1" stepKey="deleteCategory1"/>

<!-- Delete all search terms -->
<amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openAdminCatalogSearchTermIndexPage"/>
<waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/>
<comment userInput="Delete all search terms" stepKey="deleteAllSearchTermsComment"/>
<actionGroup ref="DeleteAllSearchTerms" stepKey="deleteAllSearchTerms"/>

<actionGroup ref="logout" stepKey="logoutOfAdmin1"/>
</after>

<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="quickSearchByProductName1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,8 @@
</annotations>
<before>
<!-- Login as admin -->
<comment userInput="Login as admin" stepKey="loginAsAdminComment"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<!-- Go to the catalog search term page -->
<comment userInput="Go to the catalog search term page" stepKey="goToSearchTermPageComment"/>
<amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openAdminCatalogSearchTermIndexPage"/>
<waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/>
<!-- Delete all search terms -->
<comment userInput="Delete all search terms" stepKey="deleteAllSearchTermsComment"/>
<actionGroup ref="DeleteAllSearchTerms" stepKey="deleteAllSearchTerms"/>
<actionGroup ref="deleteAllProductsUsingProductGrid" stepKey="deleteAllProducts"/>
<!-- Create product with description -->
<comment userInput="Create product with description" stepKey="createProductWithDescriptionComment"/>
<createData entity="SimpleProductWithDescription" stepKey="simpleProduct"/>

<!-- Perform reindex and flush cache -->
Expand All @@ -39,51 +29,40 @@
</before>
<after>
<!-- Delete created product -->
<comment userInput="Delete created product" stepKey="deleteCreatedProductComment"/>
<deleteData createDataKey="simpleProduct" stepKey="deleteProduct"/>
<!-- Go to the catalog search term page -->
<comment userInput="Go to the catalog search term page" stepKey="goToSearchTermPageComment2"/>
<amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openAdminCatalogSearchTermIndexPage"/>
<waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/>
<!-- Filter the search term -->
<comment userInput="Filter search term" stepKey="filterSearchTermComment"/>
<actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterByThirdSearchQuery">
<argument name="searchQuery" value="{{ApiProductDescription.value}}"/>
</actionGroup>
<!-- Delete created below search terms -->
<comment userInput="Delete created below search terms" stepKey="deleteCreatedBelowSearchTermsComment"/>
<actionGroup ref="deleteSearchTerm" stepKey="deleteSearchTerms"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>
<!-- Go to storefront home page -->
<comment userInput="Go to storefront home page" stepKey="goToStorefrontHomePageComment"/>
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>
<!-- Storefront quick search by product name -->
<comment userInput="Storefront quick search by product name" stepKey="storefrontQuickSearchByProductNameComment"/>
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="quickSearchByProductName">
<argument name="phrase" value="{{ApiProductDescription.value}}"/>
</actionGroup>
<!-- Verify search suggestions and select the suggestion from dropdown options -->
<comment userInput="Verify search suggestions and select the suggestion from dropdown options" stepKey="verifySearchSuggestionsComment"/>
<actionGroup ref="StoreFrontSelectDropDownSearchSuggestionActionGroup" stepKey="seeDropDownSearchSuggestion">
<argument name="searchQuery" value="{{ApiProductDescription.value}}"/>
</actionGroup>
<!-- Assert Product storefront main page -->
<comment userInput="See product name" stepKey="seeProductNameComment"/>
<actionGroup ref="StorefrontAssertProductNameOnProductMainPageActionGroup" stepKey="seeProductName">
<argument name="productName" value="$$simpleProduct.name$$"/>
</actionGroup>
<!-- Go to the catalog search term page -->
<comment userInput="Go to the catalog search term page" stepKey="goToSearchTermPageComment3"/>
<amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openAdminCatalogSearchTermIndexPage"/>
<waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/>
<!-- Filter the search term -->
<comment userInput="Filter search term" stepKey="filterSearchTermComment2"/>
<actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterByThirdSearchQuery">
<argument name="searchQuery" value="{{ApiProductDescription.value}}"/>
</actionGroup>
<!-- Assert Search Term in grid -->
<comment userInput="Check is search term in grid or not" stepKey="isSearchTermInGridComment"/>
<see stepKey="seeSearchTermInGrid" selector="{{AdminCatalogSearchTermIndexSection.gridRow}}" userInput="{{ApiProductDescription.value}}" />
<see selector="{{AdminCatalogSearchTermIndexSection.numberOfSearchTermResults}}" userInput="1" stepKey="seeNumberOfSearchTermResultInGrid"/>
</test>
Expand Down
9 changes: 5 additions & 4 deletions lib/web/requirejs/domReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ define(function () {
}
}

//Check if document already complete, and if so, just trigger page load
//Check if document is no longer loading, and if so, just trigger page load
//listeners. Latest webkit browsers also use "interactive", and
//will fire the onDOMContentLoaded before "interactive" but not after
//entering "interactive" or "complete". More details:
Expand All @@ -89,8 +89,9 @@ define(function () {
//so removing the || document.readyState === "interactive" test.
//There is still a window.onload binding that should get fired if
//DOMContentLoaded is missed.
if (document.readyState === "complete") {
pageLoaded();
if (document.readyState !== "loading") {
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout(pageLoaded);
}
}

Expand Down Expand Up @@ -126,4 +127,4 @@ define(function () {
/** END OF PUBLIC API **/

return domReady;
});
});

0 comments on commit 0f2bd67

Please sign in to comment.