<commit_before>void readDigits(){

  gSystem->Load("libITSUpgradeBase");
  gSystem->Load("libITSUpgradeSim");
  gROOT->SetStyle("Plain");

  gAlice=NULL;
  AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
  runLoader->LoadgAlice();

  gAlice = runLoader->GetAliRun();

  runLoader->LoadHeader();
  runLoader->LoadKinematics();
  runLoader->LoadSDigits();
  runLoader->LoadDigits();

  AliGeomManager::LoadGeometry("geometry.root");
  AliITSUGeomTGeo* gm = new AliITSUGeomTGeo(kTRUE,kTRUE);
  //
  Int_t nLayers = gm->GetNLayers();
  Int_t nModules = gm->GetNModules();
  Int_t nbins=100;
  Int_t xmin=0;
  Int_t xmax=50000;//00*1e-09;

  TH1D **hNelSDig = new TH1D*[nLayers], **hNelDig = new TH1D*[nLayers];
  //
  for(Int_t i=0; i< nLayers; i++ ) {
    hNelSDig[i] = new TH1D(Form("hNelSDig%i",i),Form("electron distribution in SDigits [ Layer %i] ",i),nbins,xmin,xmax);
    hNelSDig[i]->SetXTitle("N electrons");
    hNelDig[i] = new TH1D(Form("hNelDig%i",i),Form("electron distribution in Digits [ Layer %i] ",i),nbins,xmin,xmax);
    hNelDig[i]->SetXTitle("N electrons");
  }

  AliLoader *dl = runLoader->GetDetectorLoader("ITS");

  //SDIGITS INIT
  TTree * sDigTree = 0x0;
  TClonesArray *sDigArr= new TClonesArray("AliITSUSDigit");

  //DIGITS INIT
  TTree * digTree = 0x0;
  TClonesArray *digArr= new TClonesArray("AliITSUDigitPix");

  printf("N Events : %i \n",(Int_t)runLoader->GetNumberOfEvents());

  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
    printf("\n Event %i \n",iEvent);
    runLoader->GetEvent(iEvent);
    AliStack *stack = runLoader->Stack();
    sDigTree=dl->TreeS();
    digTree=dl->TreeD();
    //
    sDigTree->SetBranchAddress("ITS",&sDigArr);
    digTree->SetBranchAddress("ITSDigitsPix",&digArr);

    for (int imod=0;imod<nModules;imod++) {
      sDigTree->GetEntry(imod);
      digTree->GetEntry(imod);
      int detType = gm->GetModuleDetTypeID(imod);
      AliITSUSegmentationPix* segm = (AliITSUSegmentationPix*)gm->GetSegmentationByID(detType);
      int lay,lad,det;
      int nsdig = sDigArr->GetEntries();
      int ndig  = digArr->GetEntries();
      if (nsdig<1) continue;
      gm->GetModuleId(imod, lay,lad,det);
      printf("\nModule %3d: (det %2d in ladder %2d of Layer %d) |NSDigits: %4d NDigits: %4d\n",imod,det,lad,lay,nsdig,ndig);
      //
      for (int isdig=0;isdig<nsdig;isdig++) {
	AliITSUSDigit *pSdig = (AliITSUSDigit*)sDigArr->At(isdig);
	int sdinfo = pSdig->GetUniqueID();
	printf("#%3d Sdigit col:%4d/row:%4d generated by track %5d (%s)\t",isdig, sdinfo/segm->Npx(),sdinfo%segm->Npx(),
	       pSdig->GetTrack(0),stack->Particle(pSdig->GetTrack(0))->GetName());
	pSdig->Print();
	hNelSDig[lay]->Fill(pSdig->GetSignal());
      }
      //
      for (int idig=0;idig<ndig;idig++) {
	AliITSUDigitPix *pDig = (AliITSUDigitPix*)digArr->At(idig);
	printf("#%3d digit, col:%4d/row:%4d signal: %.2e,  generated by tracks ",idig,pDig->GetCoord1(),pDig->GetCoord2(),pDig->GetSignalPix());
	for (int itr=0;itr<pDig->GetNTracks();itr++) if (pDig->GetTrack(itr)>=0) printf(" %5d",pDig->GetTrack(itr)); printf("\n");
	//
	hNelDig[lay]->Fill(pDig->GetSignalPix());
      }
      //
    }

  }//event loop

  TCanvas *cSd = new TCanvas("cSd","Summable Digits",1000,800);
  cSd->Divide(nLayers&0x1 ?  (nLayers/2+1) : nLayers/2,2);
  TCanvas *cD = new TCanvas("cD","Digits",1000,800);
  cD->Divide(nLayers&0x1 ?  (nLayers/2+1) : nLayers/2,2);

  for(Int_t ip =1; ip<=nLayers; ip++){
    cSd->cd(ip);
    hNelSDig[ip-1]->Draw();
    cD->cd(ip);
    hNelDig[ip-1]->Draw();
  }

}
<commit_msg>Fix in sdigit row/col extraction<commit_after>void readDigits(){

  gSystem->Load("libITSUpgradeBase");
  gSystem->Load("libITSUpgradeSim");
  gROOT->SetStyle("Plain");

  gAlice=NULL;
  AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
  runLoader->LoadgAlice();

  gAlice = runLoader->GetAliRun();

  runLoader->LoadHeader();
  runLoader->LoadKinematics();
  runLoader->LoadSDigits();
  runLoader->LoadDigits();

  AliGeomManager::LoadGeometry("geometry.root");
  AliITSUGeomTGeo* gm = new AliITSUGeomTGeo(kTRUE,kTRUE);
  //
  Int_t nLayers = gm->GetNLayers();
  Int_t nModules = gm->GetNModules();
  Int_t nbins=100;
  Int_t xmin=0;
  Int_t xmax=50000;//00*1e-09;

  TH1D **hNelSDig = new TH1D*[nLayers], **hNelDig = new TH1D*[nLayers];
  //
  for(Int_t i=0; i< nLayers; i++ ) {
    hNelSDig[i] = new TH1D(Form("hNelSDig%i",i),Form("electron distribution in SDigits [ Layer %i] ",i),nbins,xmin,xmax);
    hNelSDig[i]->SetXTitle("N electrons");
    hNelDig[i] = new TH1D(Form("hNelDig%i",i),Form("electron distribution in Digits [ Layer %i] ",i),nbins,xmin,xmax);
    hNelDig[i]->SetXTitle("N electrons");
  }

  AliLoader *dl = runLoader->GetDetectorLoader("ITS");

  //SDIGITS INIT
  TTree * sDigTree = 0x0;
  TClonesArray *sDigArr= new TClonesArray("AliITSUSDigit");

  //DIGITS INIT
  TTree * digTree = 0x0;
  TClonesArray *digArr= new TClonesArray("AliITSUDigitPix");

  printf("N Events : %i \n",(Int_t)runLoader->GetNumberOfEvents());

  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
    printf("\n Event %i \n",iEvent);
    runLoader->GetEvent(iEvent);
    AliStack *stack = runLoader->Stack();
    sDigTree=dl->TreeS();
    digTree=dl->TreeD();
    //
    sDigTree->SetBranchAddress("ITS",&sDigArr);
    digTree->SetBranchAddress("ITSDigitsPix",&digArr);

    for (int imod=0;imod<nModules;imod++) {
      sDigTree->GetEntry(imod);
      digTree->GetEntry(imod);
      int detType = gm->GetModuleDetTypeID(imod);
      AliITSUSegmentationPix* segm = (AliITSUSegmentationPix*)gm->GetSegmentationByID(detType);
      int lay,lad,det;
      int nsdig = sDigArr->GetEntries();
      int ndig  = digArr->GetEntries();
      if (nsdig<1) continue;
      gm->GetModuleId(imod, lay,lad,det);
      printf("\nModule %3d: (det %2d in ladder %2d of Layer %d) |NSDigits: %4d NDigits: %4d\n",imod,det,lad,lay,nsdig,ndig);
      //
      for (int isdig=0;isdig<nsdig;isdig++) {
	AliITSUSDigit *pSdig = (AliITSUSDigit*)sDigArr->At(isdig);
	int sdinfo = pSdig->GetUniqueID();
	printf("#%3d Sdigit col:%4d/row:%4d generated by track %5d (%s)\t",isdig, sdinfo%segm->Npz(), sdinfo/segm->Npz(),
	       pSdig->GetTrack(0),stack->Particle(pSdig->GetTrack(0))->GetName());
	pSdig->Print();
	hNelSDig[lay]->Fill(pSdig->GetSignal());
      }
      //
      for (int idig=0;idig<ndig;idig++) {
	AliITSUDigitPix *pDig = (AliITSUDigitPix*)digArr->At(idig);
	printf("#%3d digit, col:%4d/row:%4d signal: %.2e,  generated by tracks ",idig,pDig->GetCoord1(),pDig->GetCoord2(),pDig->GetSignalPix());
	for (int itr=0;itr<pDig->GetNTracks();itr++) if (pDig->GetTrack(itr)>=0) printf(" %5d",pDig->GetTrack(itr)); printf("\n");
	//
	hNelDig[lay]->Fill(pDig->GetSignalPix());
      }
      //
    }

  }//event loop

  TCanvas *cSd = new TCanvas("cSd","Summable Digits",1000,800);
  cSd->Divide(nLayers&0x1 ?  (nLayers/2+1) : nLayers/2,2);
  TCanvas *cD = new TCanvas("cD","Digits",1000,800);
  cD->Divide(nLayers&0x1 ?  (nLayers/2+1) : nLayers/2,2);

  for(Int_t ip =1; ip<=nLayers; ip++){
    cSd->cd(ip);
    hNelSDig[ip-1]->Draw();
    cD->cd(ip);
    hNelDig[ip-1]->Draw();
  }

}
<|endoftext|>


<commit_before>#include "idt.hpp"
#include "console.hpp"

#define ISR(num) extern "C" void isr_##num();
#define ISR_ERR(num) ISR(num)
#include "../interrupt-list.inc"
#undef ISR
#undef ISR_ERR

static InterruptDescriptor invalid;
InterruptDescriptor IDT::descriptors[length];

InterruptDescriptor & IDT::descriptor(uint32_t idx)
{
	if(idx >= IDT::length) {
		return invalid;
	}
	return IDT::descriptors[idx];
}

void IDT::initialize()
{
#define ISR(num) IDT::descriptor(num) = InterruptDescriptor( \
		uint32_t(&isr_##num), \
		0x08, \
		InterruptFlags::Interrupt | InterruptFlags::Use32Bit | InterruptFlags::Ring0 | InterruptFlags::Present);
#define ISR_ERR(num) ISR(num)
#include "../interrupt-list.inc"
#undef ISR
#undef ISR_ERR

	struct {
		uint16_t limit;
		void* pointer;
	} __attribute__((packed)) idtp = {
		.limit = IDT::length * sizeof(InterruptDescriptor) - 1,
		.pointer = IDT::descriptors,
	};
	asm volatile("lidt %0" : : "m" (idtp));
}

void IDT::dispatch(CpuState *cpu)
{
	Console::main << "Ermahgerd, Interrupts!";
	while(true);
}<commit_msg>Prints CPU state on interrupt.<commit_after>#include "idt.hpp"
#include "console.hpp"

#define ISR(num) extern "C" void isr_##num();
#define ISR_ERR(num) ISR(num)
#include "../interrupt-list.inc"
#undef ISR
#undef ISR_ERR

static InterruptDescriptor invalid;
InterruptDescriptor IDT::descriptors[length];

InterruptDescriptor & IDT::descriptor(uint32_t idx)
{
	if(idx >= IDT::length) {
		return invalid;
	}
	return IDT::descriptors[idx];
}

void IDT::initialize()
{
#define ISR(num) IDT::descriptor(num) = InterruptDescriptor( \
		uint32_t(&isr_##num), \
		0x08, \
		InterruptFlags::Interrupt | InterruptFlags::Use32Bit | InterruptFlags::Ring0 | InterruptFlags::Present);
#define ISR_ERR(num) ISR(num)
#include "../interrupt-list.inc"
#undef ISR
#undef ISR_ERR

	struct {
		uint16_t limit;
		void* pointer;
	} __attribute__((packed)) idtp = {
		.limit = IDT::length * sizeof(InterruptDescriptor) - 1,
		.pointer = IDT::descriptors,
	};
	asm volatile("lidt %0" : : "m" (idtp));
}

void IDT::dispatch(CpuState *cpu)
{
	using namespace console_tools;

	Console::main << "Ermahgerd, Interrupts!\n";

	Console::main
		<< "eax    = " << hex(cpu->eax) << "\n"
		<< "ebx    = " << hex(cpu->ebx) << "\n"
		<< "ecx    = " << hex(cpu->ecx) << "\n"
		<< "edx    = " << hex(cpu->edx) << "\n"
		<< "esi    = " << hex(cpu->esi) << "\n"
		<< "edi    = " << hex(cpu->edi) << "\n"
		<< "ebp    = " << hex(cpu->ebp) << "\n"
		<< "intr   = " << cpu->intr << "\n"
		<< "error  = " << cpu->error << "\n"
		<< "eip    = " << hex(cpu->eip) << "\n"
		<< "cs     = " << hex(cpu->cs) << "\n"
		<< "eflags = " << bin(cpu->eflags) << "\n"
		<< "esp    = " << hex(cpu->esp) << "\n"
		<< "ss     = " << hex(cpu->ss) << "\n";

	while(true);
}<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: acccfg.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: hr $ $Date: 2007-06-27 23:25:44 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _ACCCFG_HXX
#define _ACCCFG_HXX

// #include *****************************************************************

#ifndef _SV_FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _SV_BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#ifndef _SV_DIALOG_HXX //autogen
#include <vcl/dialog.hxx>
#endif
#ifndef _SV_LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif
#include <sfx2/minarray.hxx>

// forward ******************************************************************

class SfxAcceleratorManager;

// class SfxAcceleratorConfigListBox *************************************************

class SfxAcceleratorConfigListBox : public ListBox
{
    void KeyInput( const KeyEvent &rKEvt );

public:

    SfxAcceleratorConfigListBox( Window *pParent, ResId &rResId ) :
        ListBox( pParent, rResId ) {}

    void ReplaceEntry( USHORT nPos, const String &rStr );
    void ExpandEntry ( USHORT nPos, const String &rStr );
};

// class USHORTArr **********************************************************

#if !defined(_MNUCFG_HXX) && !defined(_TBXCFG_HXX)
DECL_2BYTEARRAY(USHORTArr, USHORT, 10, 10)
#endif

// class SfxAcceleratorConfigDialog **************************************************

class SfxAcceleratorConfigDialog : public ModalDialog
{
    OKButton           aOKButton;
    CancelButton       aCancelButton;
    PushButton         aChangeButton;
    PushButton         aRemoveButton;
    SfxAcceleratorConfigListBox aEntriesBox;
    FixedText          aDescriptionTextText;
    FixedText          aDescriptionInfoText;
    FixedLine          aKeyboardGroup;
    FixedText          aGroupText;
    ListBox            aGroupLBox;
    FixedText          aFunctionText;
    ListBox            aFunctionBox;
    FixedText          aKeyText;
    ListBox            aKeyBox;
    FixedLine          aFunctionsGroup;

    SfxAcceleratorManager *pMgr;

    USHORTArr     aAccelArr;
    USHORTArr     aFunctionArr;
    USHORTArr     aKeyArr;

    void OKHdl    ( Button  * );
    void ChangeHdl( Button  * );
    void RemoveHdl( Button  * );
    void SelectHdl( ListBox *pListBox );

    KeyCode PosToKeyCode   ( USHORT nPos )          const;
    USHORT  KeyCodeToPos   ( const KeyCode &rCode ) const;
    String  GetFunctionName( KeyFuncType eType )    const;

public:

    SfxAcceleratorConfigDialog( Window *pParent );
};

#endif

<commit_msg>INTEGRATION: CWS changefileheader (1.6.216); FILE MERGED 2008/04/01 15:39:22 thb 1.6.216.2: #i85898# Stripping all external header guards 2008/03/31 13:38:34 rt 1.6.216.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: acccfg.hxx,v $
 * $Revision: 1.7 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _ACCCFG_HXX
#define _ACCCFG_HXX

// #include *****************************************************************

#include <vcl/fixed.hxx>
#ifndef _SV_BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#include <vcl/dialog.hxx>
#include <vcl/lstbox.hxx>
#include <sfx2/minarray.hxx>

// forward ******************************************************************

class SfxAcceleratorManager;

// class SfxAcceleratorConfigListBox *************************************************

class SfxAcceleratorConfigListBox : public ListBox
{
    void KeyInput( const KeyEvent &rKEvt );

public:

    SfxAcceleratorConfigListBox( Window *pParent, ResId &rResId ) :
        ListBox( pParent, rResId ) {}

    void ReplaceEntry( USHORT nPos, const String &rStr );
    void ExpandEntry ( USHORT nPos, const String &rStr );
};

// class USHORTArr **********************************************************

#if !defined(_MNUCFG_HXX) && !defined(_TBXCFG_HXX)
DECL_2BYTEARRAY(USHORTArr, USHORT, 10, 10)
#endif

// class SfxAcceleratorConfigDialog **************************************************

class SfxAcceleratorConfigDialog : public ModalDialog
{
    OKButton           aOKButton;
    CancelButton       aCancelButton;
    PushButton         aChangeButton;
    PushButton         aRemoveButton;
    SfxAcceleratorConfigListBox aEntriesBox;
    FixedText          aDescriptionTextText;
    FixedText          aDescriptionInfoText;
    FixedLine          aKeyboardGroup;
    FixedText          aGroupText;
    ListBox            aGroupLBox;
    FixedText          aFunctionText;
    ListBox            aFunctionBox;
    FixedText          aKeyText;
    ListBox            aKeyBox;
    FixedLine          aFunctionsGroup;

    SfxAcceleratorManager *pMgr;

    USHORTArr     aAccelArr;
    USHORTArr     aFunctionArr;
    USHORTArr     aKeyArr;

    void OKHdl    ( Button  * );
    void ChangeHdl( Button  * );
    void RemoveHdl( Button  * );
    void SelectHdl( ListBox *pListBox );

    KeyCode PosToKeyCode   ( USHORT nPos )          const;
    USHORT  KeyCodeToPos   ( const KeyCode &rCode ) const;
    String  GetFunctionName( KeyFuncType eType )    const;

public:

    SfxAcceleratorConfigDialog( Window *pParent );
};

#endif

<|endoftext|>


<commit_before><commit_msg>Fix validation warning on scene change<commit_after><|endoftext|>


<commit_before>// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <string>

#include "base/basictypes.h"
#include "base/file_path.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_test_job.h"
#include "testing/gtest/include/gtest/gtest.h"

class ChildProcessSecurityPolicyTest : public testing::Test {
protected:
  // testing::Test
  virtual void SetUp() {
    // In the real world, "chrome:" is a handled scheme.
    URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme,
                                        &URLRequestTestJob::Factory);
  }
  virtual void TearDown() {
    URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme, NULL);
  }
};

static int kRendererID = 42;

TEST_F(ChildProcessSecurityPolicyTest, IsWebSafeSchemeTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  EXPECT_TRUE(p->IsWebSafeScheme("http"));
  EXPECT_TRUE(p->IsWebSafeScheme("https"));
  EXPECT_TRUE(p->IsWebSafeScheme("ftp"));
  EXPECT_TRUE(p->IsWebSafeScheme("data"));
  EXPECT_TRUE(p->IsWebSafeScheme("feed"));
  EXPECT_TRUE(p->IsWebSafeScheme("chrome-extension"));

  EXPECT_FALSE(p->IsWebSafeScheme("registered-web-safe-scheme"));
  p->RegisterWebSafeScheme("registered-web-safe-scheme");
  EXPECT_TRUE(p->IsWebSafeScheme("registered-web-safe-scheme"));
}

TEST_F(ChildProcessSecurityPolicyTest, IsPseudoSchemeTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  EXPECT_TRUE(p->IsPseudoScheme("about"));
  EXPECT_TRUE(p->IsPseudoScheme("javascript"));
  EXPECT_TRUE(p->IsPseudoScheme("view-source"));

  EXPECT_FALSE(p->IsPseudoScheme("registered-psuedo-scheme"));
  p->RegisterPseudoScheme("registered-psuedo-scheme");
  EXPECT_TRUE(p->IsPseudoScheme("registered-psuedo-scheme"));
}

TEST_F(ChildProcessSecurityPolicyTest, StandardSchemesTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  // Safe
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("http://www.google.com/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("https://www.paypal.com/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("ftp://ftp.gnu.org/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("data:text/html,Hi")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID,
                               GURL("view-source:http://www.google.com/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("chrome-extension://xy/z")));

  // Dangerous
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("file:///etc/passwd")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("view-cache:http://www.google.com/")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("chrome://foo/bar")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, AboutTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("about:blank")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("about:BlAnK")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("aBouT:BlAnK")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("aBouT:blank")));

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:memory")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:cache")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:hang")));

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("aBoUt:memory")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe")));

  p->GrantRequestURL(kRendererID, GURL("about:memory"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:memory")));

  p->GrantRequestURL(kRendererID, GURL("about:crash"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash")));

  p->GrantRequestURL(kRendererID, GURL("about:cache"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:cache")));

  p->GrantRequestURL(kRendererID, GURL("about:hang"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:hang")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, JavaScriptTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("javascript:alert('xss')")));
  p->GrantRequestURL(kRendererID, GURL("javascript:alert('xss')"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("javascript:alert('xss')")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, RegisterWebSafeSchemeTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  // Currently, "asdf" is destined for ShellExecute, so it is allowed.
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  // Once we register a ProtocolFactory for "asdf", we default to deny.
  URLRequest::RegisterProtocolFactory("asdf", &URLRequestTestJob::Factory);
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  // We can allow new schemes by adding them to the whitelist.
  p->RegisterWebSafeScheme("asdf");
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  // Cleanup.
  URLRequest::RegisterProtocolFactory("asdf", NULL);
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanServiceCommandsTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));
  p->GrantRequestURL(kRendererID, GURL("file:///etc/passwd"));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));

  // We should forget our state if we repeat a renderer id.
  p->Remove(kRendererID);
  p->Add(kRendererID);
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));
  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, ViewSource) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  // View source is determined by the embedded scheme.
  EXPECT_TRUE(p->CanRequestURL(kRendererID,
                               GURL("view-source:http://www.google.com/")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("view-source:file:///etc/passwd")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));

  p->GrantRequestURL(kRendererID, GURL("view-source:file:///etc/passwd"));
  // View source needs to be able to request the embedded scheme.
  EXPECT_TRUE(p->CanRequestURL(kRendererID,
                               GURL("view-source:file:///etc/passwd")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanUploadFiles) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
  p->GrantUploadFile(kRendererID, FilePath(FILE_PATH_LITERAL("/etc/passwd")));
  EXPECT_TRUE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/shadow"))));

  p->Remove(kRendererID);
  p->Add(kRendererID);

  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/shadow"))));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanServiceInspectElement) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  GURL url("chrome://inspector/inspector.html");

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
  p->GrantInspectElement(kRendererID);
  EXPECT_TRUE(p->CanRequestURL(kRendererID, url));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanServiceDOMUIBindings) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  GURL url("chrome://thumb/http://www.google.com/");

  p->Add(kRendererID);

  EXPECT_FALSE(p->HasDOMUIBindings(kRendererID));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
  p->GrantDOMUIBindings(kRendererID);
  EXPECT_TRUE(p->HasDOMUIBindings(kRendererID));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, url));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, RemoveRace) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  GURL url("file:///etc/passwd");
  FilePath file(FILE_PATH_LITERAL("/etc/passwd"));

  p->Add(kRendererID);

  p->GrantRequestURL(kRendererID, url);
  p->GrantUploadFile(kRendererID, file);
  p->GrantDOMUIBindings(kRendererID);

  EXPECT_TRUE(p->CanRequestURL(kRendererID, url));
  EXPECT_TRUE(p->CanUploadFile(kRendererID, file));
  EXPECT_TRUE(p->HasDOMUIBindings(kRendererID));

  p->Remove(kRendererID);

  // Renderers are added and removed on the UI thread, but the policy can be
  // queried on the IO thread.  The ChildProcessSecurityPolicy needs to be prepared
  // to answer policy questions about renderers who no longer exist.

  // In this case, we default to secure behavior.
  EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
  EXPECT_FALSE(p->CanUploadFile(kRendererID, file));
  EXPECT_FALSE(p->HasDOMUIBindings(kRendererID));
}

#if defined(OS_WIN)

class ChildProcessSecurityPolicyInProcessBrowserTest
    : public InProcessBrowserTest {
 public:
  virtual void SetUp() {
    EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 0U);
    InProcessBrowserTest::SetUp();
  }

  virtual void TearDown() {
    EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 0U);
    InProcessBrowserTest::TearDown();
  }
};

IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) {
  FilePath path;
  PathService::Get(chrome::DIR_TEST_DATA, &path);
  path = path.Append(FilePath::FromWStringHack(L"google"));
  path = path.Append(FilePath::FromWStringHack(L"google.html"));
  GURL url = net::FilePathToFileURL(path);

  ui_test_utils::NavigateToURL(browser(), url);
  EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 1U);

  TabContents* tab = browser()->GetTabContentsAt(0);
  ASSERT_TRUE(tab != NULL);
  base::KillProcess(
      tab->process()->process().handle(), base::PROCESS_END_KILLED_BY_USER,
      true);

  tab->controller().Reload(true);
  EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 1U);
}

#endif
<commit_msg>Disable test since it's causing others to fail<commit_after>// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <string>

#include "base/basictypes.h"
#include "base/file_path.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_test_job.h"
#include "testing/gtest/include/gtest/gtest.h"

class ChildProcessSecurityPolicyTest : public testing::Test {
protected:
  // testing::Test
  virtual void SetUp() {
    // In the real world, "chrome:" is a handled scheme.
    URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme,
                                        &URLRequestTestJob::Factory);
  }
  virtual void TearDown() {
    URLRequest::RegisterProtocolFactory(chrome::kChromeUIScheme, NULL);
  }
};

static int kRendererID = 42;

TEST_F(ChildProcessSecurityPolicyTest, IsWebSafeSchemeTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  EXPECT_TRUE(p->IsWebSafeScheme("http"));
  EXPECT_TRUE(p->IsWebSafeScheme("https"));
  EXPECT_TRUE(p->IsWebSafeScheme("ftp"));
  EXPECT_TRUE(p->IsWebSafeScheme("data"));
  EXPECT_TRUE(p->IsWebSafeScheme("feed"));
  EXPECT_TRUE(p->IsWebSafeScheme("chrome-extension"));

  EXPECT_FALSE(p->IsWebSafeScheme("registered-web-safe-scheme"));
  p->RegisterWebSafeScheme("registered-web-safe-scheme");
  EXPECT_TRUE(p->IsWebSafeScheme("registered-web-safe-scheme"));
}

TEST_F(ChildProcessSecurityPolicyTest, IsPseudoSchemeTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  EXPECT_TRUE(p->IsPseudoScheme("about"));
  EXPECT_TRUE(p->IsPseudoScheme("javascript"));
  EXPECT_TRUE(p->IsPseudoScheme("view-source"));

  EXPECT_FALSE(p->IsPseudoScheme("registered-psuedo-scheme"));
  p->RegisterPseudoScheme("registered-psuedo-scheme");
  EXPECT_TRUE(p->IsPseudoScheme("registered-psuedo-scheme"));
}

TEST_F(ChildProcessSecurityPolicyTest, StandardSchemesTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  // Safe
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("http://www.google.com/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("https://www.paypal.com/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("ftp://ftp.gnu.org/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("data:text/html,Hi")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID,
                               GURL("view-source:http://www.google.com/")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("chrome-extension://xy/z")));

  // Dangerous
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("file:///etc/passwd")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("view-cache:http://www.google.com/")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("chrome://foo/bar")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, AboutTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("about:blank")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("about:BlAnK")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("aBouT:BlAnK")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("aBouT:blank")));

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:memory")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:cache")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:hang")));

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("aBoUt:memory")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe")));

  p->GrantRequestURL(kRendererID, GURL("about:memory"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:memory")));

  p->GrantRequestURL(kRendererID, GURL("about:crash"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash")));

  p->GrantRequestURL(kRendererID, GURL("about:cache"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:cache")));

  p->GrantRequestURL(kRendererID, GURL("about:hang"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:hang")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, JavaScriptTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("javascript:alert('xss')")));
  p->GrantRequestURL(kRendererID, GURL("javascript:alert('xss')"));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("javascript:alert('xss')")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, RegisterWebSafeSchemeTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  // Currently, "asdf" is destined for ShellExecute, so it is allowed.
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  // Once we register a ProtocolFactory for "asdf", we default to deny.
  URLRequest::RegisterProtocolFactory("asdf", &URLRequestTestJob::Factory);
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  // We can allow new schemes by adding them to the whitelist.
  p->RegisterWebSafeScheme("asdf");
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  // Cleanup.
  URLRequest::RegisterProtocolFactory("asdf", NULL);
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("asdf:rockers")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanServiceCommandsTest) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));
  p->GrantRequestURL(kRendererID, GURL("file:///etc/passwd"));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));

  // We should forget our state if we repeat a renderer id.
  p->Remove(kRendererID);
  p->Add(kRendererID);
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));
  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, ViewSource) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  // View source is determined by the embedded scheme.
  EXPECT_TRUE(p->CanRequestURL(kRendererID,
                               GURL("view-source:http://www.google.com/")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID,
                                GURL("view-source:file:///etc/passwd")));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));

  p->GrantRequestURL(kRendererID, GURL("view-source:file:///etc/passwd"));
  // View source needs to be able to request the embedded scheme.
  EXPECT_TRUE(p->CanRequestURL(kRendererID,
                               GURL("view-source:file:///etc/passwd")));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanUploadFiles) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
  p->GrantUploadFile(kRendererID, FilePath(FILE_PATH_LITERAL("/etc/passwd")));
  EXPECT_TRUE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/shadow"))));

  p->Remove(kRendererID);
  p->Add(kRendererID);

  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
  EXPECT_FALSE(p->CanUploadFile(kRendererID,
      FilePath(FILE_PATH_LITERAL("/etc/shadow"))));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanServiceInspectElement) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  GURL url("chrome://inspector/inspector.html");

  p->Add(kRendererID);

  EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
  p->GrantInspectElement(kRendererID);
  EXPECT_TRUE(p->CanRequestURL(kRendererID, url));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, CanServiceDOMUIBindings) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  GURL url("chrome://thumb/http://www.google.com/");

  p->Add(kRendererID);

  EXPECT_FALSE(p->HasDOMUIBindings(kRendererID));
  EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
  p->GrantDOMUIBindings(kRendererID);
  EXPECT_TRUE(p->HasDOMUIBindings(kRendererID));
  EXPECT_TRUE(p->CanRequestURL(kRendererID, url));

  p->Remove(kRendererID);
}

TEST_F(ChildProcessSecurityPolicyTest, RemoveRace) {
  ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();

  GURL url("file:///etc/passwd");
  FilePath file(FILE_PATH_LITERAL("/etc/passwd"));

  p->Add(kRendererID);

  p->GrantRequestURL(kRendererID, url);
  p->GrantUploadFile(kRendererID, file);
  p->GrantDOMUIBindings(kRendererID);

  EXPECT_TRUE(p->CanRequestURL(kRendererID, url));
  EXPECT_TRUE(p->CanUploadFile(kRendererID, file));
  EXPECT_TRUE(p->HasDOMUIBindings(kRendererID));

  p->Remove(kRendererID);

  // Renderers are added and removed on the UI thread, but the policy can be
  // queried on the IO thread.  The ChildProcessSecurityPolicy needs to be prepared
  // to answer policy questions about renderers who no longer exist.

  // In this case, we default to secure behavior.
  EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
  EXPECT_FALSE(p->CanUploadFile(kRendererID, file));
  EXPECT_FALSE(p->HasDOMUIBindings(kRendererID));
}

#if defined(OS_WIN)

class ChildProcessSecurityPolicyInProcessBrowserTest
    : public InProcessBrowserTest {
 public:
  virtual void SetUp() {
    EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 0U);
    InProcessBrowserTest::SetUp();
  }

  virtual void TearDown() {
    EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 0U);
    InProcessBrowserTest::TearDown();
  }
};

IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, DISABLED_NoLeak) {
  FilePath path;
  PathService::Get(chrome::DIR_TEST_DATA, &path);
  path = path.Append(FilePath::FromWStringHack(L"google"));
  path = path.Append(FilePath::FromWStringHack(L"google.html"));
  GURL url = net::FilePathToFileURL(path);

  ui_test_utils::NavigateToURL(browser(), url);
  EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 1U);

  TabContents* tab = browser()->GetTabContentsAt(0);
  ASSERT_TRUE(tab != NULL);
  base::KillProcess(
      tab->process()->process().handle(), base::PROCESS_END_KILLED_BY_USER,
      true);

  tab->controller().Reload(true);
  EXPECT_EQ(
      ChildProcessSecurityPolicy::GetInstance()->security_state_.size(), 1U);
}

#endif
<|endoftext|>


<commit_before>#include "SimpleJupiterSatellites.h"

#include "Maths/PDEMaths.h"

// SE - TODO: ... get data from horizons and make a fit?

/*
const KeplerElements IoKeplerOrbitalEphemeris::kxElements =
{
};
*/

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements MetisKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 336.4005150234270 ),
    PDE::Deg2Rad( 2.230949860674993 ),
    PDE::Deg2Rad( 123.2624202368908 ),
    0.0008620661440651730,
    0.007946059897956641,
    PDE::Deg2Rad( 359.1454862030957 ),
    PDE::Deg2Rad( 1203.102420759774 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements AdrasteaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 337.9367720657275 ),
    PDE::Deg2Rad( 2.279436226180493 ),
    PDE::Deg2Rad( 98.26438988098714 ),
    0.0008681044460624248,
    0.006580796501884345,
    PDE::Deg2Rad( 356.7485100936312 ),
    PDE::Deg2Rad( 1190.571587148306 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements AmaltheaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 329.0107309027490 ),
    PDE::Deg2Rad( 2.015464116682605 ),
    PDE::Deg2Rad( 313.2507339673505 ),
    0.001216519191149836,
    0.00248074833492421,
    PDE::Deg2Rad( 65.17184176554154 ),
    PDE::Deg2Rad( 717.6869325429853 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements ThebeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 350.8153645274925 ),
    PDE::Deg2Rad( 3.116498381975071 ),
    PDE::Deg2Rad( 351.2737497067845 ),
    0.001486538950497333,
    0.01611031342897255,
    PDE::Deg2Rad( 130.8476360249211 ),
    PDE::Deg2Rad( 531.3112906518649 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements IoKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 337.2145512233379 ),
    PDE::Deg2Rad( 2.201269687356567 ),
    PDE::Deg2Rad( 98.32070501224331 ),
    0.002821049635725075,
    0.003752318988860653,
    PDE::Deg2Rad( 122.2240177752877 ),
    PDE::Deg2Rad( 203.2270727974874 ),
    2457357.5,
};

// SE - NOTE: no idea what the reference plane is... assume ecliptic?

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements LedaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 249.02157 ),
    PDE::Deg2Rad( 26.70534 ),
    PDE::Deg2Rad( 217.11857 ),
    0.0741038,
    0.1470003,
    PDE::Deg2Rad( 150.57874 ),
    PDE::Deg2Rad( 1.50972268 ),
    2442320.5, // 1974-Sep-30
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements HimaliaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 64.19257 ),
    PDE::Deg2Rad( 30.24666 ),
    PDE::Deg2Rad( 321.24132 ),
    0.0760468,
    0.1665967,
    PDE::Deg2Rad( 71.55525 ),
    PDE::Deg2Rad( 1.45238101 ),
    2451540.5, // 1999-Dec-28
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements ElaraKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 112.83775 ),
    PDE::Deg2Rad( 28.90366 ),
    PDE::Deg2Rad( 129.98928 ),
    0.0784653,
    0.2217152,
    PDE::Deg2Rad( 340.59927 ),
    PDE::Deg2Rad( 1.38575310 ),
    2451540.5, // 1999-Dec-28
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements LysitheaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 22.16328 ),
    PDE::Deg2Rad( 27.81628 ),
    PDE::Deg2Rad( 28.92678 ),
    0.0785543,
    0.1046442,
    PDE::Deg2Rad( 227.21422 ),
    PDE::Deg2Rad( 1.38339721 ),
    2447580.5, // 1989-Feb-23
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements AnankeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 331.30582 ),
    PDE::Deg2Rad( 146.96187 ),
    PDE::Deg2Rad( 58.72381 ),
    0.1403856,
    0.2524233,
    PDE::Deg2Rad( 144.19425 ),
    PDE::Deg2Rad( 0.57905295 ),
    2447580.5, // 1989-Feb-23
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements CarmeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 74.27767 ),
    PDE::Deg2Rad( 166.33569 ),
    PDE::Deg2Rad( 313.48927 ),
    0.1480462,
    0.2630848,
    PDE::Deg2Rad( 125.52653 ),
    PDE::Deg2Rad( 0.53469510 ),
    2447580.5, // 1989-Feb-23
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements PasiphaeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 315.66157 ),
    PDE::Deg2Rad( 140.03626 ),
    PDE::Deg2Rad( 173.13413 ),
    0.1561900,
    0.3801964,
    PDE::Rad2Deg( 276.60510 ),
    PDE::Deg2Rad( 0.49342641 ),
    2451540.5, // 1999-Dec-28
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements SinopeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 269.90288 ),
    PDE::Deg2Rad( 157.95047 ),
    PDE::Deg2Rad( 301.07683 ),
    0.1583604,
    0.3699151,
    PDE::Deg2Rad( 92.16244 ),
    PDE::Deg2Rad( 0.48331731 ),
    2447580.5, // 1989-Feb-23
};
<commit_msg>more galileans<commit_after>#include "SimpleJupiterSatellites.h"

#include "Maths/PDEMaths.h"

// SE - TODO: ... get data from horizons and make a fit?

/*
const KeplerElements IoKeplerOrbitalEphemeris::kxElements =
{
};
*/

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements MetisKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 336.4005150234270 ),
    PDE::Deg2Rad( 2.230949860674993 ),
    PDE::Deg2Rad( 123.2624202368908 ),
    0.0008620661440651730,
    0.007946059897956641,
    PDE::Deg2Rad( 359.1454862030957 ),
    PDE::Deg2Rad( 1203.102420759774 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements AdrasteaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 337.9367720657275 ),
    PDE::Deg2Rad( 2.279436226180493 ),
    PDE::Deg2Rad( 98.26438988098714 ),
    0.0008681044460624248,
    0.006580796501884345,
    PDE::Deg2Rad( 356.7485100936312 ),
    PDE::Deg2Rad( 1190.571587148306 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements AmaltheaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 329.0107309027490 ),
    PDE::Deg2Rad( 2.015464116682605 ),
    PDE::Deg2Rad( 313.2507339673505 ),
    0.001216519191149836,
    0.00248074833492421,
    PDE::Deg2Rad( 65.17184176554154 ),
    PDE::Deg2Rad( 717.6869325429853 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements ThebeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 350.8153645274925 ),
    PDE::Deg2Rad( 3.116498381975071 ),
    PDE::Deg2Rad( 351.2737497067845 ),
    0.001486538950497333,
    0.01611031342897255,
    PDE::Deg2Rad( 130.8476360249211 ),
    PDE::Deg2Rad( 531.3112906518649 ),
    2456171.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements IoKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 337.2145512233379 ),
    PDE::Deg2Rad( 2.201269687356567 ),
    PDE::Deg2Rad( 98.32070501224331 ),
    0.002821049635725075,
    0.003752318988860653,
    PDE::Deg2Rad( 122.2240177752877 ),
    PDE::Deg2Rad( 203.2270727974874 ),
    2457357.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements EuropaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 340.7659564998470 ),
    PDE::Deg2Rad( 2.678461676229340 ),
    PDE::Deg2Rad( 267.6474184300764 ),
    0.004487487813609674,
    0.009269287514518767,
    PDE::Deg2Rad( 244.8682907676467 ),
    0.5 * PDE::Deg2Rad( 203.2270727974874 ),
    2457357.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements GanymedeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 340.8500741618403 ),
    PDE::Deg2Rad( 2.289337328826746 ),
    PDE::Deg2Rad( 357.1900045314197 ),
    0.007155073783245806,
    0.001919286233374703,
    PDE::Deg2Rad( 33.06853497022615 ),
    0.25 * PDE::Deg2Rad( 203.2270727974874 ),
    2457357.5,
};

// Source: JPL Horizons osculating elements - these are relative to the ecliptic
// for certain... because thats what i asked for :)
const KeplerElements CallistoKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 337.1272375263306 ),
    PDE::Deg2Rad( 1.978764514395921 ),
    PDE::Deg2Rad( 26.51912928452954 ),
    0.01258782275430763,
    0.007046550009794705,
    PDE::Deg2Rad( 177.3928942496798 ),
    PDE::Deg2Rad( 21.56253723231748 ),
    2457357.5,
};

// SE - NOTE: no idea what the reference plane is... assume ecliptic?

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements LedaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 249.02157 ),
    PDE::Deg2Rad( 26.70534 ),
    PDE::Deg2Rad( 217.11857 ),
    0.0741038,
    0.1470003,
    PDE::Deg2Rad( 150.57874 ),
    PDE::Deg2Rad( 1.50972268 ),
    2442320.5, // 1974-Sep-30
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements HimaliaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 64.19257 ),
    PDE::Deg2Rad( 30.24666 ),
    PDE::Deg2Rad( 321.24132 ),
    0.0760468,
    0.1665967,
    PDE::Deg2Rad( 71.55525 ),
    PDE::Deg2Rad( 1.45238101 ),
    2451540.5, // 1999-Dec-28
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements ElaraKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 112.83775 ),
    PDE::Deg2Rad( 28.90366 ),
    PDE::Deg2Rad( 129.98928 ),
    0.0784653,
    0.2217152,
    PDE::Deg2Rad( 340.59927 ),
    PDE::Deg2Rad( 1.38575310 ),
    2451540.5, // 1999-Dec-28
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements LysitheaKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 22.16328 ),
    PDE::Deg2Rad( 27.81628 ),
    PDE::Deg2Rad( 28.92678 ),
    0.0785543,
    0.1046442,
    PDE::Deg2Rad( 227.21422 ),
    PDE::Deg2Rad( 1.38339721 ),
    2447580.5, // 1989-Feb-23
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements AnankeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 331.30582 ),
    PDE::Deg2Rad( 146.96187 ),
    PDE::Deg2Rad( 58.72381 ),
    0.1403856,
    0.2524233,
    PDE::Deg2Rad( 144.19425 ),
    PDE::Deg2Rad( 0.57905295 ),
    2447580.5, // 1989-Feb-23
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements CarmeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 74.27767 ),
    PDE::Deg2Rad( 166.33569 ),
    PDE::Deg2Rad( 313.48927 ),
    0.1480462,
    0.2630848,
    PDE::Deg2Rad( 125.52653 ),
    PDE::Deg2Rad( 0.53469510 ),
    2447580.5, // 1989-Feb-23
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements PasiphaeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 315.66157 ),
    PDE::Deg2Rad( 140.03626 ),
    PDE::Deg2Rad( 173.13413 ),
    0.1561900,
    0.3801964,
    PDE::Rad2Deg( 276.60510 ),
    PDE::Deg2Rad( 0.49342641 ),
    2451540.5, // 1999-Dec-28
};

// Source: http://www.projectpluto.com/jsats.htm 2015-Aug-16
const KeplerElements SinopeKeplerOrbitalEphemeris::kxElements =
{
    PDE::Deg2Rad( 269.90288 ),
    PDE::Deg2Rad( 157.95047 ),
    PDE::Deg2Rad( 301.07683 ),
    0.1583604,
    0.3699151,
    PDE::Deg2Rad( 92.16244 ),
    PDE::Deg2Rad( 0.48331731 ),
    2447580.5, // 1989-Feb-23
};
<|endoftext|>


<commit_before>#include "../src/rcon.hpp"

int main() {
  #include "../examples/rcon_basic_usage.cpp"
  #include "../examples/rcon_deferred_authorisation.cpp"
  return 0;
}
<commit_msg>Use global includes.<commit_after>#include <lrcon.hpp>

#include <iostream>

int main() {
  #include "../examples/rcon_basic_usage.cpp"
  #include "../examples/rcon_deferred_authorisation.cpp"
  return 0;
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: chips/p9/procedures/hwp/memory/p9_mss_draminit_mc.C $         */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* EKB Project                                                            */
/*                                                                        */
/* COPYRIGHT 2015,2016                                                    */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

///
/// @file p9_mss_draminit_mc.C
/// @brief Initialize the memory controller to take over the DRAM
///
// *HWP HWP Owner: Brian Silver <bsilver@us.ibm.com>
// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 2
// *HWP Consumed by: FSP:HB

#include <fapi2.H>
#include <mss.H>

#include <p9_mss_draminit_mc.H>

using fapi2::TARGET_TYPE_MCBIST;
using fapi2::TARGET_TYPE_MCA;
using fapi2::TARGET_TYPE_MCS;

extern "C"
{
///
/// @brief Initialize the MC now that DRAM is up
/// @param[in] i_target, the McBIST of the ports
/// @return FAPI2_RC_SUCCESS iff ok
///
    fapi2::ReturnCode p9_mss_draminit_mc( const fapi2::Target<TARGET_TYPE_MCBIST>& i_target )
    {
        auto l_mca = i_target.getChildren<TARGET_TYPE_MCA>();

        FAPI_INF("Start draminit MC");

        // If we don't have any ports, lets go.
        if (l_mca.size() == 0)
        {
            FAPI_INF("No ports? %s", mss::c_str(i_target));
            return fapi2::FAPI2_RC_SUCCESS;
        }

        // While we're doing the scominit in here, lets do it for all ports before we dump the MCS regs.
        for (auto p : i_target.getChildren<TARGET_TYPE_MCA>())
        {
            mss::mc<TARGET_TYPE_MCS> l_mc;

            // Don't do this yet - leverage the sim inits for the moment
#if 0
            // All the scominit for this MCA
            l_mc.scominit(p);
#endif
            // Setup the MC port/dimm address translation registers
            FAPI_TRY( l_mc.setup_xlate_map(p) );
        }

        for (auto p : l_mca)
        {

            // Setup the read_pointer_delay
            // TK: Do we need to do this in general or is this a place holder until the
            // init file gets here?
            {
                fapi2::buffer<uint64_t> l_data;
                FAPI_TRY( mss::getScom(p, MCA_RECR, l_data) );
                l_data.insertFromRight<MCA_RECR_MBSECCQ_READ_POINTER_DELAY, MCA_RECR_MBSECCQ_READ_POINTER_DELAY_LEN>(0x1);
                FAPI_DBG("writing read pointer delay 0x%016lx %s", l_data, mss::c_str(p));
                FAPI_TRY( mss::putScom(p, MCA_RECR, l_data) );
            }

            // Set the IML Complete bit MBSSQ(3) (SCOM Addr: 0x02011417) to indicate that IML has completed
            // Can't find MBSSQ or the iml_complete bit - asked Steve. Gary VH created this bit as a scratch
            // 'you are hre bit' and it was removed for Nimbus. Gary VH asked for it to be put back in. Not
            // sure if that happened yet. BRS (2/16).

            // Reset addr_mux_sel to “0” to allow the MCA to take control of the DDR interface over from CCS.
            // (Note: this step must remain in this procedure to ensure that data path is placed into mainline
            // mode prior to running memory diagnostics. This step maybe superfluous but not harmful.)
            // Note: addr_mux_sel is set low in p9_mss_draminit(), however that might be a work-around so we
            // set it low here kind of like belt-and-suspenders. BRS
            FAPI_TRY( mss::change_addr_mux_sel(p, mss::LOW) );

            // Re-enable port fails. Turned off in draminit_training
            FAPI_TRY( mss::change_port_fail_disable(p, mss::OFF ) );

            // Step Two.1: Check RCD protect time on RDIMM and LRDIMM
            // Step Two.2: Enable address inversion on each MBA for ALL CARDS

            // Start the refresh engines by setting MBAREF0Q(0) = “1”. Note that the remaining bits in
            // MBAREF0Q should retain their initialization values.
            FAPI_TRY( mss::change_refresh_enable(p, mss::HIGH) );

            // Power management is handled in the init file. (or should be BRS)

            // Enabling periodic calibration
            FAPI_TRY( mss::enable_periodic_cal(p) );

            // Step Six: Setup Control Bit ECC
            FAPI_TRY( mss::enable_read_ecc(p) );

            // At this point the DDR interface must be monitored for memory errors. Memory related FIRs should be unmasked.

            // Cram a fast write, followed by a read in here for giggles
            {
                mss::mcbist::program<TARGET_TYPE_MCBIST> l_program;
                uint64_t l_start = 0;
                uint64_t l_end = 0;
                uint64_t l_pattern = 0;

                // Write
                {
                    // Uses address register set 0
                    mss::mcbist::subtest_t<TARGET_TYPE_MCBIST> l_fw_subtest =
                        mss::mcbist::write_subtest<TARGET_TYPE_MCBIST>();
                    l_fw_subtest.enable_port(mss::pos(p));

                    // HACK: We only need to worry about the DIMM in slot 0 right now
                    l_fw_subtest.enable_dimm(0);
                    l_program.iv_subtests.push_back(l_fw_subtest);
                }

                // Read
                {
                    // Uses address register set 0
                    mss::mcbist::subtest_t<TARGET_TYPE_MCBIST> l_fr_subtest =
                        mss::mcbist::read_subtest<TARGET_TYPE_MCBIST>();
                    l_fr_subtest.enable_port(mss::pos(p));

                    // HACK: We only need to worry about the DIMM in slot 0 right now
                    l_fr_subtest.enable_dimm(0);
                    l_program.iv_subtests.push_back(l_fr_subtest);
                }

                FAPI_TRY( mss::mcbist_start_addr(p, l_start) );
                FAPI_TRY( mss::mcbist_end_addr(p, l_end) );

                // TK: calculate proper polling based on address range

                // Setup a nice pattern for writing
                FAPI_TRY( mss::mcbist_write_data(i_target, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD0Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD1Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD2Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD3Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD4Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD5Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD6Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD7Q, l_pattern) );

                // Sanity check - can't do much if end is before start.
                // This is either a programming error or a mistake in attribute settings. So we'll just assert.
                if (l_end < l_start)
                {
                    FAPI_ERR("mcbist end address is less than mcbist starting address. s: 0x%x e: 0x%x", l_start, l_end);
                    fapi2::Assert(false);
                }

                // By default we're in maint address mode so we do a start + len and the 'BIST increments for us.
                // By default, the write subtest uses the 0'th address start/end registers.
                mss::mcbist::config_address_range0(i_target, l_start, l_end - l_start);

                // Just one port for now. Per Shelton we need to set this in maint adress mode
                // even tho we specify the port/dimm in the subtest.
                fapi2::buffer<uint8_t> l_port;
                l_port.setBit(mss::pos(p));
                l_program.select_ports(l_port >> 4);

                // Kick it off, wait for a result
                FAPI_TRY( mss::mcbist::execute(i_target, l_program) );
            }
        }

    fapi_try_exit:
        FAPI_INF("End draminit MC");
        return fapi2::current_err;
    }
}
<commit_msg>Change the mcbist draminit_mc timeout to be based on the address range<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: chips/p9/procedures/hwp/memory/p9_mss_draminit_mc.C $         */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* EKB Project                                                            */
/*                                                                        */
/* COPYRIGHT 2015,2016                                                    */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

///
/// @file p9_mss_draminit_mc.C
/// @brief Initialize the memory controller to take over the DRAM
///
// *HWP HWP Owner: Brian Silver <bsilver@us.ibm.com>
// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 2
// *HWP Consumed by: FSP:HB

#include <fapi2.H>
#include <mss.H>

#include <p9_mss_draminit_mc.H>

using fapi2::TARGET_TYPE_MCBIST;
using fapi2::TARGET_TYPE_MCA;
using fapi2::TARGET_TYPE_MCS;

extern "C"
{
///
/// @brief Initialize the MC now that DRAM is up
/// @param[in] i_target, the McBIST of the ports
/// @return FAPI2_RC_SUCCESS iff ok
///
    fapi2::ReturnCode p9_mss_draminit_mc( const fapi2::Target<TARGET_TYPE_MCBIST>& i_target )
    {
        auto l_mca = i_target.getChildren<TARGET_TYPE_MCA>();

        FAPI_INF("Start draminit MC");

        // If we don't have any ports, lets go.
        if (l_mca.size() == 0)
        {
            FAPI_INF("No ports? %s", mss::c_str(i_target));
            return fapi2::FAPI2_RC_SUCCESS;
        }

        // While we're doing the scominit in here, lets do it for all ports before we dump the MCS regs.
        for (auto p : i_target.getChildren<TARGET_TYPE_MCA>())
        {
            mss::mc<TARGET_TYPE_MCS> l_mc;

            // Don't do this yet - leverage the sim inits for the moment
#if 0
            // All the scominit for this MCA
            l_mc.scominit(p);
#endif
            // Setup the MC port/dimm address translation registers
            FAPI_TRY( l_mc.setup_xlate_map(p) );
        }

        for (auto p : l_mca)
        {

            // Setup the read_pointer_delay
            // TK: Do we need to do this in general or is this a place holder until the
            // init file gets here?
            {
                fapi2::buffer<uint64_t> l_data;
                FAPI_TRY( mss::getScom(p, MCA_RECR, l_data) );
                l_data.insertFromRight<MCA_RECR_MBSECCQ_READ_POINTER_DELAY, MCA_RECR_MBSECCQ_READ_POINTER_DELAY_LEN>(0x1);
                FAPI_DBG("writing read pointer delay 0x%016lx %s", l_data, mss::c_str(p));
                FAPI_TRY( mss::putScom(p, MCA_RECR, l_data) );
            }

            // Set the IML Complete bit MBSSQ(3) (SCOM Addr: 0x02011417) to indicate that IML has completed
            // Can't find MBSSQ or the iml_complete bit - asked Steve. Gary VH created this bit as a scratch
            // 'you are hre bit' and it was removed for Nimbus. Gary VH asked for it to be put back in. Not
            // sure if that happened yet. BRS (2/16).

            // Reset addr_mux_sel to “0” to allow the MCA to take control of the DDR interface over from CCS.
            // (Note: this step must remain in this procedure to ensure that data path is placed into mainline
            // mode prior to running memory diagnostics. This step maybe superfluous but not harmful.)
            // Note: addr_mux_sel is set low in p9_mss_draminit(), however that might be a work-around so we
            // set it low here kind of like belt-and-suspenders. BRS
            FAPI_TRY( mss::change_addr_mux_sel(p, mss::LOW) );

            // Re-enable port fails. Turned off in draminit_training
            FAPI_TRY( mss::change_port_fail_disable(p, mss::OFF ) );

            // Step Two.1: Check RCD protect time on RDIMM and LRDIMM
            // Step Two.2: Enable address inversion on each MBA for ALL CARDS

            // Start the refresh engines by setting MBAREF0Q(0) = “1”. Note that the remaining bits in
            // MBAREF0Q should retain their initialization values.
            FAPI_TRY( mss::change_refresh_enable(p, mss::HIGH) );

            // Power management is handled in the init file. (or should be BRS)

            // Enabling periodic calibration
            FAPI_TRY( mss::enable_periodic_cal(p) );

            // Step Six: Setup Control Bit ECC
            FAPI_TRY( mss::enable_read_ecc(p) );

            // At this point the DDR interface must be monitored for memory errors. Memory related FIRs should be unmasked.

            // Cram a fast write, followed by a read in here for giggles
            {
                mss::mcbist::program<TARGET_TYPE_MCBIST> l_program;
                uint64_t l_start = 0;
                uint64_t l_end = 0;
                uint64_t l_pattern = 0;

                // Write
                {
                    // Uses address register set 0
                    mss::mcbist::subtest_t<TARGET_TYPE_MCBIST> l_fw_subtest =
                        mss::mcbist::write_subtest<TARGET_TYPE_MCBIST>();
                    l_fw_subtest.enable_port(mss::pos(p));

                    // HACK: We only need to worry about the DIMM in slot 0 right now
                    l_fw_subtest.enable_dimm(0);
                    l_program.iv_subtests.push_back(l_fw_subtest);
                }

                // Read
                {
                    // Uses address register set 0
                    mss::mcbist::subtest_t<TARGET_TYPE_MCBIST> l_fr_subtest =
                        mss::mcbist::read_subtest<TARGET_TYPE_MCBIST>();
                    l_fr_subtest.enable_port(mss::pos(p));

                    // HACK: We only need to worry about the DIMM in slot 0 right now
                    l_fr_subtest.enable_dimm(0);
                    l_program.iv_subtests.push_back(l_fr_subtest);
                }

                FAPI_TRY( mss::mcbist_start_addr(p, l_start) );
                FAPI_TRY( mss::mcbist_end_addr(p, l_end) );

                // TK: calculate proper polling based on address range

                // Setup a nice pattern for writing
                FAPI_TRY( mss::mcbist_write_data(i_target, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD0Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD1Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD2Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD3Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD4Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD5Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD6Q, l_pattern) );
                FAPI_TRY( mss::putScom(i_target, MCBIST_MCBFD7Q, l_pattern) );

                // Sanity check - can't do much if end is before start.
                // This is either a programming error or a mistake in attribute settings. So we'll just assert.
                if (l_end < l_start)
                {
                    FAPI_ERR("mcbist end address is less than mcbist starting address. s: 0x%x e: 0x%x", l_start, l_end);
                    fapi2::Assert(false);
                }

                // By default we're in maint address mode so we do a start + len and the 'BIST increments for us.
                // By default, the write subtest uses the 0'th address start/end registers.
                mss::mcbist::config_address_range0(i_target, l_start, l_end - l_start);

                // Setup the polling based on a heuristic <cough>guess</cough>
                // Looks like 20ns per address for a write/read program, and add a long number of polls
                l_program.iv_poll.iv_initial_delay = (l_end - l_start) * 2 * mss::DELAY_10NS;
                l_program.iv_poll.iv_initial_sim_delay =
                    mss::cycles_to_simcycles(mss::ns_to_cycles(i_target, l_program.iv_poll.iv_initial_delay));
                l_program.iv_poll.iv_poll_count = 100;

                // Just one port for now. Per Shelton we need to set this in maint adress mode
                // even tho we specify the port/dimm in the subtest.
                fapi2::buffer<uint8_t> l_port;
                l_port.setBit(mss::pos(p));
                l_program.select_ports(l_port >> 4);

                // Kick it off, wait for a result
                FAPI_TRY( mss::mcbist::execute(i_target, l_program) );
            }
        }

    fapi_try_exit:
        FAPI_INF("End draminit MC");
        return fapi2::current_err;
    }
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_pm_ocb_indir_access.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
// @file p9_pm_ocb_indir_access.H
// @brief Access procedure to the OCC OCB indirect channels

// *HWP HWP Owner       : Greg Still <stillgs@us.ibm.com>
// *HWP Backup HWP Owner:
// *HWP FW Owner        : Bilicon Patil <bilpatil@in.ibm.com>
// *HWP Team            : PM
// *HWP Level           : 1
// *HWP Consumed by     : HS

#ifndef _P9_PM_OCBINDIRACC_H_
#define _P9_PM_OCBINDIRACC_H_

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <fapi2.H>
#include <p9_pm_ocb_init.H>

//------------------------------------------------------------------------------
// Constant definitions
//------------------------------------------------------------------------------

namespace p9ocb
{
enum P9_OCB_ACCESS_OP
{
    OCB_GET = 0x1,
    OCB_PUT = 0x2
};
}

// function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9_pm_ocb_indir_access_FP_t)
(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
 p9ocb::P9_OCB_CHAN_NUM     i_ocb_chan,
 p9ocb::P9_OCB_ACCESS_OP    i_ocb_op,
 const uint32_t             i_ocb_req_length,
 fapi2::buffer<uint64_t>&    io_ocb_buffer,
 uint32_t&                   o_ocb_act_length,
 const bool                 i_oci_address_valid,
 const uint32_t             i_oci_address);

//------------------------------------------------------------------------------
// Function prototype
//------------------------------------------------------------------------------

extern "C"
{

/// @brief Provides for the abstract access to an OCB indirect channel that has
/// been configured previously via p9_pm_ocb_indir_setup_[linear/circular]
/// procedures
///
/// @param[in]      &i_target           Chip target
/// @param[in]      i_ocb_chan          OCB channel number (0, 1, 2, 3)
/// @param[in]      i_ocb_op            Operation (Get, Put)
/// @param[in]      i_ocb_req_length    Requested length in the number of 8B
///                                     elements to be accessed (unit origin)
///                                     Number of bytes = (i_ocb_req_length) *
///                                     8B
/// @param[in/out] &io_ocb_buffer       Reference to fappi2::buffer
/// @param[out]    &o_ocb_act_length    Address containing to contain the actual
///                                     length in the number of 8B elements to
///                                     be accessed (zero origin)
///                                     Number of bytes = (i_ocb_act_length+1) *
///                                     8B
/// @param[in]      i_oci_address_valid Indicator that oci_address is to be used
/// @param[in]      i_oci_address       OCI Address to be used for the operation
/// @return FAPI2_RC_SUCCESS on success, else error.

    fapi2::ReturnCode p9_pm_ocb_indir_access(
        const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
        p9ocb::P9_OCB_CHAN_NUM      i_ocb_chan,
        p9ocb::P9_OCB_ACCESS_OP i_ocb_op,
        const uint32_t             i_ocb_req_length,
        fapi2::buffer<uint64_t>&    io_ocb_buffer,
        uint32_t&                   o_ocb_act_length,
        const bool                 i_oci_address_valid,
        const uint32_t             i_oci_address);

} // extern "C"

#endif // _P9_PM_OCBINDIRACC_H_
<commit_msg>JET: Level 2, Make p9_pm_ocb_init FAPI 2.0 compliant<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_pm_ocb_indir_access.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
// @file p9_pm_ocb_indir_access.H
// @brief Access procedure to the OCC OCB indirect channels

// *HWP HWP Owner       : Greg Still <stillgs@us.ibm.com>
// *HWP Backup HWP Owner:
// *HWP FW Owner        : Bilicon Patil <bilpatil@in.ibm.com>
// *HWP Team            : PM
// *HWP Level           : 1
// *HWP Consumed by     : HS

#ifndef _P9_PM_OCBINDIRACC_H_
#define _P9_PM_OCBINDIRACC_H_

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <fapi2.H>
#include <p9_pm_ocb_init.H>

//------------------------------------------------------------------------------
// Constant definitions
//------------------------------------------------------------------------------

namespace p9ocb
{
enum P9_OCB_ACCESS_OP
{
    OCB_GET = 0x1,
    OCB_PUT = 0x2
};
}

// function pointer typedef definition for HWP call support
typedef fapi2::ReturnCode (*p9_pm_ocb_indir_access_FP_t)
(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
 p9ocb::PM_OCB_CHAN_NUM     i_ocb_chan,
 p9ocb::P9_OCB_ACCESS_OP    i_ocb_op,
 const uint32_t             i_ocb_req_length,
 fapi2::buffer<uint64_t>&    io_ocb_buffer,
 uint32_t&                   o_ocb_act_length,
 const bool                 i_oci_address_valid,
 const uint32_t             i_oci_address);

//------------------------------------------------------------------------------
// Function prototype
//------------------------------------------------------------------------------

extern "C"
{

/// @brief Provides for the abstract access to an OCB indirect channel that has
/// been configured previously via p9_pm_ocb_indir_setup_[linear/circular]
/// procedures
///
/// @param[in]      &i_target           Chip target
/// @param[in]      i_ocb_chan          OCB channel number (0, 1, 2, 3)
/// @param[in]      i_ocb_op            Operation (Get, Put)
/// @param[in]      i_ocb_req_length    Requested length in the number of 8B
///                                     elements to be accessed (unit origin)
///                                     Number of bytes = (i_ocb_req_length) *
///                                     8B
/// @param[in/out] &io_ocb_buffer       Reference to fappi2::buffer
/// @param[out]    &o_ocb_act_length    Address containing to contain the actual
///                                     length in the number of 8B elements to
///                                     be accessed (zero origin)
///                                     Number of bytes = (i_ocb_act_length+1) *
///                                     8B
/// @param[in]      i_oci_address_valid Indicator that oci_address is to be used
/// @param[in]      i_oci_address       OCI Address to be used for the operation
/// @return FAPI2_RC_SUCCESS on success, else error.

    fapi2::ReturnCode p9_pm_ocb_indir_access(
        const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
        p9ocb::PM_OCB_CHAN_NUM      i_ocb_chan,
        p9ocb::P9_OCB_ACCESS_OP i_ocb_op,
        const uint32_t             i_ocb_req_length,
        fapi2::buffer<uint64_t>&    io_ocb_buffer,
        uint32_t&                   o_ocb_act_length,
        const bool                 i_oci_address_valid,
        const uint32_t             i_oci_address);

} // extern "C"

#endif // _P9_PM_OCBINDIRACC_H_
<|endoftext|>


<commit_before>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) {
  ASSERT_TRUE(StartTestServer());

  // Loads a simple extension which attempts to change the title of every page
  // that loads to "modified".
  ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("incognito")
      .AppendASCII("content_scripts")));

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  Browser* otr_browser = BrowserList::FindBrowserWithType(
      browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
      false);
  TabContents* tab = otr_browser->GetSelectedTabContents();

  // Verify the script didn't run.
  bool result = false;
  ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
      tab->render_view_host(), L"",
      L"window.domAutomationController.send(document.title == 'Unmodified')",
      &result));
  EXPECT_TRUE(result);
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  // Load a dummy extension. This just tests that we don't regress a
  // crash fix when multiple incognito- and non-incognito-enabled extensions
  // are mixed.
  ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("content_scripts")
      .AppendASCII("all_frames")));

  // Loads a simple extension which attempts to change the title of every page
  // that loads to "modified".
  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("content_scripts")));

  // Dummy extension #2.
  ASSERT_TRUE(LoadExtension(test_data_dir_
      .AppendASCII("content_scripts").AppendASCII("isolated_world1")));

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  Browser* otr_browser = BrowserList::FindBrowserWithType(
      browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
      false);
  TabContents* tab = otr_browser->GetSelectedTabContents();

  // Verify the script ran.
  bool result = false;
  ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
      tab->render_view_host(), L"",
      L"window.domAutomationController.send(document.title == 'modified')",
      &result));
  EXPECT_TRUE(result);
}

// Tests that an extension which is enabled for incognito mode doesn't
// accidentially create and incognito profile.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DontCreateIncognitoProfile) {
  ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
  ASSERT_TRUE(
      RunExtensionTestIncognito("incognito/enumerate_tabs")) << message_;
  ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
}

// TODO(kochi): Flaky at r65757 and after on buildbot for ChromiumOS.
// http://crosbug.com/9049
#if defined(OS_CHROMEOS)
#define MAYBE_Incognito FLAKY_Incognito
#else
#define MAYBE_Incognito Incognito
#endif

// Tests that the APIs in an incognito-enabled extension work properly.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Incognito) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  ResultCatcher catcher;

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("apis")));

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}

// Hangs flakily on mac and linux: http://crbug.com/53991
#if defined(OS_MACOSX) || defined(OS_LINUX)
#define MAYBE_IncognitoSplitMode DISABLED_IncognitoSplitMode
#else
#define MAYBE_IncognitoSplitMode IncognitoSplitMode
#endif

// Tests that the APIs in an incognito-enabled split-mode extension work
// properly.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_IncognitoSplitMode) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  // We need 2 ResultCatchers because we'll be running the same test in both
  // regular and incognito mode.
  ResultCatcher catcher;
  catcher.RestrictToProfile(browser()->profile());
  ResultCatcher catcher_incognito;
  catcher_incognito.RestrictToProfile(
      browser()->profile()->GetOffTheRecordProfile());

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("split")));

  // Wait for both extensions to be ready before telling them to proceed.
  ExtensionTestMessageListener listener("waiting", true);
  EXPECT_TRUE(listener.WaitUntilSatisfied());
  ExtensionTestMessageListener listener_incognito("waiting", true);
  EXPECT_TRUE(listener_incognito.WaitUntilSatisfied());
  listener.Reply("go");
  listener_incognito.Reply("go");

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
  EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message();
}

// Tests that the APIs in an incognito-disabled extension don't see incognito
// events or callbacks.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoDisabled) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  ResultCatcher catcher;

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  ASSERT_TRUE(LoadExtension(test_data_dir_
      .AppendASCII("incognito").AppendASCII("apis_disabled")));

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}

// Test that opening a popup from an incognito browser window works properly.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoPopup) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  ResultCatcher catcher;

  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("popup")));

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  Browser* incognito_browser = BrowserList::FindBrowserWithType(
      browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
      false);

  // Simulate the incognito's browser action being clicked.
  BrowserActionTestUtil(incognito_browser).Press(0);

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
<commit_msg>Reverts r65780.<commit_after>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) {
  ASSERT_TRUE(StartTestServer());

  // Loads a simple extension which attempts to change the title of every page
  // that loads to "modified".
  ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("incognito")
      .AppendASCII("content_scripts")));

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  Browser* otr_browser = BrowserList::FindBrowserWithType(
      browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
      false);
  TabContents* tab = otr_browser->GetSelectedTabContents();

  // Verify the script didn't run.
  bool result = false;
  ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
      tab->render_view_host(), L"",
      L"window.domAutomationController.send(document.title == 'Unmodified')",
      &result));
  EXPECT_TRUE(result);
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  // Load a dummy extension. This just tests that we don't regress a
  // crash fix when multiple incognito- and non-incognito-enabled extensions
  // are mixed.
  ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("content_scripts")
      .AppendASCII("all_frames")));

  // Loads a simple extension which attempts to change the title of every page
  // that loads to "modified".
  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("content_scripts")));

  // Dummy extension #2.
  ASSERT_TRUE(LoadExtension(test_data_dir_
      .AppendASCII("content_scripts").AppendASCII("isolated_world1")));

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  Browser* otr_browser = BrowserList::FindBrowserWithType(
      browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
      false);
  TabContents* tab = otr_browser->GetSelectedTabContents();

  // Verify the script ran.
  bool result = false;
  ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
      tab->render_view_host(), L"",
      L"window.domAutomationController.send(document.title == 'modified')",
      &result));
  EXPECT_TRUE(result);
}

// Tests that an extension which is enabled for incognito mode doesn't
// accidentially create and incognito profile.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DontCreateIncognitoProfile) {
  ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
  ASSERT_TRUE(
      RunExtensionTestIncognito("incognito/enumerate_tabs")) << message_;
  ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile());
}

// Tests that the APIs in an incognito-enabled extension work properly.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Incognito) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  ResultCatcher catcher;

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("apis")));

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}

// Hangs flakily on mac and linux: http://crbug.com/53991
#if defined(OS_MACOSX) || defined(OS_LINUX)
#define MAYBE_IncognitoSplitMode DISABLED_IncognitoSplitMode
#else
#define MAYBE_IncognitoSplitMode IncognitoSplitMode
#endif

// Tests that the APIs in an incognito-enabled split-mode extension work
// properly.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_IncognitoSplitMode) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  // We need 2 ResultCatchers because we'll be running the same test in both
  // regular and incognito mode.
  ResultCatcher catcher;
  catcher.RestrictToProfile(browser()->profile());
  ResultCatcher catcher_incognito;
  catcher_incognito.RestrictToProfile(
      browser()->profile()->GetOffTheRecordProfile());

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("split")));

  // Wait for both extensions to be ready before telling them to proceed.
  ExtensionTestMessageListener listener("waiting", true);
  EXPECT_TRUE(listener.WaitUntilSatisfied());
  ExtensionTestMessageListener listener_incognito("waiting", true);
  EXPECT_TRUE(listener_incognito.WaitUntilSatisfied());
  listener.Reply("go");
  listener_incognito.Reply("go");

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
  EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message();
}

// Tests that the APIs in an incognito-disabled extension don't see incognito
// events or callbacks.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoDisabled) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  ResultCatcher catcher;

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  ASSERT_TRUE(LoadExtension(test_data_dir_
      .AppendASCII("incognito").AppendASCII("apis_disabled")));

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}

// Test that opening a popup from an incognito browser window works properly.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoPopup) {
  host_resolver()->AddRule("*", "127.0.0.1");
  ASSERT_TRUE(StartTestServer());

  ResultCatcher catcher;

  ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_
      .AppendASCII("incognito").AppendASCII("popup")));

  // Open incognito window and navigate to test page.
  ui_test_utils::OpenURLOffTheRecord(
      browser()->profile(),
      test_server()->GetURL("files/extensions/test_file.html"));

  Browser* incognito_browser = BrowserList::FindBrowserWithType(
      browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL,
      false);

  // Simulate the incognito's browser action being clicked.
  BrowserActionTestUtil(incognito_browser).Press(0);

  EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
<|endoftext|>


<commit_before>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

#if defined(OS_LINUX) && defined(TOOLKIT_VIEWS)
// See http://crbug.com/30151.
#define Toolstrip DISABLED_Toolstrip
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Toolstrip) {
  ASSERT_TRUE(RunExtensionTest("toolstrip")) << message_;
}
<commit_msg>Disable ExtensionApiTest.Toolstrip, crashy.<commit_after>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"

// Disabled, http://crbug.com/30151.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Toolstrip) {
  ASSERT_TRUE(RunExtensionTest("toolstrip")) << message_;
}
<|endoftext|>