Skip to content

Commit 7662e05

Browse files
🤖 Merge PR DefinitelyTyped#73368 Sync latest changes to @types/google-publisher-tag by @google-publisher-tag
Co-authored-by: jimper <jimper@users.noreply.github.com>
1 parent 56f7327 commit 7662e05

File tree

3 files changed

+1022
-54
lines changed

3 files changed

+1022
-54
lines changed

‎types/google-publisher-tag/google-publisher-tag-tests.ts‎

Lines changed: 273 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Tests for Google Publisher Tag 1.20250428
2-
// Synced from: https://github.com/googleads/google-publisher-tag-types/commit/1f06e740f1e08182e11f5b32be778f4596262c43
1+
// Tests for Google Publisher Tag 1.20250728
2+
// Synced from: https://github.com/googleads/google-publisher-tag-types/commit/acc4c06564252357bad326a7d63ec6b7402e0384
33

44
// Test for googletag.cmd
55
function test_googletag_cmd() {
@@ -80,6 +80,15 @@ function test_googletag_setAdIframeTitle() {
8080
googletag.setAdIframeTitle("title");
8181
}
8282

83+
// Test for googletag.getConfig
84+
function test_googletag_getConfig() {
85+
// Get the value of the `targeting` setting.
86+
const targetingConfig = googletag.getConfig("targeting");
87+
88+
// Get the value of the `adsenseAttributes` and `disableInitialLoad` settings.
89+
const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
90+
}
91+
8392
// Test for googletag.CommandArray.push
8493
function test_googletag_commandArray_push() {
8594
googletag.cmd.push(() => {
@@ -638,6 +647,17 @@ function test_googletag_slot_updateTargetingFromMap() {
638647
});
639648
}
640649

650+
// Test for googletag.Slot.getConfig
651+
function test_googletag_slot_getConfig() {
652+
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!;
653+
654+
// Get the value of the `targeting` setting.
655+
const targetingConfig = slot.getConfig("targeting");
656+
657+
// Get the value of the `adsenseAttributes` and `categoryExclusion` settings.
658+
const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
659+
}
660+
641661
// Test for googletag.config.AdExpansionConfig
642662
function test_googletag_config_adExpansionConfig() {
643663
// Enable ad slot expansion across the entire page.
@@ -658,6 +678,144 @@ function test_googletag_config_pageSettingsConfig_threadYield() {
658678
googletag.setConfig({ threadYield: null });
659679
}
660680

681+
// Test for googletag.config.PageSettingsConfig.location
682+
function test_googletag_config_pageSettingsConfig_location() {
683+
// Geo-target line items to US postal code 10001.
684+
googletag.setConfig({ location: "10001,US" });
685+
686+
// Clear the location setting.
687+
googletag.setConfig({ location: null });
688+
}
689+
690+
// Test for googletag.config.PageSettingsConfig.videoAds
691+
function test_googletag_config_pageSettingsConfig_videoAds() {
692+
// Enable video ads and set video content and content source IDs.
693+
googletag.setConfig({
694+
videoAds: {
695+
enableVideoAds: true,
696+
videoContentId: "e1eGlRL7ju8",
697+
videoCmsId: "1234567",
698+
},
699+
});
700+
}
701+
702+
// Test for googletag.config.PageSettingsConfig.lazyLoad
703+
function test_googletag_config_pageSettingsConfig_lazyLoad() {
704+
// Enable lazy loading.
705+
googletag.setConfig({
706+
lazyLoad: {
707+
// Fetch slots within 5 viewports.
708+
fetchMarginPercent: 500,
709+
// Render slots within 2 viewports.
710+
renderMarginPercent: 200,
711+
// Double the above values on mobile.
712+
mobileScaling: 2.0,
713+
},
714+
});
715+
716+
// Clear fetch margin only.
717+
googletag.setConfig({
718+
lazyLoad: { fetchMarginPercent: null },
719+
});
720+
721+
// Clear all lazy loading settings.
722+
googletag.setConfig({ lazyLoad: null });
723+
}
724+
725+
// Test for googletag.config.PageSettingsConfig.safeFrame
726+
function test_googletag_config_pageSettingsConfig_safeFrame() {
727+
// Force SafeFrame for all ads on the page.
728+
googletag.setConfig({
729+
safeFrame: { forceSafeFrame: true },
730+
});
731+
732+
// Configure SafeFrame to allow overlay expansion.
733+
googletag.setConfig({
734+
safeFrame: { allowOverlayExpansion: true },
735+
});
736+
737+
// Clear forceSafeFrame setting.
738+
googletag.setConfig({
739+
safeFrame: { forceSafeFrame: null },
740+
});
741+
742+
// Clear all SafeFrame settings.
743+
googletag.setConfig({ safeFrame: null });
744+
}
745+
746+
// Test for googletag.config.PageSettingsConfig.centering
747+
function test_googletag_config_pageSettingsConfig_centering() {
748+
// Make ads centered.
749+
googletag.setConfig({ centering: true });
750+
751+
// Clear the centering setting.
752+
googletag.setConfig({ centering: null });
753+
}
754+
755+
// Test for googletag.config.PageSettingsConfig.collapseDiv
756+
function test_googletag_config_pageSettingsConfig_collapseDiv() {
757+
// Collapse the div for this slot if no ad is returned.
758+
googletag.setConfig({ collapseDiv: "ON_NO_FILL" });
759+
760+
// Collapse the div for this slot by default, and expand only
761+
// if an ad is returned.
762+
googletag.setConfig({ collapseDiv: "BEFORE_FETCH" });
763+
764+
// Do not collapse the div for this slot.
765+
googletag.setConfig({ collapseDiv: "DISABLED" });
766+
767+
// Clear the collapse setting.
768+
googletag.setConfig({ collapseDiv: null });
769+
}
770+
771+
// Test for googletag.config.PageSettingsConfig.singleRequest
772+
function test_googletag_config_pageSettingsConfig_singleRequest() {
773+
// Enable Single Request Architecture.
774+
googletag.setConfig({ singleRequest: true });
775+
}
776+
777+
// Test for googletag.config.PageSettingsConfig.disableInitialLoad
778+
function test_googletag_config_pageSettingsConfig_disableInitialLoad() {
779+
// Prevent requesting ads when `display()` is called.
780+
googletag.setConfig({ disableInitialLoad: true });
781+
}
782+
783+
// Test for googletag.config.PageSettingsConfig.categoryExclusion
784+
function test_googletag_config_pageSettingsConfig_categoryExclusion() {
785+
// Label = AirlineAd.
786+
googletag.setConfig({ categoryExclusion: ["AirlineAd"] });
787+
788+
// Clearing category exclusion setting.
789+
googletag.setConfig({ categoryExclusion: null });
790+
}
791+
792+
// Test for googletag.config.PageSettingsConfig.targeting
793+
function test_googletag_config_pageSettingsConfig_targeting() {
794+
// Setting a single targeting key-value.
795+
googletag.setConfig({ targeting: { interests: "sports" } });
796+
797+
// Setting multiple values for a single targeting key
798+
googletag.setConfig({ targeting: { interests: ["sports", "music"] } });
799+
800+
// Setting multiple targeting key-values at once.
801+
googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });
802+
803+
// Clearing a single targeting key.
804+
googletag.setConfig({ targeting: { interests: null } });
805+
}
806+
807+
// Test for googletag.config.PageSettingsConfig.adsenseAttributes
808+
function test_googletag_config_pageSettingsConfig_adsenseAttributes() {
809+
// Set the document language and page URL.
810+
googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" } });
811+
812+
// Clear the page URL only.
813+
googletag.setConfig({ adsenseAttributes: { page_url: null } });
814+
815+
// Clear all AdSense attributes.
816+
googletag.setConfig({ adsenseAttributes: null });
817+
}
818+
661819
// Test for googletag.config.PrivacyTreatmentsConfig.treatments
662820
function test_googletag_config_privacyTreatmentsConfig_treatments() {
663821
// Disable personalization across the entire page.
@@ -682,6 +840,119 @@ function test_googletag_config_publisherProvidedSignalsConfig() {
682840
});
683841
}
684842

843+
// Test for googletag.config.SlotSettingsConfig.clickUrl
844+
function test_googletag_config_slotSettingsConfig_clickUrl() {
845+
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
846+
847+
// Sets the click URL to 'http://www.example.com?original_click_url='.
848+
slot.setConfig({
849+
clickUrl: "http://www.example.com?original_click_url=",
850+
});
851+
852+
// Clears the click URL.
853+
slot.setConfig({
854+
clickUrl: null,
855+
});
856+
}
857+
858+
// Test for googletag.config.SlotSettingsConfig.safeFrame
859+
function test_googletag_config_slotSettingsConfig_safeFrame() {
860+
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
861+
862+
// Force SafeFrame for the slot.
863+
slot.setConfig({
864+
safeFrame: { forceSafeFrame: true },
865+
});
866+
867+
// Configure SafeFrame to allow overlay expansion for the slot.
868+
slot.setConfig({
869+
safeFrame: { allowOverlayExpansion: true },
870+
});
871+
872+
// Clear forceSafeFrame setting for the slot.
873+
slot.setConfig({
874+
safeFrame: { forceSafeFrame: null },
875+
});
876+
877+
// Clear all SafeFrame settings for the slot.
878+
slot.setConfig({ safeFrame: null });
879+
}
880+
881+
// Test for googletag.config.SlotSettingsConfig.collapseDiv
882+
function test_googletag_config_slotSettingsConfig_collapseDiv() {
883+
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
884+
885+
// Collapse the div for this slot if no ad is returned.
886+
slot.setConfig({
887+
collapseDiv: "ON_NO_FILL",
888+
});
889+
890+
// Collapse the div for this slot by default, and expand only
891+
// if an ad is returned.
892+
slot.setConfig({
893+
collapseDiv: "BEFORE_FETCH",
894+
});
895+
896+
// Do not collapse the div for this slot.
897+
slot.setConfig({
898+
collapseDiv: "DISABLED",
899+
});
900+
901+
// Clear the collapse setting.
902+
slot.setConfig({
903+
collapseDiv: null,
904+
});
905+
}
906+
907+
// Test for googletag.config.SlotSettingsConfig.categoryExclusion
908+
function test_googletag_config_slotSettingsConfig_categoryExclusion() {
909+
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
910+
911+
// Label = AirlineAd
912+
slot.setConfig({
913+
categoryExclusion: ["AirlineAd"],
914+
});
915+
916+
// Clearing category exclusion setting.
917+
slot.setConfig({ categoryExclusion: null });
918+
}
919+
920+
// Test for googletag.config.SlotSettingsConfig.targeting
921+
function test_googletag_config_slotSettingsConfig_targeting() {
922+
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
923+
924+
// Setting a single targeting key-value.
925+
slot.setConfig({ targeting: { interests: "sports" } });
926+
927+
// Setting multiple values for a single targeting key.
928+
slot.setConfig({ targeting: { interests: ["sports", "music"] } });
929+
930+
// Setting multiple targeting key-values at once.
931+
slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } });
932+
933+
// Clearing a single targeting key.
934+
slot.setConfig({ targeting: { interests: null } });
935+
936+
// Clear all targeting keys.
937+
slot.setConfig({ targeting: null });
938+
}
939+
940+
// Test for googletag.config.SlotSettingsConfig.adsenseAttributes
941+
function test_googletag_config_slotSettingsConfig_adsenseAttributes() {
942+
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
943+
944+
// Set the AdSense ad format and channel IDs.
945+
slot.setConfig({
946+
adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265" },
947+
});
948+
949+
// Clear the AdSense channel IDs only.
950+
slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } });
951+
952+
// Clear all AdSense attributes.
953+
slot.setConfig({ adsenseAttributes: null });
954+
}
955+
685956
// Test for googletag.config.ComponentAuctionConfig.auctionConfig
686957
function test_googletag_config_componentAuctionConfig_auctionConfig() {
687958
const componentAuctionConfig = {

0 commit comments

Comments
 (0)