حالت های تست
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
ادغام ()adBreak را آزمایش کنید
به منظور آزمایش کد جاوا اسکریپت که از API adBreak()
استفاده می کند، یک حالت آزمایشی ارائه می دهیم که می تواند با افزودن ویژگی data-adbreak-test="on"
در adsbygoogle.js
فعال شود:
<script async
data-adbreak-test="on"
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456789"
crossorigin="anonymous">
</script>
<script>
window.adsbygoogle = window.adsbygoogle || [];
var adBreak = adConfig = function(o) {adsbygoogle.push(o);}
</script>
حالت تست:
- به جای درخواست تبلیغات واقعی، تبلیغات ساختگی را نمایش می دهد.
- رفتار تبلیغات واقعی را تقلید می کند، مانند رعایت فراوانی تبلیغات پیکربندی شده شما.
- از
console.log
یا نقاط شکست برای اشکال زدایی adBreakDone()
و placementInfo
استفاده کنید.
توجه : حالت تست فقط به شما امکان می دهد جاوا اسکریپت سمت سرویس گیرنده را بدون ارسال درخواست تبلیغات به سرورهای Google آزمایش کنید. نمیتواند به شما در تشخیص مشکلات مربوط به پیکربندی نادرست کد AdSense مانند مقادیر نامعتبر «data-ad-client» کمک کند.
حالت تست بین دو سناریو چرخه میشود: تبلیغ بارگیری میشود و تبلیغ برای تقلید از یک محیط واقعی که در آن تبلیغ همیشه در دسترس نخواهد بود بارگیری نمیشود.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eTesting mode for \u003ccode\u003eadBreak()\u003c/code\u003e is enabled by adding \u003ccode\u003edata-adbreak-test="on"\u003c/code\u003e to the \u003ccode\u003eadsbygoogle.js\u003c/code\u003e script tag.\u003c/p\u003e\n"],["\u003cp\u003eThis mode displays mock ads, mimics real ad behavior (like frequency capping), and allows debugging with \u003ccode\u003econsole.log\u003c/code\u003e or breakpoints.\u003c/p\u003e\n"],["\u003cp\u003eIt's for testing client-side JavaScript only and doesn't detect AdSense code misconfigurations.\u003c/p\u003e\n"],["\u003cp\u003eThe test mode cycles between scenarios where ads are and aren't loaded to simulate real-world conditions.\u003c/p\u003e\n"]]],["To test `adBreak()` API integration, enable testing mode by adding `data-adbreak-test=\"on\"` to the `adsbygoogle.js` script. This mode displays mock ads, mimicking real ad behavior, but does not send real ad requests. It cycles between ad loaded and not loaded scenarios. Use `console.log` or breakpoints to debug `adBreakDone()` and `placementInfo`. This method helps test client-side JavaScript, but it cannot detect issues related to AdSense code misconfiguration.\n"],null,["# Testing modes\n\nTest adBreak() integration\n--------------------------\n\nIn order to test JavaScript code that uses the `adBreak()` API we provide a\ntesting mode that can be enabled by adding `data-adbreak-test=\"on\"`attribute on\nthe `adsbygoogle.js`: \n\n \u003cscript async\n data-adbreak-test=\"on\"\n src=\"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=\u003cvar translate=\"no\"\u003eca-pub-123456789\u003c/var\u003e\"\n crossorigin=\"anonymous\"\u003e\n \u003c/script\u003e\n \u003cscript\u003e\n window.adsbygoogle = window.adsbygoogle || [];\n var adBreak = adConfig = function(o) {adsbygoogle.push(o);}\n \u003c/script\u003e\n\nTesting mode:\n\n- Displays mock ads instead of requesting real ads.\n- Mimics real ads behaviour such as respecting your configured ad frequency.\n- Use `console.log` or [break points](https://developer.chrome.com/docs/devtools/javascript/breakpoints) to debug [`adBreakDone()`](/ad-placement/apis/adbreak#adbreakdone_and_placementinfo) and `placementInfo`.\n\n**Note**: testing mode only allows you to test\nclient-side JavaScript without sending ad requests to Google servers. It can't\nhelp you to detect issues related to misconfiguration of the AdSense code such\nas invalid \\`data-ad-client\\` values.\n\nTest mode cycles between two scenarios: ad is loaded and ad is not loaded to\nemulate a real environment where ad will not always be available."]]