From 094a0d1ab9bed4cd6709d29c0ad742e88e4fbbb0 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 18 Oct 2023 19:34:09 +0000 Subject: [PATCH] Bug 1853418 - Prepare tab-related tests.r=dao Differential Revision: https://phabricator.services.mozilla.com/D190555 UltraBlame original commit: 1a42179c6b78749c0c13e4494bb5523662fe91a0 --- .../browser_auth_spoofing_protection.js | 61 +++++++ .../browser_auth_spoofing_url_copy.js | 154 ++++++++++++++++++ ..._tab_title_and_url_prefilled_blank_page.js | 76 +++++++++ ..._url_prefilled_normal_page_blank_target.js | 106 ++++++++++++ ...and_url_prefilled_normal_page_by_script.js | 51 ++++++ ...and_url_prefilled_normal_page_no_target.js | 56 +++++++ ..._url_prefilled_normal_page_other_target.js | 86 ++++++++++ 7 files changed, 590 insertions(+) diff --git a/browser/base/content/test/tabPrompts/browser_auth_spoofing_protection.js b/browser/base/content/test/tabPrompts/browser_auth_spoofing_protection.js index 2f0565f01a3c9..af5602a5241a0 100644 --- a/browser/base/content/test/tabPrompts/browser_auth_spoofing_protection.js +++ b/browser/base/content/test/tabPrompts/browser_auth_spoofing_protection.js @@ -33,6 +33,32 @@ use strict " ; +ChromeUtils +. +defineESModuleGetters +( +this +{ +UrlbarTestUtils +: +" +resource +: +/ +/ +testing +- +common +/ +UrlbarTestUtils +. +sys +. +mjs +" +} +) +; let TEST_PATH = @@ -436,7 +462,12 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( AUTH_URL +) " Correct location @@ -524,6 +555,10 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( " https : @@ -533,6 +568,7 @@ example . org " +) " No location @@ -612,7 +648,12 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( AUTH_URL +) " Correct location @@ -759,7 +800,12 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( AUTH_URL +) " Correct location @@ -821,7 +867,12 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( CROSS_DOMAIN_URL +) " No location @@ -908,7 +959,12 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( SAME_DOMAIN_URL +) " No location @@ -1112,11 +1168,16 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( crossDomain ? CROSS_DOMAIN_URL : SAME_DOMAIN_URL +) " No location diff --git a/browser/base/content/test/tabPrompts/browser_auth_spoofing_url_copy.js b/browser/base/content/test/tabPrompts/browser_auth_spoofing_url_copy.js index 2192436e4a093..9e091ac9e3eeb 100644 --- a/browser/base/content/test/tabPrompts/browser_auth_spoofing_url_copy.js +++ b/browser/base/content/test/tabPrompts/browser_auth_spoofing_url_copy.js @@ -33,6 +33,32 @@ use strict " ; +const +{ +UrlbarTestUtils +} += +ChromeUtils +. +importESModule +( +" +resource +: +/ +/ +testing +- +common +/ +UrlbarTestUtils +. +sys +. +mjs +" +) +; let TEST_PATH = @@ -305,7 +331,12 @@ equal gURLBar . value +UrlbarTestUtils +. +trimURL +( AUTH_URL +) " url bar @@ -348,7 +379,12 @@ focus let endOfSelectionRange = +UrlbarTestUtils +. +trimURL +( AUTH_URL +) . indexOf ( @@ -362,6 +398,20 @@ sjs " ) ; +let +isProtocolTrimmed += +AUTH_URL +. +startsWith +( +UrlbarTestUtils +. +getTrimmedProtocolWithSlashes +( +) +) +; await SimpleTest . @@ -373,6 +423,20 @@ substring ( 0 endOfSelectionRange ++ +( +isProtocolTrimmed +? +UrlbarTestUtils +. +getTrimmedProtocolWithSlashes +( +) +. +length +: +0 +) ) ( ) @@ -386,7 +450,12 @@ equal gURLBar . value +UrlbarTestUtils +. +trimURL +( AUTH_URL +) " url bar @@ -456,7 +525,12 @@ window gURLBar . value +UrlbarTestUtils +. +trimURL +( CROSS_DOMAIN_URL +) " No location @@ -504,7 +578,12 @@ equal gURLBar . value +UrlbarTestUtils +. +trimURL +( CROSS_DOMAIN_URL +) " url bar @@ -563,6 +642,81 @@ testUrlCopy ( ) { +SpecialPowers +. +pushPrefEnv +( +{ +set +: +[ +[ +" +browser +. +urlbar +. +trimHttps +" +false +] +[ +" +browser +. +urlbar +. +trimURLs +" +true +] +] +} +) +; +await +trigger401AndHandle +( +) +; +SpecialPowers +. +popPrefEnv +( +) +; +SpecialPowers +. +pushPrefEnv +( +{ +set +: +[ +[ +" +browser +. +urlbar +. +trimHttps +" +true +] +[ +" +browser +. +urlbar +. +trimURLs +" +true +] +] +} +) +; await trigger401AndHandle ( diff --git a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_blank_page.js b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_blank_page.js index 5dfacb888e20a..00a2a17d21f78 100644 --- a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_blank_page.js +++ b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_blank_page.js @@ -76,6 +76,32 @@ by clicking link . +ChromeUtils +. +defineESModuleGetters +( +this +{ +UrlbarTestUtils +: +" +resource +: +/ +/ +testing +- +common +/ +UrlbarTestUtils +. +sys +. +mjs +" +} +) +; / * import @@ -253,7 +279,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -285,7 +316,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -340,7 +376,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) } async actionWhileLoading @@ -372,7 +413,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) history : [ @@ -427,7 +473,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -459,7 +510,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -514,7 +570,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) } async actionWhileLoading @@ -546,7 +607,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) history : [ @@ -625,7 +691,12 @@ tab HOME_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -657,7 +728,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) history : [ diff --git a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_blank_target.js b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_blank_target.js index c0d9cc9d05ba9..a4db0075dd78d 100644 --- a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_blank_target.js +++ b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_blank_target.js @@ -85,6 +85,32 @@ is _blank " . +ChromeUtils +. +defineESModuleGetters +( +this +{ +UrlbarTestUtils +: +" +resource +: +/ +/ +testing +- +common +/ +UrlbarTestUtils +. +sys +. +mjs +" +} +) +; / * import @@ -175,7 +201,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) } async actionWhileLoading @@ -207,7 +238,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) history : [ @@ -264,7 +300,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) } async actionWhileLoading @@ -296,7 +337,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) history : [ @@ -353,7 +399,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) } async actionWhileLoading @@ -393,7 +444,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) history : [ @@ -448,7 +504,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( REQUEST_TIMEOUT_URL +) } async actionWhileLoading @@ -480,7 +541,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( REQUEST_TIMEOUT_URL +) history : [ @@ -587,7 +653,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -619,7 +690,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -676,7 +752,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -708,7 +789,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -765,7 +851,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -805,7 +896,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -859,7 +955,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -891,7 +992,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ diff --git a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_by_script.js b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_by_script.js index a0121b9ecc713..b3c0b0a208e0b 100644 --- a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_by_script.js +++ b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_by_script.js @@ -128,6 +128,32 @@ js this ) ; +const +{ +UrlbarTestUtils +} += +ChromeUtils +. +importESModule +( +" +resource +: +/ +/ +testing +- +common +/ +UrlbarTestUtils +. +sys +. +mjs +" +) +; add_task ( async @@ -204,7 +230,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) history : [ @@ -261,7 +292,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) } async actionWhileLoading @@ -301,7 +337,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) history : [ @@ -355,7 +396,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) } async actionWhileLoading @@ -387,7 +433,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( REQUEST_TIMEOUT_URL +) history : [ diff --git a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_no_target.js b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_no_target.js index b7a1c44e54cb8..43814dedcfc84 100644 --- a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_no_target.js +++ b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_no_target.js @@ -128,6 +128,32 @@ js this ) ; +const +{ +UrlbarTestUtils +} += +ChromeUtils +. +importESModule +( +" +resource +: +/ +/ +testing +- +common +/ +UrlbarTestUtils +. +sys +. +mjs +" +) +; add_task ( async @@ -196,7 +222,12 @@ tab HOME_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -228,7 +259,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) history : [ @@ -286,7 +322,12 @@ tab HOME_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -326,7 +367,12 @@ tab HOME_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -381,7 +427,12 @@ tab HOME_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -413,7 +464,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( REQUEST_TIMEOUT_URL +) history : [ diff --git a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_other_target.js b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_other_target.js index 86a79f0ef1905..c94ba6c66bab4 100644 --- a/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_other_target.js +++ b/browser/base/content/test/tabs/browser_link_in_tab_title_and_url_prefilled_normal_page_other_target.js @@ -85,6 +85,32 @@ is other " . +ChromeUtils +. +defineESModuleGetters +( +this +{ +UrlbarTestUtils +: +" +resource +: +/ +/ +testing +- +common +/ +UrlbarTestUtils +. +sys +. +mjs +" +} +) +; / * import @@ -175,7 +201,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) } async actionWhileLoading @@ -207,7 +238,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( WAIT_A_BIT_URL +) history : [ @@ -264,7 +300,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) } async actionWhileLoading @@ -304,7 +345,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) history : [ @@ -358,7 +404,12 @@ tab BLANK_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( BLANK_URL +) } async actionWhileLoading @@ -390,7 +441,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( REQUEST_TIMEOUT_URL +) history : [ @@ -492,7 +548,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -524,7 +585,12 @@ tab WAIT_A_BIT_PAGE_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -581,7 +647,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -621,7 +692,12 @@ tab WAIT_A_BIT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [ @@ -675,7 +751,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) } async actionWhileLoading @@ -707,7 +788,12 @@ tab REQUEST_TIMEOUT_LOADING_TITLE urlbar : +UrlbarTestUtils +. +trimURL +( HOME_URL +) history : [